1 / 17

OBJECT-ORIENTED PATTERNS

OBJECT-ORIENTED PATTERNS. By: Peter Coad Presented by Peixin Chen. What is pattern?. Pattern A fully realized form, original, or model accepted or proposed for imitation; something regarded as a normative example to be copied; archetype; exemplar. Patterns apply to many disciplines.

mgirard
Download Presentation

OBJECT-ORIENTED PATTERNS

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. OBJECT-ORIENTED PATTERNS By: Peter Coad Presented by Peixin Chen

  2. What is pattern? • Pattern A fully realized form, original, or model accepted or proposed for imitation; something regarded as a normative example to be copied; archetype; exemplar. Patterns apply to many disciplines.

  3. How to discover patterns? • “Look more carefully… to find out what it really is that is repeating there…” • “Each building or town is defined by certain patterns of relationships among the elements…” • “These relationships are not extra, but necessary to the elements…”

  4. Patterns in OOA/OOD • Class and its object are the elements in low-level building block, and they are the constantly repeating lowest-level elements. • Patterns of lowest-level elements and relationships between them form a building block for more effective OOA and OOD. • Existing patterns: generalization-specification, whole-part, association, and messaging.

  5. Object-oriented patterns • An object-oriented pattern is an abstraction of a double, triplet, or other small grouping of classes that is likely to be helpful again and again in object-oriented development. • Patterns are found by trial-and-error and by observation.

  6. Severn Patterns -- Notation Attributes are listed in the center section. They depict what an object knows Services are listed in the lower section. They define what an object does ClassName Attribut1 Attribute2 Service 1 Service 2 This is a class symbol. It has no directly corresponding objects This is a class-&-object symbol. The lighter border represents an object in that class.

  7. Notation (2) GeneralizationClass Whole SpecializaitonClass Part Gen-spec structure Whole-part structure

  8. Notation (3) Receiver Sender The solid line is an association connection, indicating that one object needs to know about another object. The arrow is a message connection .

  9. Item description pattern Item description Item Guideline: when some attribute values may apply to more than one object in a class. aircraftDescription Model manufacture Aircraft tailnum Aircraft tailnum

  10. Time Association Pattern Guideline: whenever the system is responsible to know an association between two or more objects and to know or do something about that association If participant1 and participant2 is in one association, and one needs to express attributes or services regarding that association, then an object from time association is needed

  11. Event Logging Pattern EventRemembered Device Guideline: whenever an event is detected, and you need to log its occurrence to support after-the-fact analysis or to meet legal requirements.

  12. Role Played Pattern Player Guideline: whenever you have a player object which remains the same old player object, but has different attributes and services. PlayerRole More concise and flexible than attempting to use multiple inheritance to model a large numbers of roles. PlayerRole1 PlayerRole2

  13. State Across a Collection Collection Member Guideline: whenever there is a whole-part relationship, and one or more attributes apply to the whole.

  14. Behavior Across a Collection Pattern Collection Guideline: whenever there is a whole-part relationship and a behavior applies across the whole collection. A collection object has a behavior that applies across an entire collection of its member objects. Member Caution: only put behavior that really applies across the collection up into collection object.

  15. Broadcast Pattern BroadcastingItem ReceivingItem This pattern is used to communicate complex changes between one major section of an OOA/OOD model with another major section. In ParcPlace System’s ObjectWorks, this application of a broadcast pattern is called model-view-controller (MVC). Guideline: Use this pattern to establish interactions between major OOA/OOD parts in a way that two sections stay cleanly separated.

  16. MVC • In the MVC paradigm the user input, the modeling of the external world, and the visual feedback to the user are explicitly separated and handled by three types of object, each specialized for its task. • The view manages the graphical and/or textual output to the portion of the bitmapped display that is allocated to its application. • The controller interprets the mouse and keyboard inputs from the user, commanding the model and/or the view to change as appropriate. • Finally, the model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). • The MVC behavior is then inherited, added to, and modified as necessary to provide a flexible and powerful system.

  17. Summary • A pattern is a fully realized form, original, or model accepted or proposed for imitation. • With patterns, small piecework is standardized into a larger chunk or unit. • Patterns become the building blocks for design and construction. • Finding and applying patterns indicates progress in a field of human endeavor. The End

More Related