Professional Documents
Culture Documents
Week 4
January 28, 2021
Announcements
February 4, 2021
6 PM – 9 PM
▪ Must mark a class as abstract even with only one abstract method.
▪ If a class extends an abstract class, it must implement all the abstract methods.
• (Top Code Example)
▪ You cannot mark a method with both abstract and final keywords. Why?
• Following this design, the compiler knows about the parent class first
and can point out any compilation errors in the parent class.
▪Note:
• An interface can extend multiple interfaces.
• A class cannot extend from multiple parent classes,
• A class can implement multiple interfaces.
1
▪ You can use abstract before interface method (Optional) (Snippet 1)
• Interfaces by default are abstract.
▪Encapsulation vs Abstraction
• Abstraction is more about ‘What‘ a class can do. [Idea]
• Encapsulation is more about ‘How‘ to achieve that functionality. [Implementation]
Object-oriented Software Development – SE 450 – Winter 2021
16
Object-oriented Programming Principles
An overview of 4 pillars of OOP
Software 03
Maintenance
Development
Design
06 Life Cycle
(SDLC)
Testing &
Integration 04
Implementation
05
Object-oriented Software Development – SE 450 – Winter 2021
23
Types of documentation
▪UML 1.0
• 1997
• HP, IBM, Microsoft, Oracle, …
▪UML 2.5
• Current version
• Version History
• Complete References & Examples
• Behavioral things
• State Machine, Activity Diagram, Interaction Diagram
• Grouping things
• Package
• Annotational things
• Note
• Relationships
• Dependency, Association, Generalization, Realization
• Diagrams
• Structural Diagram
• Behavioral Diagram
• Interaction Diagram
Behavioral Diagrams
• Use Case Diagram
• Activity Diagram
• State Machine Diagram
• Interaction Diagrams
• Interaction Overview Diagram
• Sequence Diagram
• Communication Diagram
Object-oriented Software Development – SE 450 – Winter 2021
• Timing Diagram
30
UML Class Diagram
▪What is UML Class Diagram?
• static view of an application | types of objects |
relationships between them
▪Purpose?
• analyses and designs | responsibilities | base for
other diagrams | forward and reverse eng.
▪Benefits?
• complex systems | reduces the maintenance time |
better understanding | desired code | helpful for the
stakeholders
General Java C++
▪Components
• Upper Section Name Name Name
Class Diagram Example: Order System
• Middle Section State Variable Members
Source: visual-paradigm.com
• Lower Section
Behavior Methods Functions
• Generalization Multiplicity
• “Is-a-kind-of”, “is-a”
• Association Composition
• “Has-a”
• Aggregation
• “Has-a”, “is part of”
• Composition
• has-a”, “part of”, “belongs-to” Generalization
▪Generalization
• Denotes inheritance between classes
• “is a” relationship
• Solid line with open (triangular) arrowhead
Example: Laptop, Desktop, PDA inherit state & behavior from Computers
▪Generalization vs Specialization
▪Generalization vs Inheritance
▪Realization/Implementation A «B»
• Denotes class implements Java interface
• Dotted line with open (triangular) arrowhead
A implements interface B
▪Association
• permanent, structural relationship
• State of class A contains class B
Car and Engine classes know about each other
• Represented by solid line (arrowhead optional)
▪Navigation
• Represented by solid line with arrowhead
• Denotes “has-a” relationship between classes
• Example:
• “Gas Pedal” has an “Engine”
Gas Pedal class knows about Engine class
• State of Gas Pedal class contains instance of Engine class and can
Engine class doesn’t know about Gas Pedal class
invoke its methods
▪Notation
• Bank has many ATMs, ATM knows only 1 bank
•* => 0, 1, or more
▪One-to-many
•7 => exactly 7
• 3..8 => between 3 and 8, inclusive
• 2..* => 2 or more
Example: A house has exactly one kitchen, exactly one
bath, at least one bedroom (can have many), exactly
• Inventory has many items, items know 1 inventory one mailbox, and at most one mortgage (zero or one).
▪Composition
• “has-a”, “part of”, “belongs-to”
• Stricter form of aggregation
• Two classes are mutually dependent
• Cannot exist without each other / life span are same a class Car cannot exist without Engine,
it won't be functional anymore
• Illustrate composition with a filled diamond
• The diamond end points toward the "whole" class
Aggregation is denoted by a straight line with one end of The composition is denoted by a straight line with a full
Definition
the null-diamonded arrow mark. diamonded arrow mark at one end.
Dependency It explains the section of the association relationship. It explains the section of the aggregation relationship.
Type of Relationship The relationship established is very delicate. The relationship established is definitely strong.
In aggregation, the related objects are present In composition, the related objects are nor present within the
Associate Objects
independently within the entire system. entire system.
The linked objects present in the system are independent The linked objects present in the system are dependent on other
Linked Objects
to other objects. objects.
Deletion of one element in the aggregation doesn’t impact The deletion of one object impacts the presence of the other
Deletion of Objects
the other components present in the associative section. related objects in the compression.
For the proper functioning of a car, the wheel is a If an image is placed in a document and that document gets
mandatory element. But it doesn’t require the same wheel deleted, the image cannot be found again or used. The image
Examples
for the operation of the car. Even other wheels can be residing in the document also gets deleted at the same time at
substituted. the time of document deletion.
Representation
▪Dependency (references)
▪Association (has-a)
▪Connections
• Shown as arrows
• Show direction
▪<<interface>> NameOfTheInterface
▪ Desktop
• Your IDE (https://www.jetbrains.com/help/idea/class-diagram.html)
• Code Iris Plugin
• Sketch It Plugin
• PlantUML Plugin
• Modelio
• StarUML
• ArgoUML
• Umbrello UML Modeller
• Acceleo
• UMLdesigner
• PlantUML
▪ Online
• yuml.me
• GenMyModel
• visual-paradigm
• MS Visio
• Creately
• Draw.io
Object-oriented Software Development – SE 450 – Winter 2021
74
UML Cheat Sheets