Open rain1024 opened 10 years ago
public class Customer {
private String name;
private String address;
private String contactNumber;
}
public class Car {
private String modelNumber;
private Customer owner;
}
Paterns: <Chain of responsibility>
This shows “has a” relationship. It is a form of association relationship. This relationship highlights that a whole is made of its parts. So if a whole is destroyed the part still remains. In UML this is represented through a hollow diamond with the diamond symbol pointing towards the whole. In case of Java the aggregation follows the same structure as association. It is represented through the instance variables of a class.
public class Student {
}
public class School {
private Student student;
}
This is again a whole or part relationship where if the whole is destroyed then the part cannot exist independently. Another important point about Composition is that the part at any point in time can have only one owner. E.g. A person can be an employee of one company at any point in time due to contractual obligations. That person cannot hold dual work authorisation. If the Company goes bankrupt the employee of this company does not exist and will be fired. The composition is represented as a filled diamond with data flowing in single direction from the whole to the part. The composition in Java is represented in the same form as aggregation with help of instance variables.
public class Employee {
}
public class Company {
private Employee[] employee;
}
Association | Aggregation | Composition | |
---|---|---|---|
Definition | is a relationship where all objects have their own lifecycle and there is no owner. |
is a specialised form of Association where all objects have their own lifecycle but there is ownership and child objects can not belong to another parent object. |
is again specialised form of Aggregation and we can call this as a “death” relationship. It is a strong type of Aggregation. Child object does not have it's lifecycle and if parent object is deleted all child objects will also be deleted. |
Example |
Teacher and Student. Multiple students can associate with single teacher and single student can associate with multiple teachers but there is no ownership between the objects and both have their own lifecycle. Both can create and delete independently. |
Department and teacher. A single teacher can not belong to multiple departments, but if we delete the department teacher object will not be destroyed. We can think about it as a “has-a” relationship. |
House and rooms. House can contain multiple rooms there is no independent life of room and any room can not belong to two different houses. If we delete the house - room will automatically be deleted. Let’s take another example relationship between Questions and options. Single questions can have multiple options and option can not belong to multiple questions. If we delete questions options will automatically be deleted. |
allow designers to extend the vocabulary of UML in order to create new model elements, derived from existing ones, but that have specific properties that are suitable for a particular problem domain or otherwise specialized usage
<Entities>
, <Boundaries>
, <Controls>
Entities (model) Objects representing system data, often from the domain model.
Boundaries (view) Objects that interface with system actors (e.g. a user or external service). Windows, screens and menus are examples of boundaries that interface with users.
Controls (controller) Objects that mediate between boundaries and entities. These serve as the glue between boundary elements and entity elements, implementing the logic required to manage the various elements and their interactions. It is important to understand that you may decide to implement controllers within your design as something other than objects – many controllers are simple enough to be implemented as a method of an entity or boundary class for example.
<Worker>
, <Internal Worker>
, <Case Worker>
Worker
A Worker
is a class that represents an abstraction of a human
that acts within the
system. A worker
interacts with other workers
and manipulates entities
while
participating in use case realizations.
Case Worker
A Case Worker
is a worker who interacts directly with actors
outside the system
Internal Worker
An Internal Worker
is a worker that interacts with other workers
and entities
inside the
system.
Entity
An Entity
is a class that is passive; that is, it does not initiate interactions on its own.
An entity object
may participate in many different use case realizations and usually
outlives any single interaction.
In business modeling, entities
represent objects that workers
access, inspect, manipulate, produce, and so on. Entity
objects provide the basis for sharing among workers
participating in different use case realizations.
Usecase