1 / 56

RAJIKA TANDON

RAJIKA TANDON. SOFTWARE DESIGN. CIS 453 - Software Specification & Design Instructor: Dr. E. Sibert. DESIGN. The design of a system is essentially a blueprint or a plan for a solution for the system.

tarannum
Télécharger la présentation

RAJIKA TANDON

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. RAJIKA TANDON SOFTWARE DESIGN • CIS 453 - Software Specification & Design Instructor: Dr. E. Sibert

  2. DESIGN • The design of a system is essentially a blueprint or a plan for a solution for the system. • Here we consider a system to be a set of modules with clearly defined behavior which interact with each other in a defined manner to produce some behavior or services for its environment. • The design process for software systems often has two levels. At the first level the focus is on deciding which modules are needed for the system, the specifications of these modules, and how the modules should be interconnected. • This is what may be called the module design or the high-level design. • In the second level, the internal design of the modules, or how the specifications of the module can be satisfied, is decided. This design level is often called detailed design or logic design. • Detailed design essentially expands the system design to contain a more detailed description of the processing logic and data structures so that the design is sufficiently complete for coding.

  3. Object model? • An object model defines the structural relationships and dynamic interaction between a group of related objects. • An object diagram represents a specific collection of objects, with specific attribute values and relationships. • Therefore it looks like a snapshot of an O-O system at some instant in time.

  4. Outline • Object modeling • Class vs instance diagrams • Attributes • Operations and methods • Links and associations • Examples of associations • Two special associations • Aggregation • Inheritance

  5. Definition: Object Modeling • Main goal: Find the important abstractions • Steps during object modeling • 1. Class identification • Based on the fundamental assumption that we can find abstractions • 2. Find the attributes • 3. Find the methods • 4. Find the associations between classes • Order of steps • Goal: get the desired abstractions • Order of steps secondary, only a heuristic • Iteration is important What happens if we find the wrong abstractions? • Iterate and correct the model

  6. Class Identification • Identify the boundaries of the system • Identify the important entities in the system • Class identification is crucial to object-oriented modeling • Basic assumption: • 1. We can find the classes for a new software system (Forward Engineering) • 2. We can identify the classes in an existing system (Reverse Engineering)

  7. Pieces of an Object Model • Classes • Associations (Relations) • Part of- Hierarchy (Aggregation) • Kind of-Hierarchy (Generalization) • Attributes • Detection of attributes • Application specific • Attributes in one system can be classes in another system • Turning attributes to classes • Methods • Detection of methods • Generic methods: General world knowledge, design patterns • Domain Methods: Dynamic model, Functional model

  8. Object vs Class • Object (instance): Exactly one thing • A class describes a group of objects with similar properties • Object diagram:A graphic notation for modeling objects, classes and their relationships ("associations"): • Class diagram:Template for describing many instances of data. A class diagram describes object classes. Object class: group of objects with similar properties (attributes), common behavior(operations), common relationships to other objects) Useful for taxonomies, patters, schemata... • Instance diagram: A particular set of objects relating to each other. Useful for discussing scenarios, test cases and examples

  9. Class and Instance Diagrams Inspector Class Diagram anonymous: Inspector joe: Inspector mary: Inspector Instance Diagram

  10. Common uses of object diagrams are: • to illustrate the system state at a high level of abstraction, before and after some action (e.g. instruction execution) i.e. dynamic modeling !! • to analyze the structure of recursive data types (classes) by unfolding a class diagram.

  11. Inspector name:string age: integer joe:Inspector mary: Inspector name = “Joe” name = “Mary” age = 24 age = 18 Attributes – A data value held by the objects in a class.

  12. Operation: A function or transformation applied to objects in a class. All objects in a class share the same operations (Analysis Phase) Signature:Number & types of arguments, type of result value. All methods of a class have the same signature (Object Design Phase) Method: Implementation of an operation for a class (Implementation Phase) Polymorphic operation: The same operation applies to many different classes. Workorder File_name: String Size_in_bytes: integer Last_update: date Stickies: array[max] print() delete() open() close() write() read() Operation, Signature or Method? What when?( Feature –A generic word for either attribute /operation)

  13. Links and Associations • Links and associations establish relationships among objects and classes. • Link: • A (physical/conceptual) connection between two object instances. A link is like a tuple. • A link is an instance of an association • Association: • An association describes a set of links like a class describes a set of objects. • Basically a bidirectional mapping. • One-to-one, many-to-one, one-to-many.

  14. Notation for multiplicity: • 1 one and only one exactly 1 • 0 zero or one 0 or 1 (optional) • +1 one or more > = 1 • M- N from M to N M to N • greater than or equal to zero > = 0 (many)

  15. Country City name:String name:String Workorder schedule() 1-to-1 and 1-to-many Associations Has-capital One-to-one association StickyNote x: Integer y: Integer z: Integer One-to-many association

  16. :Sticky :Sticky :Sticky :WorkOrder x,y,z=(-1,0,5) x,y,z=(1,10,1) x,y,z=(10,1,2) Object Instance Diagram Example for 1-to-many

  17. Mechanics Plane Many-to-Many Associations Work on

  18. Ternary and n-ary relations are represented using the diamond as before, e.g. Object_1 : Class_1 Object_2 : Class_2 Object_3 : Class_3

  19. We can use object diagrams to understand recursively defined classes. For example, the class diagram Binary_Tree 0,1 0 .. 2

  20. T1 : Binary Tree T2 : Binary Tree T3 : Binary Tree T4 : Binary Tree T5 : Binary Tree

  21. Do associations have direction? A B • A association between two classes is by default a bi-directional mapping. • If you want to make A a client, and B a server, you can make the association unidirectional. The arrowhead points to the server role: • Class A can access class B and class B can access class A • Both classes play the agent role. Name of association Name Direction A B accesses Association Direction • Class A ( the “client”) accesses class B (“the server”). B is also called navigable.

  22. Relation R between classes X and Y is: n-to-… if for every object y :Y there are n distinct objects x1 ,…, xn : X with xiR y for i = 1 ,…, n …-to-m if for every object x :X there are m distinct objects y1 ,…, ym : Y with x R yi for i = 1 ,…, m

  23. Roles • A role name is the name that uniquely identifies one end of an association. • A role name is written next to the association line near the class that plays the role. • When do you use role names? • Necessary for associations between two objects of the same class • Also useful to distinguish between two associations between the same pair of classes • When do you not use role names? • If there is only a single association between a pair of distinct classes, the names of the classes serve as good role names

  24. Person Person Person Person Example of Role Pr oblem Statement : A person assumes the role of repairer with respect to another person, who assumes the role of inspector with respect to the first person. Creates Workorders inspector Creates Workorders repairperson

  25. File 1 * Directory filename 0..1 1 Directory File filename Qualification • The qualifier improves the information about the multiplicity of the association between the classes. • It is used for reducing 1-to-many multiplicity to 1-1 multiplicity Without qualification: A directory has many files. A file belongs only to one directory. With qualification: A directory has many files, each with a unique name

  26. StockExchange lists Company tickerSym Example Pr oblem Statement : A stock exchange lists many companies. However , a stock exchange lists only one company with a given ticker symbol. A company may be listed on many stock exchanges, possibly with different ticker symbols. Find company with ticker symbol AAPL.

  27. Company StockExchange tickerSym StockExchange Company tickerSym Use of Qualification reduces multiplicity 0..1 1 Directory FILE filename

  28. officer Company Person office Organization Many-to-Many Qualification

  29. Aggregation • Models "part of" hierarchy • Useful for modeling the breakdown of a product into its component parts (sometimes called bills of materials (BOM) by manufacturers)

  30. Aggregation Plain association: peer relationship. Aggregation: whole/part relationship. - An object may be a part of ONLY one aggregate at a time. Company whole 1 * Department part

  31. Aggregation • Special kind of association • For “part-whole” relationships • For “has-a” relationships • Aggregation-by-Value: Composition • Aggregation-by-Reference: Aggregation

  32. Composition In Composition (composite aggregation): - An object may be a part of ONLY one composite at a time. - Whole is responsible for the disposition of its parts. whole Window 1 * part Frame

  33. Composition (by Value) gfdgfdgfdgfdgfdg

  34. Aggregation (by Reference) Product Catalog Product 1 * Roll Call Student

  35. Aggregation vs. Composition • Both denote whole-part relationships • Both enable modeling at multiple levels of abstraction: whole or part

  36. Aggregation vs Composition (contd.) • Aggregation: does not link the lifetimes of the whole and its parts. Aggregation can occur when a class is a collection or container of other classes, but where the contained classes do not have a strong life cycle dependency on the container—essentially, if the container is destroyed, its contents are not. • Composition: usually has a strong life cycle dependency between instances of the container class and instances of the contained class(es): If the container is destroyed, normally every instance that it contains is destroyed as well. Note that (where allowed): • Parts with non-fixed multiplicity can be created after the composite itself.  lifetime • Such parts can be explicitly removed before the death of the composite.  lifetime • An object may be a part of only one composite at a time.  strong ownership

  37. Generalization • Also called Inheritance or Specialization. • Connects generalized classes to more specialized classes. • Sometimes called the “is-a” relationship because each instance of a subclass is an instance of the superclass as well. • NOTATION : A triangle connecting the superclass to its subclasses. The superclass connected by a line to the apex of the triangle. The subclasses are connected by lines to a horizontal bar attached to the base of the triangle.

  38. Aggregation Vs Generalization Both associations describe trees (hierarchies) AGGREGATION: • Aggregation relates instances (involves two or more different objects). • Two distinct objects are involved; one of them is a part of the other. • An aggregation tree is composed of object instances that are all part of a composite object. • “part-of” relationship. GENERALIZATION: • Generalization relates classes (a way to structure the description of a single object). • It is a way of structuring the description of a single object. • An generalization tree is composed of classes that describe an object • “a-kind-of”,”is-a” relationship.

  39. Class relationships • Aggregation: • Represented by has-a relationship • Also called Whole-part, Composition, or Embedding • Cardinality is associated with this relationship • Inheritance • Represented by Is-A relation • No cardinality is associated • Also referred to as generalization/specialization • Association • It is used when objects of two classes communicate or • there is a dependency that doesn’t fit the category of • aggregation or inheritance • Cardinality is associated

  40. Grouping constructs: Module: A logical construct for grouping classes, associations, and generalizations. It captures one perspective or view of a situation. For example: Electrical, Plumbing and ventilation modules are different views of a building. SHEET: A mechanism for breaking a large object model into a series of pages.

  41. Revision - Relationships 1. Dependency a semantic relationship between two things in which a change to one thing (independent) may affect the semantics of the other thing (dependent). Directed is optional and label is optional. 2. Associations a structural relationship that describes a set of links, a link being a connection between objects. Can bedirected labels Can havemultiplicity & role names employer employee 0..1 * Aggregation a special kind of association. It represents a structural relationship between the whole and its parts. Aggregation is inherently TRANSITIVE. An aggregate has parts, which may inturn have parts. Represented by a diamond. 3. Generalization a specialization/generalization relationship in which objects of the specialized element (the child) are more specific than the objects of the generalized element.

  42. Aggregation Vs Association • Aggregation relates instances. • If two objects are tightly bound by a part-whole relationship, it is aggregation. Vs Association: • If two objects considered are independent, even though they may often be linked Division Department Company Works for Person

  43. How do you find classes? • Learn about problem domain: Observe your client • Apply general world knowledge and intuition • Take the flow of events and find participating objects in use cases • Apply design patterns • Try to establish a taxonomy ( classification, derivatives ) • Do a textual analysis of scenario or flow of events (Abbott Textual Analysis, 1983) • Nouns are good candidates for classes

  44. Mapping parts of speech to object model components [Abbot 1983] Part of speech Model component Example Proper noun object Jim Smith Improper noun class Toy, doll Doing verb method Buy, recommend being verb inheritance is-a (kind-of) having verb aggregation has an modal verb constraint must be adjective attribute 3 years old transitive verb method enter intransitive verb method (event) depends on

  45. Example: Scenario from Problem Statement • Jim Smithenters a store with the intention of buying a toy for his 3 year old child. • Help must be available within less than one minute. • The store owner gives advice to the customer. The advice depends on the age range of the child and the attributes of the toy. • Jim selects a dangerous toy which is unsuitable for the child. • The store owner recommends a more yellow doll. ( Is is-a (kind-of) and has-a present in the above text ? )

  46. Foo Balance CustomerId Deposit() Withdraw() GetBalance() Object Modeling in Practice: Class Identification Class Identification: Name of Class, Attributes and Methods

  47. Account Foo “Dada” Balance Balance Balance CustomerId CustomerId CustomerId Deposit() Deposit() Deposit() Withdraw() Withdraw() Withdraw() GetBalance() GetBalance() GetBalance() Object Modeling in Practice: Encourage Brainstorming Naming is important!

  48. Account Balance AccountId Customer Bank Name CustomerId Name Deposit() Withdraw() GetBalance() Object Modeling in Practice Find New Objects Iterate on Names, Attributes and Methods

  49. Account Balance AccountId Bank Customer Name CustomerId Name Deposit() Withdraw() GetBalance() Object Modeling in Practice: A Banking System * Has Find New Objects Iterate on Names, Attributes and Methods Find Associations between Objects Label the associations Determine the multiplicity of the associations

More Related