1 / 53

Object-Oriented Concepts and Principles

Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI. Object-Oriented Concepts and Principles. The OO Process Model. The OO Mindset. objects. problem domain. Key Concepts. classes and class hierarchies instances

urbain
Download Presentation

Object-Oriented Concepts and Principles

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. Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany)DIRECTORARUNAI ENGINEERING COLLEGETIRUVANNAMALAI

  2. Object-Oriented Conceptsand Principles

  3. The OO Process Model

  4. The OO Mindset objects problem domain

  5. Key Concepts • classes and class hierarchies • instances • inheritance • abstraction and hiding • objects • attributes • methods • encapsulation • polymorphism • messages

  6. Classes • object-oriented thinking begins with the definition of a class often defined as: • template • generalized description • pattern • “blueprint” ... describing a collection of similar items • a metaclass (also called a superclass) is a collection of classes • once a class of items is defined, a specific instance of the class can be defined

  7. Building a Class

  8. What is a Class? occurrences roles organizational units things places external entities structures class name attributes: operations:

  9. Encapsulation/Hiding Theobject encapsulates both data and the logical procedures required to manipulate the data method # 2 method # 1 data method # 6 method # 4 method # 5 Achieves“information hiding”

  10. Class Hierarchy furniture (superclass) table chair desk "chable" subclasses of the furniture superclass instances of chair

  11. Methods(a.k.a. Operations, Services) An executable procedure that is encapsulated in a class and is designed to operate on one or more data attributes that are defined as part of the class. A method is invoked via message passing.

  12. Messages

  13. Object-Oriented Analysis

  14. Domain Analysis class taxononmies techncial literature DOMAIN SOURCES OF reuse standards DOMAIN ANALYSIS existing applications DOMAIN functional models ANALYSIS MODEL KNOWLEDGE customer surveys domain languages expert advice current/future requirements

  15. OOA- A Generic View • define use cases • extract candidate classes • establish basic class relationships • define a class hierarchy • identify attributes for each class • specify methods that service the attributes • indicate how classes/objects are related • build a behavioral model • iterate on the first five steps

  16. Use Cases • a scenario that describes a “thread of usage” for a system • actors represent roles people or devices play as the system functions • users can play a number of different roles for a given scenario

  17. Developing a Use Case • What are the main tasks or functions that are performed by the actor? • What system information will the the actor acquire, produce or change? • Will the actor have to inform the system about changes in the external environment? • What information does the actor desire from the system? • Does the actor wish to be informed about unexpected changes?

  18. Selecting Classes—Criteria retained information needed services multiple attributes common attributes common operations essential requirements

  19. Unified Modeling Language (UML) User model view. This view represents the system (product) from the user’s (called “actors” in UML) perspective. Structural model view. Data and functionality is viewed from inside the system. That is, static structure (classes, objects, and relationships) is modeled. Behavioral model view. This part of the analysis model represents the dynamic or behavioral aspects of the system. Implementation model view. The structural and behavioral aspects of the system are represented as they are to be built. Environment model view. The structural and behavioral aspects of the environment in which the system is to be implemented are represented.

  20. UML: Use-Case Diagram

  21. CRC Modeling

  22. Guidelines for Allocating Responsibilities to Classes 1. System intelligence should be evenly distributed. 2. Each responsibility should be stated as generally as possible. 3. Information and the behavior that is related to it should reside within the same class. 4. Information about one thing should be localized with a single class, not distributed across multiple classes. 5. Responsibilities should be shared among related classes, when appropriate.

  23. Reviewing the CRC Model 1. All participants in the review (of the CRC model) are given a subset of the CRC model index cards. 2. All use-case scenarios (and corresponding use-case diagrams) should be organized into categories. 3. The review leader reads the use-case deliberately. As the review leader comes to a named object, she passes the token to the person holding the corresponding class index card. 4. When the token is passed, the holder of the class card is asked to describe the responsibilities noted on the card. The group determines whether one (or more) of the responsibilities satisfies the use-case requirement. 5. If the responsibilities and collaborations noted on the index cards cannot accommodate the use-case, modifications are made to the cards.

  24. UML: Class Diagrams Generalization-specialization Composite aggregates

  25. UML: Package Reference

  26. Relationships between Objects

  27. Object-Behavior Model 1. Evaluate all use-cases to fully understand the sequence of interaction within the system. 2. Identify events that drive the interaction sequence and understand how these events relate to specific objects. 3. Create an event trace [RUM91] for each use-case. 4. Build a state transition diagram for the system 5. Review the object-behavior model to verify accuracy and consistency

  28. UML: State Transition

  29. UML: Event Trace

  30. Object-Oriented Design

  31. Object-Oriented Design

  32. OOA and OOD

  33. OOA and OOD

  34. Design Issues • decomposability—the facility with which a design method helps the designer to decompose a large problem into subproblems that are easier to solve; • composability—the degree to which a design method ensures that program components (modules), once designed and built, can be reused to create other systems; • understandability—the ease with which a program component can be understood without reference to other information or other modules; • continuity—the ability to make small changes in a program and have these changes manifest themselves with corresponding changes in just one or a very few modules; • protection—a architectural characteristic that will reduce the propagation of side affects if an error does occur in a given module.

  35. Generic Components for OOD • Problem domain component—the subsystems that are responsible for implementing customer requirements directly; • Human interaction component —the subsystems that implement the user interface (this included reusable GUI subsystems); • Task Management Component—the subsystems that are responsible for controlling and coordinating concurrent tasks that may be packaged within a subsystem or among different subsystems; • Data management component—the subsystem that is responsible for the storage and retrieval of objects.

  36. Process Flow for OOD

  37. System Design Process • Partition the analysis model into subsystems. • Identify concurrency that is dictated by the problem. • Allocate subsystems to processors and tasks. • Develop a design for the user interface. • Choose a basic strategy for implementing data management. • Identify global resources and the control mechanisms required to access them. • Design an appropriate control mechanism for the system, including task management. • Consider how boundary conditions should be handled. • Review and consider trade-offs.

  38. System Design

  39. Subsystem Example

  40. Subsystem Design Criteria • The subsystem should have a well-defined interface through which all communication with the rest of the system occurs. • With the exception of a small number of “communication classes,” the classes within a subsystem should collaborate only with other classes within the subsystem. • The number of subsystems should be kept small. • A subsystem can be partitioned internally to help reduce complexity.

  41. Subsystem Collaboration Table

  42. Object Design • A protocol description establishes the interface of an object by defining each message that the object can receive and the related operation that the object performs • An implementation description shows implementation details for each operation implied by a message that is passed to an object. • information about the object's private part • internal details about the data structures that describe the object’s attributes • procedural details that describe operations

  43. Design Patterns ... you’ll find recurring patterns of classes and communicating objects in many object-oriented systems. These patterns solve specific design problems and make object-oriented design more flexible, elegant, and ultimately reusable. They help designers reuse successful designs by basing new designs on prior experience. A designer who is familiar with such patterns can apply them immediately to design problems without having to rediscover them. Gamma and his colleagues [GAM95]

  44. Design Pattern Attributes • The design pattern name is an abstraction that conveys significant meaning about it applicability and intent. • The problem description indicates the environment and conditions that must exist to make the design pattern applicable. • The pattern characteristics indicate the attributes of the design that may be adjusted to enable the pattern to accommodate into a variety of problems. • The consequences associated with the use of a design pattern provide an indication of the ramifications of design decisions.

  45. Object-Oriented Testing

  46. Object-Oriented Testing • begins by evaluating the correctness and consistency of the OOA and OOD models • testing strategy changes • the concept of the ‘unit’ broadens due to encapsulation • integration focuses on classes and their execution across a ‘thread’ or in the context of a usage scenario • validation uses conventional black box methods • test case design draws on conventional methods, but also encompasses special features

  47. Broadening the View of “Testing” It can be argued that the review of OO analysis and design models is especially useful because the same semantic constructs (e.g., classes, attributes, operations, messages) appear at the analysis, design, and code level. Therefore, a problem in the definition of class attributes that is uncovered during analysis will circumvent side effects that might occur if the problem were not discovered until design or code (or even the next iteration of analysis).

  48. Testing the CRC Model 1. Revisit the CRC model and the object-relationship model. 2. Inspect the description of each CRC index card to determine if a delegated responsibility is part of the collaborator’s definition. 3. Invert the connection to ensure that each collaborator that is asked for service is receiving requests from a reasonable source. 4. Using the inverted connections examined in step 3, determine whether other classes might be required or whether responsibilities are properly grouped among the classes. 5. Determine whether widely requested responsibilities might be combined into a single responsibility. 6. Steps 1 to 5 are applied iteratively to each class and through each evolution of the OOA model.

  49. OOT Strategy • class testing is the equivalent of unit testing • operations within the class are tested • the state behavior of the class is examined • integration applied three different strategies • thread-based testing—integrates the set of classes required to respond to one input or event • use-based testing—integrates the set of classes required to respond to one use case • cluster testing—integrates the set of classes required to demonstrate one collaboration

  50. OOT—Test Case Design Berard [BER93] proposes the following approach: • 1. Each test case should be uniquely identified and should be explicitly associated with the class to be tested, • 2. The purpose of the test should be stated, • 3. A list of testing steps should be developed for each test and should contain [BER94]: • a. a list of specified states for the object that is to be tested • b. a list of messages and operations that will be exercised as a consequence of the test • c. a list of exceptions that may occur as the object is tested • d. a list of external conditions (i.e., changes in the environment external to the software that must exist in order to properly conduct the test) • e. supplementary information that will aid in understanding or implementing the test.

More Related