Quantcast
Viewing all articles
Browse latest Browse all 12

How to Make Class Diagrams using Composition

This tutorial is designed to show you how to make class diagrams using Composition. This provides you with a example problem statement and the solution to walk you through the process.

Problem Statement:

A company has a number of employees, company also has several projects that it needs to work on. Each employee may be assigned to one or more projects, or may not be assigned to a project at all. A project must have at least one employee assigned, and may have any number of employees assigned. An employee’s billing rate may vary by project and the company wishes to record the applicable billing rate for each employee when assigned to a particular project. At the end of each month, company mails a cheque to each employee who has worked on a project during that month. The cheque amount is based on billing rate and hours logged for each project assigned to the employee.

Before we move on to making class diagram for this particular problem, let’s discuss what is composition relation and how we use it. For example we have ClassA and ClassB these classes will have composition relationship if ClassA object is composed of one or more ClassB objects and further in composition relationship if a ClassA object dies then all ClassB objects that this particular ClassA object has will die automatically. For instance a building class can have many room class objects but when the building object dies all the room objects it contains must die too. Composition has a solid black diamond symbol.

To make a class diagram we first look for particular nouns, in our problem statement we have company, employee and project. We can say that company has employees and company has projects further if a company project dies then all associated employee objects will die as well, so here we can use…read more…

Image may be NSFW.
Clik here to view.
Geeksww_-_logo_-06

Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 12

Trending Articles