1. Trang chủ
  2. » Giáo Dục - Đào Tạo

OO basics (THIẾT kế đối TƯỢNG SLIDE)

37 13 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Slide 1

  • Introduction to Object Orientation Topics

  • Overview

  • OOA, OOD, and OOP

  • Basic Definitions OOD, and OOP

  • Object-Oriented Approach

  • Five Basic Characteristics of OO

  • Basic Principles of Object Orientation

  • What Is Abstraction?

  • What Is Encapsulation?

  • Encapsulation

  • What Is Polymorphism?

  • Polymorphism

  • What is Hierarchy?

  • Basic Concepts of Object Orientation

  • What is an Object?

  • A More Formal Definition

  • What is a Class?

  • Sample Class

  • Representing Classes in the UML

  • Classes of Objects

  • Classes and Objects Relationship

  • What Is an Attribute?

  • What Is an Operation?

  • What is an Interface?

  • Interface

  • What is a Package?

  • Relationships

  • Relationships: Association

  • Relationships: Association Aggregation

  • Association: Multiplicity and Navigation

  • Relationships: Dependency

  • Relationships: Realization

  • Inheritance

  • Polymorphism

  • What Gets Inherited?

  • Example: What Gets Inherited

Nội dung

OO Basics Introduction to Object Orientation Topics • • • • Overview Basic Principles of Object Orientation Basic Concepts of Object Orientation Strengths of Object Orientation Overview • What are object-oriented (OO) methods? – OO methods provide a set of techniques for analyzing, decomposing, and modularizing software system architectures – In general, OO methods are characterized by structuring the system architecture on the basis of its objects (and classes of objects) rather than the actions it performs • What are the benefits of OO? – OO enhances key software quality factors of a system and its constituent components OOA, OOD, and OOP • Object-oriented methods may be applied to different phases in the software lifecycle – e.g., analysis, design, implementation, etc • Object-oriented analysis (OOA) is a process of discovery – models and understands the requirements of the system • Object-oriented design (OOD) is a process of invention and adaptation – creates the abstractions and mechanisms necessary to meet the system's behavioral requirements determined during analysis Basic Definitions OOD, and OOP • Object-Oriented Design (OOD) – A method for decomposing software architectures based on the objects every system or subsystem manipulates – Rather than "the" function it is meant to ensure • Object-Oriented Programming (OOP) – construction of software systems using object oriented concepts as inheritance, polymorphism, encapsulation, dynamic binding • Distinguish between OOD and OOP – OOD is relatively independent of the programming language used – OOP is primarily concerned with programming language and software implementation issues Object-Oriented Approach • Model objects that are part of the problem • Have objects exhibit their normal behavior • Add objects that not have problem-space analogs • Have the objects work together to create a solution Design patterns help you identify less-obvious abstractions and the objects that can capture them - GOF Five Basic Characteristics of OO "Pure" object-orientation by Alan Kay (Smalltalk): • Everything is an object • A program is a bunch of objects telling each other what to by sending messages • Each object has its own memory made up of other objects • Every object has a type • All objects of a particular type can receive the same message Basic Principles of Object Orientation Hierarchy Polymorphism Encapsulation Abstraction Object Orientation What Is Abstraction? • The essential characteristics of an entity that distinguishes it from all other kinds of entities • Defines a boundary relative to the perspective of the viewer • Is not a concrete manifestation, denotes the ideal essence of something Manages Complexity Customer Salesperson: Not saying Which salesperson – just a salesperson in general!!! Product What Is Encapsulation? • Hides implementation from clients – Clients depend on interface Improves Resiliency 10 What Is an Attribute? • An attribute is a named property of a class that describes the range of values that 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 23 What Is an Operation? • A service that can be requested from an object to effect behavior An operation has a signature, which may restrict the actual parameters that are possible • A class may have any number of operations or none at all Student Operations + get tuition() + add schedule() + get schedule() + delete schedule() + has prerequisites() 24 What is an Interface? • Interfaces formalize polymorphism • Interfaces support “plug-and-play” architectures Tube Shape Pyramid Draw Move Scale Rotate Cube Realization relationship (stay tuned for realization relationships) 25 Interface • How you get an object to useful work for you? • Objects are known only through their interfaces • Every object presents an interface to the world • Interface determines what you can get an object to • Represent a "contract" with other objects • Communicate with objects by sending messages to them; an object’s interface is the set of messages an object will respond to 26 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 • Uses – Organize the model under development – A unit of configuration managemen 27 Relationships • Association – Aggregation • Dependency • Inheritance • Realization generalization Window open() close() move() display() handleEvent() ConsoleWindow Event association DialogBox Control 28 Relationships: Association • Models a semantic connection among classes Association Name Professor Works for University Association Class 29 Relationships: Association Aggregation Company * Department • To model a “whole/part” relationship, use aggregation • Aggregation represents a “has-a” or “is a part-of” relationship, meaning that an object of the whole has objects of the part 30 Association: Multiplicity and Navigation • Multiplicity defines how many objects participate in a relationships – Specified for each end of the association • Associations are bi-directional by default, but it is often desirable to restrict navigation to one direction Multiplicity Customer * Account Navigation 31 Relationships: Dependency • A relationship between two model elements where a change in one may cause a change in the other – E.g Class A depends on class B: method of A manipulates objects of B in the parameters, local variables, or return types Class Client Package ClientPackage Supplier Dependency relationship SupplierPackage 32 Relationships: Realization Tube Shape Pyramid Draw Move Scale Rotate Cube Realization relationship (stay tuned for realization relationships) 33 Inheritance Shape origin draw() erase() move() setColor() getColor() Circle draw() erase() Square draw() erase() move() [Martin Fowler] 34 Polymorphism Bird FlockManager move() reLocate() Goose move() Penguin move() [Martin Fowler] 35 What Gets Inherited? • A subclass inherits its parent’s attributes, operations, and relationships • A subclass may: – Add additional attributes, operations, relationships – Redefine inherited operations (use caution!) • Common attributes, operations, and/or relationships are shown at the highest applicable level in the hierarchy Inheritance leverages the similarities among classes 36 Example: What Gets Inherited GroundVehicle weight licenseNumber Superclass (parent) owner * Person register( ) generalization Car Subclass size Truck Trailer tonnage getTax( ) 37 ... actions it performs • What are the benefits of OO? – OO enhances key software quality factors of a system and its constituent components OOA, OOD, and OOP • Object-oriented methods may be applied... Programming (OOP) – construction of software systems using object oriented concepts as inheritance, polymorphism, encapsulation, dynamic binding • Distinguish between OOD and OOP – OOD is relatively... system's behavioral requirements determined during analysis Basic Definitions OOD, and OOP • Object-Oriented Design (OOD) – A method for decomposing software architectures based on the objects

Ngày đăng: 29/03/2021, 14:51

TỪ KHÓA LIÊN QUAN

w