My first session.
The following was achieved:
- Set up of intellij idea
- Requriements 1 and 2
Requirement 1 ¶
We bhavdeep, deepak, surender go to albertsons. Buy worth 15$ (we r stingy). bhavdeep pays. the expense amt is shared equally among 3.
Steps: Write junit test case, it fails. Write code so test passes.
Classes: Transaction, ExpenseSheet, ExpenseLine, Money, Party.
- process method in Transaction generates Expense sheet. Has if statements to find out if Party is payer / receiver and then calculate. Smell of Party heirarchy.
- other classes have relatively no behavior.
- decision: for this requirement its good enuf but when moving to other requirements i will have to wear my refactoring hat before implementation.
Requirement 2 ¶
Same as requirement 1. Except bhavdeep has no share in the expenses. He only paid for it. divided equally between deepak and surender.
Steps: Write junit test method, it fails, then write code to make it pass
Classes: Transaction, ExpenseSheet, ExpenseLine, Money, Party, NonParticipantPayer->Party, Receiver->Party
- Refactored Transaction , Party classes to distribute behavior of ExpenseSheet generation.
- Heirarchy of Party created. Expense lines generation delegated to Party without conditional processing (claps)
- Transactions for above 2 requirements are equitable and non equitable. But they can change at run time. So I need to use State pattern. Havent done the refactoring. But its necessary though as of now only getEqualParts method has conditional processing. Thus this forms my next refactoring before I move on for the next requirement implementation
- Add more behavior into money class. Something like 5USd 3 times is 15USD should be done by money class. will make Party expense cacls simpler.
Current Class Diagram ¶
Disqus comments are disabled.