41
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 18

SOFTWARE DESIGN AND ARCHITECTURE LECTURE 18. Review User interface Design principles Design Guidelines

Embed Size (px)

Citation preview

SOFTWARE DESIGN AND ARCHITECTURE

LECTURE 18

Review

• User interface Design principles• Design Guidelines

Outline

• Basic Concepts of Object Oriented.• Modeling• UML and OO Modeling

Basic Concepts of Object Orientation

• Object • Class• Message• Basic Principles of Object Orientation• Abstraction• Encapsulation• Inheritance• Polymorphism• Interface and Abstract Class

• Informally, an object represents an entity, either physical, conceptual, or software.

– Physical entity

– Conceptual entity

– Software entity

What Is an Object?

Chemical Process

Linked List

A More Formal Definition

• An object is an entity with a well-defined boundary and identity that encapsulates state and behavior.– State is represented by attributes and

relationships.– Behavior is represented by operations,

methods, and state machines.

An Object Has State• The state of an object is one of the possible

conditions in which an object may exist.• The state of an object normally changes over

time.

An Object Has Behavior• Behavior determines how an object acts and reacts.• The visible behavior of an object is modeled by the set

of messages it can respond to (operations the object can perform).

An Object Has Identity• Each object has a unique identity, even if the state

is identical to that of another object.

Objects Need to Collaborate

• Objects are useless unless they can collaborate together to solve a problem.– Each object is responsible for its own behavior and

status.– No one object can carry out every responsibility

on its own.• How do objects interact with each other?

– They interact through messages.

What Is a Class?• A class is a description of a set of objects that share the

same properties and behavior. – An object is an instance of a class.

Professor

- name- employeeID : UniqueId- hireDate- status- discipline- maxLoad

+ submitFinalGrade()+ acceptCourseOffering()+ setMaxLoad()+ takeSabbatical()

A Sample Class

Data Items:– manufacturer’s name– model name– year made– color– number of doors– size of engine– etc.

Methods:– Define data items

(specify manufacturer’s name, model, year, etc.)

– Change a data item (color, engine, etc.)

– Display data items– Calculate cost– etc.

Class: Automobile

The Relationship Between 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

• Objects are grouped into classes.• An object is an instance of a class.

What Is an Attribute?• An attribute is a named property of a class that

describes a range of values instances of the property may hold.– A class may have any number of attributes or no attributes at

all.

Attributes

Student

- name- address- studentID- dateOfBirth

What Is an Operation?• An operation is the implementation of a service

that can be requested from any object of the class to affect behavior.

• A class may have any number of operations or none at all.

Operations

Student

+ get tuition()+ add schedule()+ get schedule()+ delete schedule()+ has pre-requisites()

What is a message?

• A specification of a communication between objects that conveys information with the expectation that activity will ensue– One object asks another object to perform an

operation.

• The OrderEntryForm wants Order to calculate the total dollar value for the order.

Example: Object Interaction

Basic Principles of Object Orientation

Object Orientation

Enca

psul

ation

Abst

racti

on

Poly

mor

phis

m

Inhe

ritan

ce

What Is Abstraction?

• Abstraction can be defined as:• Any model that includes the most important, essential, or

distinguishing aspects of something while suppressing or ignoring less important, immaterial, or diversionary details. The result of removing distinctions so as to emphasize commonalties. (Dictionary of Object Technology, Firesmith, Eykholt, 1995)

• Abstraction • Emphasizes relevant characteristics.• Suppresses other characteristics.

What Is Encapsulation?

• Encapsulation means to design, produce, and describe software so that it can be easily used without knowing the details of how it works.

• Also known as information hiding

• An analogy:• When you drive a car, you don’t have know the details

of how many cylinders the engine has or how the gasoline and air are mixed and ignited.

• Instead you only have to know how to use the controls.

What Is Inheritance ?

• Inheritance —a way of organizing classes • Term comes from inheritance of traits like eye

color, hair color, and so on.• Classes with properties in common can be

grouped so that their common properties are only defined once.

• Is an “is a kind of” relationship

An Inheritance HierarchyVehicle

Automobile Motorcycle Bus

Sedan Sports Car School Bus Luxury Bus

What properties does each vehicle inherit from the types of vehicles above it in the diagram?

Example: Single Inheritance• One class inherits from another.

CheckingSavings

Superclass (parent)

Subclasses

Inheritance Relationship

Ancestor

Descendents

Account

- balance- name- number

+ withdraw()+ createStatement()

Example: Multiple Inheritance

Use multiple inheritance only when needed and always with caution!

• A class can inherit from several other classes.

FlyingThing Animal

HorseWolfBirdHelicopterAirplane

Multiple Inheritance

Polymorphism

• Polymorphism—the same word or phrase can be mean different things in different contexts

• Analogy: in English, bank can mean side of a river or a place to put money

• In Java, two or more classes could each have a method called output

• Each output method would do the right thing for the class that it was in.

• One output might display a number whereas a different one might display a name.

Realization relationship

What is an Interface?• An interface is a collection of operations that specify a

service of a class or component.• Interfaces formalize polymorphism• Interfaces support “plug-and-play” architectures

Shape

draw()move()scale()rotate()

<<Interface>>Tube

Pyramid

Cube

‘What’

‘How’

What is an Abstract Class?

Abstract class

Abstract operation

Shape

