Dynamic View Services > View and Notification Services > Presenting the Company Example > The Object Model
 
The Object Model
In our example, the object model includes companies that take part in projects. A company is composed of several departments, each employing a number of people who contribute to the projects. Each department has a manager. A manager is a specific kind of employee. Employees, employee contributions and projects have a cost, which is calculated as follows:
*Cost of an employee = monthly salary of the employee x the number of months spent on all projects
*Cost of a contribution = monthly salary of the employee x the number of months spent on the contribution
*Cost of a project = sum of the contribution costs
The object model can be coded as follows:
class Company: public IlsEntity
{
public:
IlsUsesList<Company,Project> projects;
IlsOwnsList<Company,Department> departments;
};
 
class Department: public IlsObject
{
public:
IlsEntry<IlsString> name;
IlsOwnsList<Department,Employee> employees;
IlsUses<Departement,Manager> manager;
IlsInvertedRelation<Department,Company> company;
};
 
 
class Employee: public IlsObject
{
public:
IlsEntry<IlsString> name;
IlsEntry<int> monthCost;
IlsDerived<Employee,int,NbMonthsEvaluator> nbMonths;
IlsDerived<Employee,int,CostEvaluator> cost;
IlsInvertedRelation<Employee,Department> department;
IlsInvertedRelationList<Employee,Contribution> contributions;
};
class Manager: public Employee
{
};
 
class Project: public IlsEntity
{
public:
IlsOwnsList<Project,Contribution> contributions;
IlsInvertedRelationList<Project,Company> companies;
IlsDerived<Project,int,CostEvaluator> cost;
};
 
class Contribution: public IlsObject
{
public:
IlsUses<Contribution,Employee> employee;
IlsInvertedRelation<Contribution,Project> project;
IlsEntry<int> nbMonths;
IlsDerived<Contribution,int,CostEvaluator> cost;
};
Figure 7.1 shows the class diagram of this object model.
Figure 7.1    The Company Object Model in IBM Rational Rose Modeler
Figure 7.2 illustrates an instance of the model.
Figure 7.2    An Instance of the Company Object Model

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.