1 / 48

Introduction to the Object-Oriented Paradigm

Introduction to the Object-Oriented Paradigm. Objectives. To explain the essential difference between the procedural and object-oriented (OO) paradigms To summarize the advantages and disadvantages of the OO paradigm

Download Presentation

Introduction to the Object-Oriented Paradigm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to the Object-Oriented Paradigm Object-Oriented Paradigm and UML

  2. Objectives • To explain the essential difference between the procedural and object-oriented (OO) paradigms • To summarize the advantages and disadvantages of the OO paradigm • To explain the basics concepts of the OO paradigm: objects, classes, attributes, and operations Object-Oriented Paradigm and UML

  3. The Procedural Paradigm • Operations are separate from data but manipulate it. • Example: A stack data type • Data store (array, linked list) • Separate operations for pushing, popping, etc. Object-Oriented Paradigm and UML

  4. The Object-Oriented Paradigm • Data is packaged (encapsulated) with the operations that manipulate it. • Example: a stack object • Data store within a stack object • Operations within the stack object Object-Oriented Paradigm and UML

  5. Encapsulation Advantages 1 • Problem and solutionsimilarity—Software objects are like real-world things. • Abstraction—Data structures and algorithm details are ignored in design. • Informationhiding—Implementations can be truly hidden. (Shielding the internal details of a program unit’s processing from other program units) Object-Oriented Paradigm and UML

  6. Encapsulation Advantages 2 • Coupling—Operations are not related through shared data structures. (The degree of connection between pairs of modules) • Cohesion—It’s easier to keep related operations and data together. (The degree to which a module’s parts are related to one another) Object-Oriented Paradigm and UML

  7. Encapsulation Advantages 3 • Reusability—It’s easier to reuse objects than collections of operations and various data structures. • Scalability—Objects can be of arbitrary size. • Newfeatures—The object-oriented paradigm offers new and powerful ways of doing things, as we will see. Object-Oriented Paradigm and UML

  8. Problems with the OO Paradigm • It’s a lot more complicated than the procedural paradigm. • Harder to learn • Harder to use properly Object-Oriented Paradigm and UML

  9. Objects An object is an entity that has properties and exhibits behavior. • Things are encapsulated when they are packaged together in a container. • Objects encapsulate properties and behavior. • Ideally, objects model things in the world. • Example: Traffic simulation Object-Oriented Paradigm and UML

  10. Attributes and Operations An attribute is a named data value held by an object or a class. An operation is a named object or class behavior. A feature is an attribute or operation. Object-Oriented Paradigm and UML

  11. Attribute and Operation Examples Object-Oriented Paradigm and UML

  12. Object Characteristics • Every object has its own attributes and operations, though these may be the same as some other objects. • Every object has a unique identity. • Two objects with the same attributes holding the same values and behaviors are distinct. Object-Oriented Paradigm and UML

  13. Messages • Objects communicate by sending one another messages. • Messages are abstractions of function calls, signals, exceptions, etc. • Ideally, objects send messages that model real-world communications between things. • Example: Traffic simulation Object-Oriented Paradigm and UML

  14. Classes An class is an abstraction of a set of objects with common attributes and operations. • Classes have attributes and operations. • A class is not a set of objects—it is more like a blueprint or a specification. • Objects are said to be instances of classes. Object-Oriented Paradigm and UML

  15. Examples of Classes Object-Oriented Paradigm and UML

  16. Classes and Abstract Data Types • ADT: a set of values (the carrier set) and a collection of operations to manipulate them • A class forms a type but not an ADT • Mathematical entities that can be implemented procedurally or using the OO paradigm • OO techniques provide an excellent way to implement ADTs Object-Oriented Paradigm and UML

  17. UML Class and Object Diagrams Object-Oriented Paradigm and UML

  18. UML • Unified Modeling Language • Developed by Grady Booch, Ivar Jacobson, and James Rumbaugh (the three amigos) at Rational Software Corporation (1994) • Goal to produce a standard OO analysis and design notation • Now a standard controlled by the Object Management Group (OMG) Object-Oriented Paradigm and UML

  19. UML Names • A name in UML is character string that identifies a model element. • Simple name: sequence of letters, digits, or punctuation characters • Composite name: sequence of simple names separated by the double colon (::) • Examples • Java::util::Vector • veryLongNameWithoutPunctuationCharacters • short_name Object-Oriented Paradigm and UML

  20. UML Class Symbol Object-Oriented Paradigm and UML

  21. Attribute Specification Format name : type [ multiplicity ] = initial-value • name—simple name, cannot be suppressed • type—any string, may be suppressed with the : • multiplicity—number of values stored in attribute • list of ranges of the form n..k, such that n <=k • k may be * • n..n is the same as n • 0..* is the same as * • 1 by default • if suppressed, square brackets are omitted • initial-value—any string, may be suppressed along with the = Object-Oriented Paradigm and UML

  22. Examples • weight • weight : real = 40.0 • signal[*] : real = { 0.0 } • charge[3,5,7..10] • hour = 12 Object-Oriented Paradigm and UML

  23. Operation Specification Format name( parameter-list ) : return-type-list • name—simple name, cannot be suppressed • parameter-list • direction param-name : param-type = default-value • direction—in, out, inout, return; in when suppressed • param-name—simple name; cannot be suppressed • param-type—any string; cannot be suppressed • default-value—any string; if suppressed, so is = • return-type-list—any comma-separated list of strings; if omitted (with :) indicates no return value • The parameter-list and return-type-list may be suppressed together. Object-Oriented Paradigm and UML

  24. Examples • rotate() • rotate( degrees : real ) • rotate( in degrees : real = 0.0 ) : Boolean • rotate( inout degrees : real ) • print( s : String[*] ) : void • split( s : String ) : int, String[*] Object-Oriented Paradigm and UML

  25. Attribute and Operation Examples Object-Oriented Paradigm and UML

  26. Class Diagram Uses • Central static modeling tool in object-oriented design • Can be used throughout both the product and engineering design processes Object-Oriented Paradigm and UML

  27. Object Diagrams • Object diagrams are used much less often than class diagrams. • Object symbols have only two compartments: • Object name • Attributes (may be suppressed) Object-Oriented Paradigm and UML

  28. Object Name Format • object-name : class-name[ stateList ] • object-name—simple name • class-name—a name (simple or composite) • stateList—list of strings; if suppressed, the square brackets are omitted • The object-name and class-name may both be suppressed, but not simultaneously. Object-Oriented Paradigm and UML

  29. Object Attribute Format attribute-name = value • attribute-name—simple name • value—any string • Any attribute and its current value may be suppressed together. Object-Oriented Paradigm and UML

  30. Examples of Object Symbols Object-Oriented Paradigm and UML

  31. Object Diagram Uses • Show the state of one or more objects at a moment during execution • Dynamic models as opposed to class diagrams, which are static models (A static model represents aspects of a program that do not change during execution.) (A dynamic model represents aspects of a program that change during execution.) Object-Oriented Paradigm and UML

  32. UML Diagram Tree Object-Oriented Paradigm and UML

  33. Procedural vs. Object-Oriented Thinking Object-Oriented Paradigm and UML

  34. Stack of int ADT • Carrier set: set of all stacks of ints • Empty stack • #0, #1, #2, … • #00, #01, #10, … • … • Operations: push(), pop(), top(), isEmpty(), isFull(), … Object-Oriented Paradigm and UML

  35. Procedural Approach • Determine a way to represent the elements of the carrier set (a data structure) • Determine how to implement the operations (procedures) • Implement the data structure and procedures in code Object-Oriented Paradigm and UML

  36. C stackOfInt Implementation • stackOfInt.h • stackOfInt.c • main.c Object-Oriented Paradigm and UML

  37. Object-Oriented Approach • Encapsulate the carrier set and the operations in a class • Determine how to implement the carrier set and operations • Implement the class in code Object-Oriented Paradigm and UML

  38. Class Design Object-Oriented Paradigm and UML

  39. C++ IntStack Implementation • IntStack.h • IntStack.cpp • main.c Object-Oriented Paradigm and UML

  40. Example: Ph Monitor • pH sensors in a vat are monitored • A control chart is generated Object-Oriented Paradigm and UML

  41. Procedural Approach • Make a context diagram • Make data flow diagrams • Make ERDs • Make a structure chart • Implement the code Object-Oriented Paradigm and UML

  42. pH Monitor Context Diagram Object-Oriented Paradigm and UML

  43. pH Monitor Data Flow Diagram Object-Oriented Paradigm and UML

  44. pH Monitor Structure Chart Object-Oriented Paradigm and UML

  45. How to describe Requirement Result on OO? • Use UML diagram • Sometime you can use Use Case diagram as the first diagram. • Move into another diagram as needed. Object-Oriented Paradigm and UML

  46. Change Chart Display Chart Collect Sample Use Case Diagram Object-Oriented Paradigm and UML

  47. pH Monitor Class Diagram Object-Oriented Paradigm and UML

  48. Thank you Object-Oriented Paradigm and UML

More Related