Topic 2 Introduction to Object Orientation ObjectOriented Systems

Topic 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A. Hoffer © Prentice Hall, 2007 2 -1

Chapter Objectives l After studying this chapter you should be able to: – Define an object. – Understand the terms class, attribute, and operations. – Explain generalization, polymorphism, and inheritance. – Define association. – Describe modeling and the Unified Modeling Language. Topic 2 © Prentice Hall, 2007 2 -2

Unified Modeling Language (UML) l A standard notation for representing objectoriented systems l Boxes represent classes, components, packages, objects – Containing attributes and operations – Provide interfaces to external entities l Lines represent generalization and other relationships Topic 2 © Prentice Hall, 2007 2 -3

Sample UML Diagram Topic 2 © Prentice Hall, 2007 2 -4

What Is an Object? l An entity that encapsulates data and behavior l- Objects are categorized into classes l- Each individual object is an instance of a l class Topic 2 © Prentice Hall, 2007 2 -5

What Is Encapsulation? l The characteristic of object-orientation in which data and behavior are bundled into a class and hidden from the outside world l Access to the data and behavior is provided and controlled through an object’s interface Topic 2 © Prentice Hall, 2007 2 -6

What Is a Class? • A category of objects that share the same attributes, operations, relationships, and semantics • All objects are instances of classes Topic 2 © Prentice Hall, 2007 2 -7

Name Attributes Operations Topic 2 © Prentice Hall, 2007 2 -8

What Is an Attribute? • Attribute- a named property of a class that describes a range of values that instances of the attribute might hold • Attributes are the way classes encapsulate data Topic 2 © Prentice Hall, 2007 2 -9

Minus sign indicates these are private (hidden) Attributes are properties containing values Topic 2 © Prentice Hall, 2007 2 -10

What Is an Operation? l. A behavior of an object l Implemented in classes are methods l Methods are identified and invoked by their signatures, including name, parameters, and return type Topic 2 © Prentice Hall, 2007 2 -11

Signature has name, parameters, return type Method implements the behavior Topic 2 © Prentice Hall, 2007 2 -12

Plus sign indicates these are public (accessible) Topic 2 © Prentice Hall, 2007 2 -13

What Is Generalization? l. A relationship between a more general (or parent) class and a more specific (or child) class l The more specific class has additional attributes and operations Topic 2 © Prentice Hall, 2007 2 -14

What Is Inheritance? l The mechanism by which the more specific class in a generalization relationship includes the attributes and operations of the more general class Topic 2 © Prentice Hall, 2007 2 -15

Generalization represented by arrows from subclass to superclass Subclasses inherit all attributes and operations of superclasses Topic 2 © Prentice Hall, 2007 2 -16

What Is Polymorphism? l The ability for different classes of objects to respond to identical messages in different ways l Polymorphism l Different Topic 2 = “having many forms” behaviors for the same message © Prentice Hall, 2007 2 -17

Here, each type of vehicle has its own version of calc. Price() Topic 2 © Prentice Hall, 2007 2 -18

What Is a Component? l. A replaceable part of a system providing a clearly defined function through a set of interfaces l Group of classes working together toward a common end; a subsystem Topic 2 © Prentice Hall, 2007 2 -19

What Is an Interface? l The mechanism by which users of a component invoke its behaviors and manipulate its properties l The interface is implemented by method signatures Topic 2 © Prentice Hall, 2007 2 -20

Interfaces are represented as small rectangles Topic 2 © Prentice Hall, 2007 2 -21

What Is a Package? l. A logical grouping of related analysis or design elements l Group of classes sharing similar characteristics or purposes Topic 2 © Prentice Hall, 2007 2 -22

Package is to component as folder is to file Topic 2 © Prentice Hall, 2007 2 -23

What Is an Association? l A relationship or link between instances of (or objects) of classes l Three types: – Simple associations: no ownership – Aggregations: part-whole relationships where the part can exist independently of the whole – Compositions: part-whole relationships where the part and the whole are fully dependent on each other Topic 2 © Prentice Hall, 2007 2 -24

This is a binary association, showing roles and multiplicities roles multiplicities Topic 2 © Prentice Hall, 2007 2 -25

Systems Modeling Systems modeling – creating an abstraction of a system l Abstraction – focusing on the relevant aspects and ignoring other details l UML is a modeling approach, involving these diagrams: l – Use-case, sequence, communication, class, object, activity, state, composite structure, package, component, deployment Topic 2 © Prentice Hall, 2007 2 -26

UML Diagrams l Use-case diagram – shows use cases, actors, and relationships describing user interactions with system l Sequence diagram – shows interactions of objects via message-passing in time-ordered manner l Communication diagram – similar to sequence diagram, but without the time-ordering Topic 2 © Prentice Hall, 2007 2 -27

UML Diagrams l Class diagram – shows set of classes and relationships (generalizations and associations) l Object diagram – shows specific instances of a class diagram l Activity diagram – shows flow of activities, or wokflow of objects Topic 2 © Prentice Hall, 2007 2 -28

UML Diagrams (cont. ) l State diagram – shows transitioning of an object from state to state in response to events l Composite structure diagram – shows how a component whole is made up of its parts l Package diagram – shows logical grouping of analysis or design elements Topic 2 © Prentice Hall, 2007 2 -29

UML Diagrams (cont. ) l Component diagram – shows software components or modules and their relationships l Deployment diagram – shows configuration of runtime processing nodes and their components Topic 2 © Prentice Hall, 2007 2 -30

Recap l After studying this chapter we learned to: – Define an object. – Understand the terms class, attribute, and operations. – Explain generalization, polymorphism, and inheritance. – Define association. – Describe modeling and the Unified Modeling Language. Topic 2 © Prentice Hall, 2007 2 -31
- Slides: 31