Update 3
What do the signs (single line, diamond with star, and arrow) mean in graph (From Eric's ddd book p195) below:
Any code sample to illustrate would be appreciated.
Update 3
What do the signs (single line, diamond with star, and arrow) mean in graph (From Eric's ddd book p195) below:
Any code sample to illustrate would be appreciated.
The diamond is composition (also called aggregation), or a has-a
relationship. The arrow is inheritance, or an is-a
relationship. The line is an Association. That leads to the question: what's the difference between Composition and Association. And the answer is that composition is stronger and usually owns the other object. If the main object is destroyed, it will also destroy its composition objects, but not its association objects.
In your example, a Facility contains a (has-a) LoanInvestment and a LoanInvestment inherits from an (is-a) Investment
Here is an excellent description of class diagrams using UML.
Here's a code example in c++, I dont know c# well enough and Id probably mess it up :)
class Facility
{
public:
Facility() : loan_(NULL) {}
// Association, weaker than Composition, wont be destroyed with this class
void setLoan(Loan *loan) { loan_ = loan; }
private:
// Composition, owned by this class and will be destroyed with this class
// Defined like this, its a 1 to 1 relationship
LoanInvestment loanInvestment_;
// OR
// One of the following 2 definitions for a multiplicity relation
// The list is simpler, whereas the map would allow faster searches
//std::list<LoanInvestment> loanInvList_;
//std::map<LoanInvestment> loanInvMap_;
Loan *loan_:
// define attributes here: limit
};
class Loan
{
public:
// define attributes here: amount
// define methods here: increase(), decrease()
private:
// 1 to 1 relationship, could consider multiplicity with a list or map
LoanInvestment loanInvestment_;
};
class Investment
{
// define attributes here: investor, percentage
};
class LoanInvestment : public LoanInvestment
{
// define attributes here
};