Design Patterns

Java is chockful of design patterns. These are ways to organize classes and objects to solve recurring software engineering problems. The Java event model is an example of the Observer/Observable des ign pattern, also known as Pub lish and Subscrib e. Its purpose is to reduce coupling of tile source and the sink; (the listener).

Once you've mastered Python programming and read Object-OrientedAnalysis and Design with Applications (Booch, 1994), make sure; to read Design Patterns ((Grammaet al., 1995).

Now, if you use the StockPri ceChecker class in Python, you don't have to implement the StockPriceListener interface and register an instance with StockPri ceChecker. StockPri ceChecker has two event properties corresponding to the methods in the interface of StockPri ceListener—priceDropped and priceIncreased—so you can pass an event handler function that has one argument, which is passed as StockEvent.

If you're confused at this point, fear not We'll do lots of examples using both Python and Java event handling when we cover GUI progremmikg in Chapter 13.

Was this article helpful?

0 0

Post a comment