Learning Python Application Development by Unknown

Learning Python Application Development by Unknown

Author:Unknown
Language: eng
Format: epub, mobi
Publisher: Packt Publishing


Note

Recall that in Chapter 1, Developing Simple Applications, we used object composition in the Hut class where its occupant was represented by a different object. Object composition allows you to represent a complex object by putting together simple objects. Just say it out loud, a Knight has-the ability to move, a Knight has the ability to jump, and so on. Each of these abilities will be represented by separate objects.

How do we implement this new design? We will discuss two approaches to solving this problem. The first one is more of a classical approach that resembles the one typically followed in other languages, such as C++. If you have such a development background, this approach will look more familiar. The second approach is more Pythonic. It uses first-class functions, a language feature in Python. This second approach will make the whole problem appear trivial. If you are not interested in the traditional approach, skip ahead to the Pythonic solution for the strategy pattern.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.