Beruflich Dokumente
Kultur Dokumente
ng them out of simple, smaller pieces that interact with each other.
Abstraction in the object oriented world generalizes the characteristics and behaviors of an item. Example: Automobile. Encapsulation conceals the functional details of an object from other objects, i.e., the object operates as a black box. Example: The functionality of brake is hidden.
Inheritance is a way to form new classes using classes that have already been defined. Inheritance is employed to help reuse of existing code with little or no modification. Example: Animal, Tiger. Inheritance Hierarchies: Inheritance can span multiple levels. A super class to a subclass can also be a subclass to another super class.
Multiple
Classes
Inheritance
can be derived from more than one super class. Example : Tank - can be a weapon and a vehicle.
Polymorphism
refers to the ability of executing different operations in response to the same message.
A Class diagramgives an overview of a system by showing its classes and the relationships among them. Class diagrams are static -- they display what interacts but not what happens when they do interact. UML class notation is a rectangle divided into three parts: class name, attributes, and operations. Names of abstract classes, such asPayment,are in italics. Relationships between classes are the connecting links.
Account
Account
- balance : double - limit : double
Account
- balance : double - limit : double + deposit (amount : double) : void + withdraw (amount : double) : void
[visibility] method_name ([[In |Out] parameter : type [ , more params ]]) [: return_type ]
Account
- balance : double + limit : double # id : int ~ databaseId : int + deposit (amount : double) : void - withdraw (amount : double) : void # getAvailableFunds() : double ~ getDatabaseId() : int
Person
- noOfPeople : int - name: String - Person(name : String) - createPerson(name : String) : Person + getName() : String + getNumberOfPeople() : int
Association (delegation) Aggregation & Composition Generalization (inheritance) Realization (interfaces) Dependency
Person
Lives at
Address
Role
Person
employer
Company
Association name
Association (delegation) Aggregation & Composition Generalization (inheritance) Realization (interfaces) Dependency
ASSOCIATION - MULTIPLICITY
A Student can take up to five Courses. Student has to be enrolled in at least one course. Up to 300 students can enroll in a course. A class should have at least 10 Student Course Takes 1..5 10 . . 300 students.
A teacher teaches 1 to 3 courses (subjects) Each course is taught by only one teacher. A student can take between 1 to 5 courses. A course can have 10 to 300 students.
Teacher
Teache s
1..3
Course
Student
00 0..3 1
s Take
1..5
Company can have many employees. An employee can only work for one company employee employer
Person
Works for
Company
John:Perso n James:Pers on
Works for
Microsoft : Company
or rks f Wo
Exactly one 1 Zero or one - 0..1 Many - 0..* or * One or more - 1..* Exact Number - e.g. 3..4 or 6 Or a complex relationship e.g. 0..1, 3..4,6..* would mean any number of objects other than 2 or 5
manag er
Employee
0.. 10
worker
Responsible for
Computer
Hardware Device
ShoppingBaske t
0..1
1..
OrderItem
Composition is composed of objects that cannot be shared or exchanged and live only as long as the composite object
Person
Employee
Person
OR
Employee
Employee
Rectan gle
Circle
Circle draw ()
Change in specification of one class can change the other class. This can happen when one class is using another class.
Circle move (p : Point ) Point
Dependency
Circle