Sie sind auf Seite 1von 22

CT015-3-2 Design Methods

Static Modelling
Learning objectives

• At the end of this lecture, you should be


able to :
– Describe static modelling
– Describe the elements in a class
diagram
– Describe the associations and
relationships possible in a class model
– Create a class diagram
CT015-3-2 Design Methods Static Modelling Slide 2 of 22
Static Modelling
• Describes static structure of the system being
modeled, which is considered less likely to
change than the functions of the system
• The UML class diagram notation is used to
depict static model
• In OO Analysis Modelling
– Define classes in system
– Defines attributes of classes
– Defines relationships between classes
• In OO Design Modelling
CT015-3-2 Design Methods
– Defines operations of each class
Static Modelling Slide 3 of 22
Object and Classes

• Objects represent “things” in real world


– Provide understanding of real world
– Form basis for a computer solution
• An Object (object instance) is a single
“thing”
– E.g., an account, an employee
• A Class (object class) is a collection of
objects with the same characteristics
– E.g., account, employee
CT015-3-2 Design Methods Static Modelling Slide 4 of 22
Example of code for object and
class
class Student //class
{
int id;
String name;

public static void main(String args[])


{
//creating an object of Student
Student s1=new Student();
System.out.println(s1.id);
System.out.println(s1.name);
}
}
CT015-3-2 Design Methods Static Modelling Slide 5 of 22
UML notation for objects &
classes

CT015-3-2 Design Methods Static Modelling Slide 6 of 22


Modeling with class diagrams

• Class diagrams are used to capture static


structure in:
– Conceptual modelling
– Detailed design modelling
– Implementation modelling

CT015-3-2 Design Methods Static Modelling Slide 7 of 22


Relationship on Class Diagram

• Relationships between classes


– Associations
– Composition / Aggregation
– Generalization / Specialization
• Other type of relationship
– Dependency
– Realization

CT015-3-2 Design Methods Static Modelling Slide 8 of 22


Relationship on Class Diagram

CT015-3-2 Design Methods Static Modelling Slide 9 of 22


Association

• Association is
– Static, structural relationship between classes
– E.g, Employee works in Department
• Navigability can be unidirectional or
bidirectional
• Multiplicity of Associations
– Specifies how many instances of one class may
relate to a single instance of another class

CT015-3-2 Design Methods Static Modelling Slide 10 of 22


Association

CT015-3-2 Design Methods Static Modelling Slide 11 of 22


Multiplicity of Association
• 1-to-1 association
– Company has President
• 1-to-many association
– Bank manages Account
• Numerically specified association
– Car has 2,4 Door
• Optional association (0 or 1)
– Customer owns Debit Card
• Optional association (0, 1, or many)
– Customer owns Credit Card
• Many-to-Many association
– Course has Student
– Student attends Course
CT015-3-2 Design Methods Static Modelling Slide 12 of 22
Aggregation

• Aggregation
– Part objects of aggregate object may be created
and deleted independently of aggregate
object.
– E.g., Aggregate class : College
– Part classes:
Admin Office IS PART OF College
Department IS PART OF College
Research Center IS PART OF College
• Navigability can be unidirectional or
bidirectional
CT015-3-2 Design Methods Static Modelling Slide 13 of 22
Aggregation

CT015-3-2 Design Methods Static Modelling Slide 14 of 22


Composition

• Whole and part objects are created, live, die


together
• A composition is a stronger relationship than
an aggregation
• Often also has a physical association
• Association between instances
– E.g., Composite class: ATM
– Part classes:
Keypad, CardReader, CashDispenser,
CT015-3-2 Design Methods
ReceiptPrinter Static Modelling Slide 15 of 22
Composition

CT015-3-2 Design Methods Static Modelling Slide 16 of 22


Generalization

• A generalization relationship is one in


which a class shares the structure and
behavior of one or more classes
• Subclass inherits a superclass
• Often described as an “is a” relationship
– E.g., Coupe is a Automobile
Sedan is a Automobile

CT015-3-2 Design Methods Static Modelling Slide 17 of 22


Generalization

CT015-3-2 Design Methods Static Modelling Slide 18 of 22


Dependency
• A dependency relationship describes a case
where one class uses another
• Dependencies may exist between classes
because:
– A message is sent from one class to the other
– One class is part of another's data
– One mentions the other as a parameter to an
operation

CT015-3-2 Design Methods Static Modelling ‹#› Slide 19 of 22


Realization

• A realization relationship describes a client


implementing a supplier's specification (an
interface)

CT015-3-2 Design Methods Static Modelling ‹#› Slide 20 of 22


Review

• What is the difference between


aggregation and composition?
• Which relationships can be bidirectional?

CT015-3-2 Design Methods Static Modelling ‹#› Slide 21 of 22


Q&A

CT015-3-2 Design Methods Static Modelling ‹#› Slide 22 of 22

Das könnte Ihnen auch gefallen