{abstract}

draw () {abstract}

Circle

draw ()

Rectangle

draw ()

• An abstract class is a class that may not have any direct instances. • In the UML, you specify that a class is abstract by writing its name in

italics.• An abstract operation is an operation that it is incomplete and

requires a child to supply an implementation of the operation. • In the UML, you specify an abstract operation by writing its name in

italics.

INTRODUCTION TO UML

What is modeling?

•A model is a simplification of reality.•A model is an abstraction of things.• Emphasizes relevant characteristics.

– Suppresses other characteristics.

The Importance of Modeling

Paper Airplane F-16 Fighter Jet

Less Important More Important

Why Do We Model?• We build models to better understand the system we

are developing.• Modeling achieves four aims. Modeling

– Helps us to visualize a system as we want it to be.– Permits us to specify the structure or behavior of a system.– Gives us a template that guides us in constructing a system.– Documents the decisions we have made.

• We build models of complex systems because we cannot comprehend such a system in its entirety.

What Is the UML?• UML is an acronym for Unified Modeling Language• The UML is a language for

– Visualizing– Specifying– Constructing– Documenting

the artifacts of a software-intensive system.

UML: Object-Oriented & Visual Modeling

History of the UML

Web - June 1996

OOPSLA 95

PublicFeedback

OMG Acceptance, Nov 1997Final submission to OMG, Sept 1997First submission to OMG, Jan 1997

UML 1.0UML partners

UML 1.1

UML 1.4

UML 2.0

Planned minor revision (2000)

Planned major revision (2001)

UML 1.3Current minor revision 1999

OMG UML Specification

• UML Semantics• UML Notation Guide• UML Example Profiles• UML Model Interchange• Object Constraint Language Specification• UML Standard Elements• Glossary

Object Oriented Design using UML

• UML (Unified Modelling Language) is a standard notation to represent software design.

• Based on OO approaches.• Has syntax rules• Can be extended using stereotypes

Advantages of UML

• Specify, visualize, and document models of software systems– Current and new systems– Structure and design– Behavior and interaction

• De facto standard (Tool Support!)• Unambiguous and consistent notation• Documentation

UML Metamodel

Where can UML be used?

1. Business Model using Activity Diagram2. Requirements Capture using Use Case Diagram3. Requirements Analysis using Use Case Details and

Class Diagram4. Initial Design using Sequence Diagrams and second

version of Class Diagram5. Requirements Analysis using State Diagram6. Architecture Design using Packages and Subsystems7. Design using next level of details for Class Diagram

Where can UML be used?...

9. System Architecture using Deployment Diagram10. Design using Design Patterns11. Detailed design using Collaboration Diagram12. Consolidate all information into Class Diagram13. Detailed design using Component Diagram

Refine all models through iterations

Implement the models by translating into code

Deploy software within operational environment

UML Modelling

Use Case View

Logical View

Dynamic View

Implementation View

Deployment View

ud Manage Employees

AutoEdge System

Manager

(from Actors)

Browse Employees

Update Employee

Create Employee

Delete Employee

Create User«extend»

«include»

«use»

«use»

cd Users

Architecture Entities::User

- UserEmail: CHARACTER- UserLogin: CHARACTER- UserPassword: CHARACTER

Architecture Entities::UserGroups

- UserGroupDescription: CHARACTER- UserGroupName: CHARACTER

Business Entities::Employee

+ Address: CHARACTER+ City: CHARACTER+ email: CHARACTER- EmployeeLanguage: CHARACTER+ employmentEndDate: DATETIME-TZ+ employmentStartDate: DATE+ FirstName: CHARACTER+ LastName: CHARACTER+ MobilePhoneNumber: CHARACTER+ Notes: CHARACTER+ PhoneNumber: CHARACTER+ Position: CHARACTER+ PostCode: CHARACTER

+ createEmployee() : void+ deleteEmployee() : void+ findEmployee() : void+ isAvailable() : LOGICAL+ updateEmployee() : void+ validateEmployee() : void

Architecture Entities::Language

- Description: CHARACTER- Language: CHARACTER

0..*

1

11

0..* 1

sd Login

Client

(from Architecture Components)

Server Gateway

(from Architecture Components)

Security

(from Architecture Components)

Session Context

(from Architecture Components)

Request("Security", "Login", ...)

isValidUser(Login, password)

ValidUser

[if Valid User]: createSession

sessionID

[if valid user]: sessionID

id Business Entity (Client)

«Program»

proSIproxy.p

- NEW GLOBAL SHARED VARIABLE ghttProxySIproc: HANDLE

+ fetchWhere(CHARACTER, HANDLE, DATASET-HANDLE*) : void+ saveChanges(CHARACTER, HANDLE, CHARACTER*) : void

«Program»

ClientXxx.p

«Include»

proSIproxyStart.i

- NEW GLOBAL SHARED VARIABLE ghProxySIproc:

«Include»

dsXxx.i

- DEFINE DATASET <dataset-def>:

«Include»

etXxx.i

«include»

ttContext.i«includes»

includes

includes

«includes»

«realize PERSISTENT»

includes

dd Integration

HQ System

Sonic

Dealer System 1

Sonic

Dealer System 2

Sonic

Dealer System 3

Sonic

Dealer System n

Sonic

Summary

• Basic Concepts of Object Oriented.• Modeling• UML and OO Modeling