Presentation is loading. Please wait.

Presentation is loading. Please wait.

SOFTWARE DESIGN RAJIKA TANDON

Similar presentations


Presentation on theme: "SOFTWARE DESIGN RAJIKA TANDON"— Presentation transcript:

1 SOFTWARE DESIGN RAJIKA TANDON
CIS 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 joe: Inspector mary: Inspector anonymous: 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 Attributes – A data value held by the objects in a class.
name:string age: integer Inspector name = “Joe” age = 24 joe:Inspector name = “Mary” age = 18 mary: Inspector

12 Operation, Signature or Method. What when
Operation, Signature or Method? What when? ( Feature –A generic word for either attribute /operation) 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()

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:
one and only one exactly 1 zero or one or 1 (optional) one or more > = 1 M- N from M to N M to N greater than or equal to zero > = 0 (many)

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

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

17 Many-to-Many Associations
Mechanics Plane 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

22 Do associations have direction?
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. A B Name of association Name Direction A B accesses Association Direction Class A ( the “client”) accesses class B (“the server”). B is also called navigable.

23 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 xi R 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

24 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

25 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. Person Person Creates Workorders Person inspector Person Creates Workorders repairperson

26 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. Directory File filename 1 * 0..1 With qualification: A directory has many files, each with a unique name

27 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. StockExchange Company tickerSym lists

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

29 officer Company Person office Organization Many-to-Many Qualification

30 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)

31 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

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

33 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 * Frame part

34 Composition (by Value)
gfdgfdgfdgfdgfdg

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

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

37 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

38 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.

39 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.

40 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

41 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.

42 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 be directed labels Can have multiplicity & 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.

43 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

44 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

45 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

46 Example: Scenario from Problem Statement
Jim Smith enters 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 ? )

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

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

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

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

51 Object Modeling in Practice: Categorize
Object Modeling in Practice: Categorize! ( many accounts belong to 1 bank OR a bank holds many accounts – aggregation) Account Balance AccountId Deposit() Withdraw() GetBalance() Bank Customer Name * * Name Has CustomerId Savings Account Checking Account Mortgage Account Withdraw() Withdraw() Withdraw()

52 Object Modeling in Practice: Heuristics
Explicitly schedule meetings for object identification Try to differentiate between entity, boundary and control objects Find associations and their multiplicity Unusual multiplicities usually lead to new objects or categories Identify Aggregation Identify Inheritance: Look for a Taxonomy, Categorize Allow time for brainstorming , Iterate, iterate

53 Summary In this lecture, we described:
Identification of objects and classes Refinement of objects with attributes and operations Generalization Associations Aggregation Composition Multiplicity

54 A static class model for ABC distributing company
Create the class model using the following class relations and the business rules: An Invoice is composed of one or more Entries An Invoice is created for exactly one Customer An Invoice is created from one or more CustomerOrders An Invoice is used to update the AccountsReceivable account An Inventory is composed of zero or more StockItems A PackingOrder is initiated from one or more Invoices A PackingOrder is created from Inventory items A PackingOrder is used to update the Inventory A StockOrder is received from a Supplier A StockOrder is used to update the Inventory A StockOrder is used to update the AccountsPayable account

55 Class Diagram (a rough sketch for the above problem)
Invoice AccountsReceivable CustomerOrder Account Customer Entry PackingOrder Created from updates Inventory Supplier Received from AccountsPayable StockItem StockOrder updates updates

56 Please refer to Design_Principles.doc, for details on: Coupling
Notes: Please refer to Design_Principles.doc, for details on: Coupling Cohesion References: Notes derived from Ms. Chandrakala .C.B., Dept. of Information & Communication Technology, Manipal Institute of Technology, Manipal University, India:


Download ppt "SOFTWARE DESIGN RAJIKA TANDON"

Similar presentations


Ads by Google