So, I want to submit you a challenge based on some object oriented crunches.
Give me your attention for some minutes, if you care, or if you don't have something better to do.
Say you have a Car object in your business domain.
It has state and behaviour, so no, it is not an anemic business object.
Say you have, besides all other components, a TransmissionGear which is a part of your car.
It has its good state and behaviour, in particular it has a GearType attribute which defines the actual gear, and a changeGear() method for changing gear.
Car, on its side, has a boost() method which interacts with the TransmissionGear and whose behaviour depends on the GearType.
Take a look at this diagram:
Say the boost() method, depending on the GearType, must do the following:
- Decreasing Car fuelQuantity and oilQuantity.
- Calling changeGear() on TransmissionGear
How would you do this?
There's no best method, but surely there's a method better than another one.
If you care, leave a short comment, or simply think.
Think about this.
I'll give you my solution in one of my next posts!
No comments:
Post a Comment