June 2019
Beginner to intermediate
770 pages
19h 24m
English
We can also design a composite command that's built from other commands. For this, we have two design strategies: object composition and class composition.
If we use object composition, then our composite command is based on the built-in list or tuple. We can extend or wrap one of the existing sequences. We'll create the composite Command object as a collection of instances of other Command objects. We might consider writing something like the following code:
simulate_and_analyze = [Simulate(), Analyze()]
This has the disadvantage that we haven't created a new class for our unique composite command. We created a generic composite and populated it with instances. If we want to create even higher-level ...
Read now
Unlock full access