Reader small image

You're reading from  Learning Python Application Development

Product typeBook
Published inSep 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781785889196
Edition1st Edition
Languages
Right arrow
Author (1)
Ninad Sathaye
Ninad Sathaye
author image
Ninad Sathaye

Ninad Sathaye has spent several years of his professional career designing and developing performance-critical engineering applications written in a variety of languages, including Python and C++. He has worked as a software architect in the semiconductor industry, and more recently in the domain of Internet of Things. He holds a master's degree in mechanical engineering.
Read more about Ninad Sathaye

Right arrow

Strategy pattern


A strategy design pattern is a behavioral pattern that is used to represent a family of algorithms. An algorithm within such a family is represented as a strategy object. The pattern enables easy switching between different strategies (algorithms) of a particular family. This is generally useful when you want to switch to a different strategy at runtime. We will revisit this definition towards the end of the discussion on strategy pattern.

Strategy scenario – The jump feature

There is a high priority feature request. Rather, it is a complaint. The users just hate the movement restriction imposed by the fence. Now even Sir Foo has joined the protest...

Rather than removing the fence from the scenario, how about a new feature that enables units to jump over the fence or any similar obstacle?

You have introduced a new method, jump(), in the superclass AbstractGameUnit. All the classes inherit this method, as shown in the following class diagram:

The fence no longer prevents...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning Python Application Development
Published in: Sep 2016Publisher: PacktISBN-13: 9781785889196

Author (1)

author image
Ninad Sathaye

Ninad Sathaye has spent several years of his professional career designing and developing performance-critical engineering applications written in a variety of languages, including Python and C++. He has worked as a software architect in the semiconductor industry, and more recently in the domain of Internet of Things. He holds a master's degree in mechanical engineering.
Read more about Ninad Sathaye