280 likes | 298 Views
This chapter introduces key object-oriented concepts like classes, attributes, operations, generalization, polymorphism, encapsulation, inheritance, association, and more. Learn how these principles form the foundation of modern system analysis and design practices.
E N D
Chapter 2:Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A. Hoffer
Chapter Objectives • 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.
What is an Object? • An entity that encapsulates data/attributes and behavior/operations • - Objects are categorized into classes • - Each individual object is an instance of a class
What is a Class? • A category of objects that share the same data attributes, and operational behavior • All objects are instances of classes • Classes are like templates, or blueprints, or types for objects
What is Encapsulation? • The characteristic of object-orientation in which data and behavior are bundled into a class and hidden from the outside world • Access to the data and behavior is provided and controlled through an object’s interface,aka. API (application programming interface)
Name Attributes Operations
What is an Attribute? • Attribute – is a named property of a class that describes the various characteristics that objects within the class will have • Attributes are the way classes encapsulate data • Attributes are mostly nouns
Minus sign indicates these are private (hidden) Attributes are properties containing values
What is an Operation? • A behavior for an object • Implemented in OO classes as methods • A method is where the program code resides • Methods are identified and invoked by their signatures, including their names and parameters • Methods are mostly verbs
A method signature identifies the interface to the method A method implements the behavior
Plus sign indicates these are public (accessible) Method signatures
What is Generalization? • A relationship betweena parent class (more general) classand a child class (morespecific) • The more specific the class is, the more additionalattributes and operations it has • A parent class Vehicle is more general • A child class Car is more specific
What is Inheritance? • The mechanism by which the more specific (child) class in a generalization relationship includes the attributes and operations of the more general (parent) class
A generalization relationship is represented by an arrow from the subclass to the superclass Subclasses inherit all attributes and operations of superclasses
What is a Message? • A message is the way one method or process invokes (calls) another method or process • The message will include the name of the method, and the value of parameters the method expects in parenthesis • Example: add_order(123456)
What is Polymorphism? • The ability for different subclasses to respond to identical messages in different ways • Polymorphism = “having many forms” • Different behaviors for the same message • Each subclass (e.g. FullTimeEmp, PartTimeEmp) will implement the same method (e.g. calcSalary) differently
Here, each type of vehicle has its own version of calcPrice( )
What is a Component? • A replaceable part of a system providing a clearly defined function through a set of interfaces • Group of classes working together toward a common end; a subsystem
What is an Interface? • The mechanism by which users of a component invoke its behaviors and manipulate its properties • The interface is implemented by method signatures
What is a Package? • A general-purpose mechanism for organizing elements into groups • Group of classes sharing similar characteristics or purposes • A Package is akin to a folder on your operating system
The Sales package might include: a product, inventory and customer classes
What is an Association? • A relationship or a link between two or more classes • Three types: • Simple associations: no ownership (e.g. people, places) • Aggregations: whole-part relationships where the part can exist independently of the whole (e.g. team, player) • Compositions: whole-part relationships where the part is fully dependent on whole, and cannot exist without it(e.g. sales_order and sales_order_line items)
What is Association Multiplicity? • Identifies the number of associated entities that can exist for an entity • Three types: • One to One: one entity is associated with a single entity • One to Many: one entity is associated with zero or more entities • Many to Many: one entity “A” is associated with zero or more entities “B” , and one entity “B” is associated with zero or more entities “A”
Unified Modeling Language (UML) • A standard notation for representing object-oriented systems created by Grady Booch, James Rumbaugh, and Ivar Jacobson • Boxes represent classes, components, packages, objects • Containing attributes and operations • Provide interfaces to external entities • Lines represent relationships, (either generalization and association)
UML Diagrams • Class Diagram – shows classes and relationships. • Use Case Diagram – describes sequences of action involving actors. • Sequence Diagram – shows interaction with objects in a time-ordered manner. • Collaboration Diagram – interaction with objects without time relevance. • Activity Diagram – shows data flow from one activity to another. Similar to flow chart diagrams • Statechart Diagram – shows transition of an object from one state to another as a response to an event • Package Diagram – shows components in packages.
Recap • 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.