Time for action - identifying units
Imagine that you're responsible for testing the following code:
def method1(self, number):
number += 4
number **= 0.5
number *= 7
def method2(self, number):
return ((number * 2) ** 1.27) * 0.3
def method3(self, number):
return self.method1(number) + self.method2(number)
return 1.713 * self.method3(id(self))
- In this example, what are the units? Is the whole class a single unit, or is each method a separate unit. How about each statement, or each expression? Keep in mind that the definition of a unit is somewhat subjective (although never bigger than a single class), and make your own decision.
- Think about what you chose. What would the consequences have been if ...