Topic : Object Oriented Design Principles - comp.utm.my · Topic : Object Oriented Design...
Transcript of Topic : Object Oriented Design Principles - comp.utm.my · Topic : Object Oriented Design...
Topic : Object Oriented Design Principles
Software Engineering Faculty of Computing
Universiti Teknologi Malaysia
2 Object-Oriented Analysis and Design with the Unified
Process
Objectives
• Describe the differences between requirements activities and design activities
• Explain the purpose of design and the difference between architectural and detailed design activities
• Describe 4 architectural styles
• Describe detailed design activities
3 Object-Oriented Analysis and Design with the Unified
Process
Comparison of Modeling During the Business Modeling, Requirements, and Design Disciplines
Recap on SDLC Phases & Artefacts
2016 Software Engineering 4
Domain Analysis @ Business Process
Requirement
Analysis
Design
Implementation
Testing & Deployment
Maintenance & Evolution
Domain Model (Class Diagram)
1) Functional & Non-Functional requirement 2) Use Case diagram
1) System Sequence Diagram 2) Activity Diagram
1) Class Diagram (refined) 2) Detail Sequence Diagram 3) State Diagram
1) Application Source Code 2) User Manual Documentation
1) Test Cases 2) Prototype
1) Change Request Form
SRS
4
5
UML Diagrams
6 Object-Oriented Analysis and Design with the Unified
Process
Understanding the Elements of Design
• Systems design discipline
– Describe, organize, and structure system components
– Artifacts at architectural level and detailed level
– Purpose: enable system construction and deployment
• Two tiers of discipline tasks
– High (architectural)
• Hardware and system software infrastructure
– Low(detail design)
• Small modules such as software design for a use case
Definitions
• Architectural design :
– The design process for identifying the sub-systems making up a system and the framework for sub-system control and communication.
• The output of this design process is a description of the software architecture.
2016 Software Engineering 10
Recap on Design Process (Ch.2)
2016 Software Engineering 11
Recap on Design Process (Ch.2)
2016 Software Engineering 12
Design software architecture (high level design)
Client server architecture Layered architecture Repository architecture Model View Controller (MVC)
13 Object-Oriented Analysis and Design with the Unified Process
Architectural Design
• An early stage of the system design process.
• Represents the link between specification and design processes.
• Often carried out in parallel with some specification activities.
• It involves identifying major system components and their communications.
2016 Software Engineering 14
Architecture Analogy for Software vs. House?
2016 Software Engineering 15
2016 Software Engineering 16
Architecture Style
Client Server Repository Layered MVC
17 Object-Oriented Analysis and Design with the Unified
Process
Client/Server Architecture
• Client/server architecture tiers
– Client: requests resources or services from a server
– Server: manages information system resources
• Architectural issues for client/server software:
– Decomposing software into client and server programs (objects)
– Determining where clients and servers will execute
– Describing interconnection protocols and networks
Client-Server Architecture
• Distributed system model which shows how data and processing is distributed across a range of components. – Can be implemented on a single computer. – Set of stand-alone servers which provide specific
services such as printing, data management, etc. – Set of clients which call on these services. – Network which allows clients to access servers.
• Used when data in a shared database has to be accessed from a range of locations.
2016 Software Engineering 18
19 Object-Oriented Analysis and Design with the Unified
Process
Client/Server Architecture with a Shared Database
Client/Server Architecture
20 Object-Oriented Analysis and Design with the Unified
Process
Client/Server Architecture (continued)
• Client and server communicate via well-defined protocols over a physical network
• Client/server architecture advantages
– Location flexibility, scalability, maintainability
• Client/server architecture disadvantages
– Additional complexity, potential poor performance, security issues, and reliability
Pros and Cons
2016 Software Engineering 21
Advantages Disadvantages
•Servers can be distributed across a network.
•Each service is a single point of failure so susceptible to denial of service attacks or server failure.
•General functionality (e.g. a printing service) can be available to all clients and does not need to be implemented by all services.
•Performance may be unpredictable because it depends on the network as well as the system.
22 Object-Oriented Analysis and Design with the Unified
Process
Interaction Among Multiple Clients and a Single Server
Repository Architecture
• Sub-systems must exchange data. This may be done in two ways: – Shared data is held in a central database or repository
and may be accessed by all sub-systems; – Each sub-system maintains its own database and
passes data explicitly to other sub-systems. • When to use:
– large amounts of data are to be shared and stored for a long time.
– in data-driven systems where the inclusion of data in the repository triggers an action or tool
2016 Software Engineering 23
Pros and Cons
2016 Software Engineering 24
Advantages Disadvantages
•Components can be independent. •Changes made by one component can be propagated to all components. • All data can be managed consistently (e.g. backups done at the same time)
•Problems in the repository affect the whole system. •Inefficiencies in organizing all communication through the repository. • Difficulties in distributing the repository across several computers
A Repository Architecture for an IDE
2016 Software Engineering 25
26 Object-Oriented Analysis and Design with the Unified
Process
Layered Architecture
• Variant of client/server architecture – Divides application software into independent
processes
• Three-layers – The data layer – The business logic layer – The view (presentation) layer
• Three-tier architecture advantages – Additional flexibility and reliability
Layered Model
• Used when:
– building new facilities on top of existing systems
– the development is spread across several teams with each team responsibility for a layer of functionality
– there is a requirement for multi-level security
– security is a critical requirement
• Example: Layered security architecture, a system to provide file security
2016 Software Engineering 27
Pros and Cons
• Advantages: • Each layer can be considered to be an increasing level
of abstraction • Designers can use the layers to decompose a problem
into a sequence of more abstract steps • It’s easy to add or modify a layer as the need arises
• Disadvantages: • Not easy to structure a system in layers • The multiple layers of abstraction are not always
evident when examine a set of requirements • System performance may suffer from the extra
coordination among the layers
2016 Software Engineering 28
29 Object-Oriented Analysis and Design with the Unified
Process
Three-layer Architecture
A Client-Server Architecture for a Film Library
2016 Software Engineering 30
The Architecture of the LIBSYS System
2016 Software Engineering 31
5. The Model-View-Controller (MVC) pattern
• Used when there are multiple ways to view and interact with data.
• Also used when the future requirements for interaction and presentation of data are unknown.
Web application architecture using the MVC pattern
33 Chapter 6 Architectural design
MVC architecture for online ordering system
Pros and Cons
2016 Software Engineering 35
Advantages Disadvantages
• Allows the data to change independently of its representation and vice versa.
• Supports presentation of the same data in different ways with changes made in one representation shown in all of them.
•Can involve additional code and code complexity when the data model and interactions are simple.
COMPONENT DIAGRAMS AND ARCHITECTURAL DESIGN
2016 Software Engineering 36
37 Object-Oriented Analysis and Design with the Unified Process
Object oriented component notation
2016 Software Engineering 38
Extension notation for windows and web page
2016 Software Engineering 39
Two-Layer Architectural Design of Internet Systems
2016 Software Engineering 40
Three-Layer Architectural Design of Internet Systems
Principles of object oriented detailed design(low level design)
• Design class diagram
• Design class symbol
• Fundamental detailed design principles
• Encapsulation
• Object reuse
• Information hiding
• Navigation visibility
• Coupling
• Cohesion
• Separation of resposibility
Object-Oriented Analysis and Design with the Unified Process 41
DESIGN CLASS DIAGRAM
2016 Software Engineering 42
Design class diagram
2016 Software Engineering 43
Systems Analysis and Design in a Changing World, 6th Edition 44
Notation for Design Classes method arguments and return types not shown
45 Object-Oriented Analysis and Design and the Unified Process
Java Program vs Class Diagram
DESIGN CLASS SYMBOL
2016 Software Engineering 46
47 Object-Oriented Analysis and Design and the Unified Process
Design Class Symbols
• Stereotypes
– UML notation to categorize a model element as a certain type
• Two types of notation
– Full notation with guillemets («»)
– Shorthand notation with circular icons
• Standard stereotypes
– Entity, control, boundary, data access
48 Object-Oriented Analysis and Design and the Unified Process
Standard stereotypes found in design models
Full notation
Shorthand notation
2016 Software Engineering 49
Reference from Center of Advanced Software Engineering (CASE)
Boundary Class
Example – Boundary Class
2016 Software Engineering 50
Reference from Center of Advanced Software Engineering (CASE)
Entity Class
2016 Software Engineering 51
Reference from Center of Advanced Software Engineering (CASE)
Example – Entity Class
2016 Software Engineering 52
Reference from Center of Advanced Software Engineering (CASE)
Control class
2016 Software Engineering 53
Reference from Center of Advanced Software Engineering (CASE)
Example control class
2016 Software Engineering 54
Reference from Center of Advanced Software Engineering (CASE)
55 Object-Oriented Analysis and Design and the Unified Process
Design Class Notation
• Class name and stereotype information
• Attribute information – Visibility, type-expression, name, initial value, and
properties
• Method signature – Visibility, name, type-expression, and parameter
list
– Use the entire signature to identify a method to distinguish between overloaded methods
56 Object-Oriented Analysis and Design and the Unified Process
Internal Symbols and Example
Systems Analysis and Design in a Changing World, 6th Edition 57
Navigation Visibility
– The ability of one object to view and interact with another object
– Accomplished by adding an object reference variable to a class.
– Shown as an arrow head on the association line—customer can find and interact with sale because it has mySale reference variable
Systems Analysis and Design in a Changing World, 6th Edition 58
Navigation Visibility Guidelines
• One-to-many associations that indicate a superior/subordinate relationship are usually navigated from the superior to the subordinate
• Mandatory associations (whole-part), in which objects in one class can’t exist without objects of another class, are usually navigated from the more independent class to the dependent
• When an object needs information from another object, a navigation arrow might be required
• Navigation arrows may be bidirectional.
Systems Analysis and Design in a Changing World, 6th Edition 59
First Cut Design Class Diagram – step
• Proceed use case by use case, adding to the diagram
• Pick the domain classes that are involved in the use case (see preconditions and post conditions for ideas)
• Add a controller class to be in charge of the use case
• Determine the initial navigation visibility requirements using the guidelines and add to diagram
• Elaborate the attributes of each class with visibility and type
• Note that often the associations and multiplicity are removed from the design class diagram as in text to emphasize navigation, but they are often left on
Systems Analysis and Design in a Changing World, 6th Edition 60
Start with Domain
Class Diagram
RMO Sales Subsystem
Systems Analysis and Design in a Changing World, 6th Edition 61
Create First Cut Design
Class Diagram
Use Case Create phone sale with controller added
Systems Analysis and Design in a Changing World, 6th Edition 63
Final DCD for the
Process new order use case
- added methods
Principles of object oriented detailed design(low level design)
• Design class diagram
• Design class symbol
• Fundamental detailed design principles
• Encapsulation
• Object reuse
• Information hiding
• Navigation visibility
• Coupling
• Cohesion
• Separation of resposibility
Object-Oriented Analysis and Design with the Unified Process 64
FUNDAMENTAL DETAILED DESIGN PRINCIPLES
2016 Software Engineering 65
66 Object-Oriented Analysis and Design and the Unified Process
Some Fundamental Design Principles
• Encapsulation – Each object is a self-contained unit containing
both data and program logic
• Object reuse – Standard objects can be used over and over
again within a system
• Information hiding – Data associated with an object is not visible
– Methods provide access to data
67 Object-Oriented Analysis and Design and the Unified Process
Some Fundamental Design Principles (continued)
• Navigation visibility – Describes which objects can interact with each other
• Coupling – Measures how closely classes are linked. – Objects which send messages to one another have navigation
visibility and thus are coupled. – Lower navigation visibility – lower coupling
• Cohesion – Measures the consistency of functions in a class – Cohesion is where the Classes perform one specific function – Classes which perform too much functions (low cohesion) hard to
be reused; difficult to understand and hard to maintain. • Separation of responsibilities
– Divides a class into several highly cohesive classes
EXTRA SLIDES ON COHESION AND COUPLING
2016 Software Engineering 68
Cohesion
69
Coupling
70
Cohesion and Coupling
71
Key Points
• A software architecture is a high level design to describe of how a software system is organized.
• Architectural style are a means of reusing knowledge about generic system architectures. They describe the architecture, explain when it may be used and describe its advantages and disadvantages.
• Model involved in software architecture is component diagram.
• Object oriented detailed design is a low level design where the identification and description of sets of objects that must work together to carry put each use case is done.
• Models involved in detailed design are class diagram and sequence diagram (will be elaborated in object oriented design use case realizations lecture)
2016 Software Engineering 72
Key Points
• Models of application systems architectures help us understand and compare applications, validate application system designs and assess large-scale components for reuse.
• Transaction processing systems are interactive systems that allow information in a database to be remotely accessed and modified by a number of users.
• Language processing systems are used to translate texts from one language into another and to carry out the instructions specified in the input language. They include a translator and an abstract machine that executes the generated language.
2016 Software Engineering 73