2008 Exam answers

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 2: Line 2:
 
Possible improvements to the design:
 
Possible improvements to the design:
 
* Replace the Pair class with a Transaction class and two subclasses CreditTransaction and DebitTransaction.  These classes will contain the information that was contained in Pair, and any other behavior related to transactions which is likely to have leaked out into the rest of the system.
 
* Replace the Pair class with a Transaction class and two subclasses CreditTransaction and DebitTransaction.  These classes will contain the information that was contained in Pair, and any other behavior related to transactions which is likely to have leaked out into the rest of the system.
**'''Violations:'''  name unknown; something related to a class capturing behavior as well as holding data
+
**'''Violations:'''  [[Behavioral Completeness]]
 
* Replace Stock class with CompanyStock and OwnedStock.  These classes will not share a common super class as they differ greatly in what they represent.
 
* Replace Stock class with CompanyStock and OwnedStock.  These classes will not share a common super class as they differ greatly in what they represent.
 
**'''Violations:'''  [[Single responsibility principle]]
 
**'''Violations:'''  [[Single responsibility principle]]

Revision as of 01:13, 17 July 2009

Question 1

Possible improvements to the design:

  • Replace the Pair class with a Transaction class and two subclasses CreditTransaction and DebitTransaction. These classes will contain the information that was contained in Pair, and any other behavior related to transactions which is likely to have leaked out into the rest of the system.
  • Replace Stock class with CompanyStock and OwnedStock. These classes will not share a common super class as they differ greatly in what they represent.
  • Broker and StockHolder should both hold a reference to an Account object. This would replace the brokersAccount property of Broker. The Account class would manage Transactions and include a reference to the account holder (Broker or StockHolder).
  • Broker and StockHolder should both hold a reference to ContactDetails object. Alternatively they could both inherit from a Person class, but if we favor composition over inheritance this would seem the less preferred solution. This also wouldn't be a good solution if a Broker can be a company as well as a person. This would allow personal details of Brokers and StockHolders to be stored. In the current design the notion of a Person is mixed with that of an Account. The improved design separates these two and would allow someone to have multiple accounts.
Personal tools