Tuesday, January 18, 2005

Object BootCamp - day6

Today was a non-productive day. We started talking about the design for Temperature comparisons and then went ahead to implement it. We spent more than an hour to get the green bar for implementing the equals method. Most of us introduced a new class for Temperature which extends Unit class. We made the add method throw an UnsupportedException. Since the add operation should not be permitted on the Temperature class(because we cannot "add" two temperatures), we were not quite sure if that was a good idea. The alternative would be to have an addable quantity and then a factory to create Quantities. That way there would be no add method when we instantiate temperatures. We took the first route, though i didnt quite like that.

We then were stuck in deducing the relation between Celsius, Fahrenheit and Kelvin scales as a linear equation. I couldn't quite get it right and we spent an hour trying to figure out what was going wrong. Lessons learnt from today's session:

1. It should not take more than 15 minutes to get the green bar. Else, we probably are biting too much.
2. Had we taken smaller steps in representing the Temperature class, we probably would have made it.
3. We didn't spend time in designing at all. We had to pay for it by spending too much time on broken unit tests.
4. There are 4 features of OOP, encapsulation, inheritance, polymorphism and Identity.

Fred also suggested having a constant called Temperature in Unit class instead of a sub-class. He suggested using identity in place of inheritance. The identity is a very powerful concept. It is something which cannot be represented in RDBMS. We need to find either a string or a number to represent the identity.
That was what happened during a day of highly practical session.


At 4:44 PM, Blogger sundar said...

" We didn't spend time in designing at all. We had to pay for it by spending too much time on broken unit tests." why do you say this? isnt this against the principles of XP?

can you explain the concept of "Identity" a bit more?


Post a Comment

<< Home