100 likes | 241 Views
Magnets + magnetic disks = …. GTD. GTD Workflow & Processing. GTD Website. http://SlideShare.net GTD Workshop. Interview with David Allen. Overview. More OOP Composition Inheritance Overriding Unit testing. Composition.
E N D
GTD GTD Workflow & Processing GTD Website http://SlideShare.net GTD Workshop Interview with David Allen
Overview More OOP • Composition • Inheritance • Overriding Unit testing
Composition One object is composed of other objects (e.g. Car is composed of an engine, etc.)
Inheritance • Models “type-of” relationships between classes • Promotes code re-use Base class Superclass Parent class Animal formalName : str poop() : None Dog name : str bark() : None Cat name : str scratch() : None Derived classes Subclasses Child classes Cow moo() : None
Overriding • Method in base/super/parent class is overridden by derived/sub/child class Base class Superclass Parent class Animal formalName : str poop() : None Dog name : str bark() : None poop() : None Cat name : str scratch() : None Derived classes Subclasses Child classes Cow moo() : None
Class under test Unit Testing AAA Pattern for Unit Testing - Arrange all necessary preconditions and inputs. - Act on the object or method under test. - Assert that the expected results have occurred. Test class The unittest module contains a unit testingframework: classes andmethods to facilitatetesting.
Inheritance and Python unittest unittest.TestCase Dice DiceTest
Some more unittest details Special methods in the test class • setUp() – run before each method • tearDown() – run after each method