Didik Dwi h t t p : / / b l o g. e l e k t r o. u m. a c. i d / d i d i k Object Oriented Software...
-
Upload
jonah-chapman -
Category
Documents
-
view
218 -
download
0
description
Transcript of Didik Dwi h t t p : / / b l o g. e l e k t r o. u m. a c. i d / d i d i k Object Oriented Software...
Didik [email protected]
h t t p : / / b l o g . e l e k t r o . u m . a c . i d / d i d i k
Object Oriented Software Engineering
2Didik Dwi - Teknik Elektro UM
Subbahasan
Paradigma Pengembangan PL Prinsip Dasar Orientasi Objek Konsep Dasar Orientasi Objek
3Didik Dwi - Teknik Elektro UM
Paradigma Pengembangan PL
Functional CompositionLogic ProgrammingStructured DevelopmentObject Orientation
4Didik Dwi - Teknik Elektro UM
Functional Composition
A problem is expressed in termed of a set of mathematical functions. e.g. Double(x) = Add(x, x).
An algorithm is not specified.Language such as Miranda, Gofer, Haskell
support this paradigm.Poor execution speed.
5Didik Dwi - Teknik Elektro UM
Logic Programming
Consists of a problem description only. e.g. Factorial(0) = 1. Factorial(N) = N x Factorial(N -1).
Doesn’t describe how to solve the problem.
Languages Prolog & Lisp support this paradigm.
6Didik Dwi - Teknik Elektro UM
Structured Development
Also called SASD, SADT & Functional Decomposition.
Breaks the system into processes & decomposes them.
Data independent from programLanguages C, Fortran, Pascal, Cobol,
Basic and a lot more support this paradigm.
By far the most popular paradigm.
7Didik Dwi - Teknik Elektro UM
Object Orientation
Most recent paradigm.Treats a problem as a collection of
objects.Becoming very popular now.More and more languages support this
paradigm now.
8Didik Dwi - Teknik Elektro UM
Paradigma Pengembangan PL Prinsip Dasar Orientasi Objek Konsep Dasar Orientasi Objek
9Didik Dwi - Teknik Elektro UM
Basic Principles of OO
Object Orientation
Enca
psul
atio
n
Abst
ract
ion
Hier
arch
y
Mod
ular
ity
10Didik Dwi - Teknik Elektro UM
What is abstraction?
Salesperson
Not saying Which salesperson – just a salesperson in general!!!
Customer Product
Manages Complexity
11Didik Dwi - Teknik Elektro UM
What is Encapsulation?
Hide implementation from clients Clients depend on interface
Improves Resiliency
How does an object encapsulate?What does it encapsulate?
12Didik Dwi - Teknik Elektro UM
What is Modularity?
The breaking up of something complex into manageable pieces
Order Processing System
Billing
OrderEntry
OrderFulfillment
Manages Complexity
13Didik Dwi - Teknik Elektro UM
What is Hierarchy?
Levels of abstraction
Decreasing abstraction
Increasing abstraction
Asset
RealEstate
Savings
BankAccount
Checking Stock
Security
Bond
Elements at the same level of the hierarchy should be at the same level
of abstraction
14Didik Dwi - Teknik Elektro UM
Hierarchy
chairtable desk "chable"
instances of chair
furniture (superclass)
subclasses of thefurniture superclass
15Didik Dwi - Teknik Elektro UM
The OO Mindset
problem domain
objects
16Didik Dwi - Teknik Elektro UM
Paradigma Pengembangan PL Prinsip Dasar Orientasi Objek Konsep Dasar Orientasi Objek
17Didik Dwi - Teknik Elektro UM
Basic Concepts of OO
• classes and class hierarchies– instances– inheritance– abstraction and hiding
• objects– attributes– Methods– polymorphism
• Messages• Component• Package• Subsystem• Relationships
18Didik Dwi - Teknik Elektro UM
Classes
• object-oriented thinking begins with the definition of a class often defined as:– template– pattern– “blueprint” ... describing a collection of similar
items
OO Principle: Abstraction
19Didik Dwi - Teknik Elektro UM
Representing Classes
A class is represented using a compartmented rectangle
Professor
Professor Clark
a + b = 10
20Didik Dwi - Teknik Elektro UM
Class Compartments
A class is comprised of three sections The first section contains the class name The second section shows the structure
(attributes) The third section shows the behavior (operations)
ProfessornameempID
create( )save( )delete( )change( )
Class Name
Attributes
Operations
21Didik Dwi - Teknik Elektro UM
Building a Class
class name
attributes:
operations:
attributes:
operations
22Didik Dwi - Teknik Elektro UM
Objects
An object is an instance of a classAn object is something that has:
State Behavior Identity
An object is a "black box" which receives and sends messages.
23Didik Dwi - Teknik Elektro UM
Classes and Objects
A class is an abstract definition of an object It defines the structure and behavior of each
object in the class It serves as a template for creating objects
24Didik Dwi - Teknik Elektro UM
Classes and Objects
Objects are grouped into classes
Objects Class
Professor Smith
Professor Jones
Professor Mellon
Professor
25Didik Dwi - Teknik Elektro UM
What is an Attribute?
26Didik Dwi - Teknik Elektro UM
Methods
A.k.a Operations, ServicesAn executable procedure that is
encapsulated in a class and is designed to operate on one or more data attributes
CourseOffering
addStudent deleteStudentgetStartTimegetEndTime
Class
Operation
27Didik Dwi - Teknik Elektro UM
What is Polymorphism
The ability to hide many different implementations behind a single interface
Manufacturer A Manufacturer B Manufacturer C
OO Principle:Encapsulation
28Didik Dwi - Teknik Elektro UM
Messages
sender object
attributes:
operations:
receiver object
attributes:
operations:
message: [receiver, operation, parameters]
message: [sender, return value(s)]
29Didik Dwi - Teknik Elektro UM
What is a Component?
A non-trivial, nearly independent, and replaceable part of a system
A component may be A source code component A run time components or An executable component
OO Principle: Encapsulation
<<DLL>>ComponentName
Component Interface
30Didik Dwi - Teknik Elektro UM
What is a Package?
A package is a general purpose mechanism for organizing elements into groups
A model element which can contain other model elements
Package Name
OO Principle:Modularity
31Didik Dwi - Teknik Elektro UM
What is a Subsystem?
A combination of a package (can contain other model elements) and a class (has behavior)
OO Principles: Encapsulation and Modularity
<<subsystem>>Subsystem Name
InterfaceInterface
RealizationSubsystem
32Didik Dwi - Teknik Elektro UM
Subsystems and Components
ComponentName
Design Model Implementation Model
<<subsystem>>Component Name
Component Interface
Component Interface
OO Principles: Encapsulation and Modularity
33Didik Dwi - Teknik Elektro UM
Relationships
Association Aggregation Composition
DependencyGeneralizationRealization
34Didik Dwi - Teknik Elektro UM
Relationships: Association
Models a semantic connection among classes
Professor UniversityWorks for
Class
Association
Association Name
Professor UniversityEmployerEmployee
Role Names
35Didik Dwi - Teknik Elektro UM
Relationships: Aggregation
A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts
Hubungan keseluruhan sebagian (wholepart)
Merepresentasikan hubungan “has a/an”
36Didik Dwi - Teknik Elektro UM
Relationships: Aggregation
Contoh:
Car Body
Whole
Aggregation
Part
37Didik Dwi - Teknik Elektro UM
Relationships: Composition
A form of aggregation with strong ownership and coincident lifetimes The parts cannot survive the whole/aggregate
Book Chapter
Whole
Aggregation
Part
38Didik Dwi - Teknik Elektro UM
Multiplicity and Navigation
Multiplicity defines how many objects participate in a relationships
Associations and aggregations are bi-directional by default, but it is often desirable to restrict navigation to one direction
One direction
Bi-direction
39Didik Dwi - Teknik Elektro UM
Association: Multiplicity
UnspecifiedExactly oneZero or more (many, unlimited)
One or moreZero or oneSpecified rangeMultiple, disjoint ranges
2..4
0..1
1..*
0..*
1
*
2, 4..6
40Didik Dwi - Teknik Elektro UM
Multiplicity and Navigation
Example
Student Schedule1 0..*
Multiplicity
Navigation
41Didik Dwi - Teknik Elektro UM
Relationships: Dependency
A relationship between two model elements where a change in one may cause a change in the other
Merepresentasikan hubungan “using”
Client Supplier
Package
ClientPackage SupplierPackage
Client
Class
Dependency relationship
42Didik Dwi - Teknik Elektro UM
Relationships: Generalization
Defines a hierarchy of abstractions in which a subclass inherits from one or more superclasses Single inheritance Multiple inheritance
Merepresentasikan hubungan “is-a-kind of”
43Didik Dwi - Teknik Elektro UM
Relationships: Generalization
One class inherits from another
Accountbalancenamenumber
Withdraw()CreateStatement()
Checking
Withdraw()
Savings
GetInterest()Withdraw()
Superclass (parent)
Subclasses
Generalization Relationship
Ancestor
Descendents
44Didik Dwi - Teknik Elektro UM
Example: Multiple Inheritance
A class can inherit from several other classes
Airplane Helicopter Wolf Horse
FlyingThing Animal
Bird
multipleinheritance
45Didik Dwi - Teknik Elektro UM
Relationships: Realization
One classifier serves as the contract that the other classifier agrees to carry out
Component
Interface
Use Case Use-Case Realization
Elided form
Class
InterfaceSubsystem
Interface
Canonical form
46Didik Dwi - Teknik Elektro UM
Tools for OO
Rumbaugh (OMT)Coad-YourdonBoochUML
47Didik Dwi - Teknik Elektro UM
Strengths of Object Orientation
Facilitates architectural and code reuseModels more closely reflect the real world
More accurately describe corporate data and processes
Decomposed based on natural partitioning Easier to understand and maintain
Stability A small change in requirements does not mean
massive changes in the system under development
48Didik Dwi - Teknik Elektro UM
Conclusion
Paradigma pengembangan PL: Fungsional, Logic, Structured, dan OO
Prinsip dasar orientasi objek: Abstraksi, enkapsulasi, modularity, dan
hierarkiKonsep dasar orientasi objek:
Kelas dan Objek Messages, Component, Package, Subsystem Relationships