domain model: adding attributes identify attributes in a domain model. distinguish between correct...

43
DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes.

Upload: ann-pearson

Post on 14-Dec-2015

242 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

DOMAIN MODEL:ADDING ATTRIBUTES

Identify attributes in a domain model.

Distinguish between correct and incorrect attributes.

Page 2: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

DOMAIN MODEL:ADDING ATTRIBUTES

An attribute is a logical data value of an object.

Include the following attributes in a domain model:

Those for which the requirements (for example, use cases) suggest or imply a need to remember information.

Page 3: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

UML Attribute Notation

Page 4: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Valid Attribute Types

Keep Attributes Simple

Page 5: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Valid Attribute Types

Keep Attributes Simple

Page 6: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Valid Attribute Types

Keep Attributes Simple

Page 7: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Conceptual vs. Implementation Perspectives

What About Attributes in Code ?

Page 8: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Data Types

Attributes should generally be data types. This is a UML term that implies a set of values for which unique identity is not meaningful (in the context of our model or system) [RJB99].

If in doubt, define something as a separate conceptual class rather than as an attribute.

Page 9: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Non-primitive Data Type Classes

Represent what may initially be considered a primitive data type (such as a number or string) as a non-primitive class if:

• It is composed of separate sections.o phone number, name of person

• There are operations usually associated with it, such as parsing or validation.

o social security number

Page 10: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Non-primitive Data Type Classes

• It has other attributes.o promotional price could have a start (effective) date and end date

• It is a quantity with a unit.o payment amount has a unit of currency

• It is an abstraction of one or more types with some of these qualities.

o item identifier in the sales domain is a generalization of types such as Universal Product Code (UPC) or European Article Number (EAN)

Page 11: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Where to Illustrate Data Type Classes?

Page 12: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Where to Illustrate Data Type Classes?

Page 13: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Design Creep: No Attributes as Foreign Keys

Attributes should not be used to relate conceptual classes in the domain model. The most common violation of this principle is to add a kind of foreign key attribute.

Page 14: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Design Creep: No Attributes as Foreign Keys

Page 15: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Modeling Attribute Quantities and Units

Page 16: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Attributes in the NextGen Domain Model

Page 17: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Attributes in the NextGen Domain Model

Page 18: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Multiplicity From SalesLineItem to Item

Page 19: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Domain Model Conclusion

Page 20: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

USE-CASE MODEL:ADDING DETAIL WITH OPERATION CONTRACTS

Objectives• Create contracts for system

operations.

Page 21: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

USE-CASE MODEL:ADDING DETAIL WITH OPERATION CONTRACTSContracts Use cases are the primary mechanism in the

UP to describe system behavior, and are usually sufficient. However, sometimes a more detailed description of

system behavior has value. Contracts describe detailed system behavior in terms of state changes to objects in the Domain Model, after a system operation has executed.

Page 22: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

System Operations and the System Interface

Page 23: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Example Contract: enterltem

Page 24: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Postconditions

Page 25: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Postconditions

If Contracts Are Used, How Complete Should Postconditions Be?

Page 26: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Writing Contracts Leads to Domain Model Updates

It is common during the creation of the contracts to discover the need to record new conceptual classes, attributes, or associations in the Domain Model. Do not be limited to the prior definition of the Domain Model; enhance it as you make new discoveries while thinking through the operation contracts.

Page 27: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

When Are Contracts Useful? Contracts vs. Use Cases?

The use cases are the main repository of requirements for the project. They may provide most or all of the detail necessary to know what to do in the design, in which case, contracts are not helpful.

There are situations where the details and complexity of required state changes are awkward to capture in use cases.

Page 28: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Guidelines: Contracts

To make contracts: 1. Identify system operations from the SSDs. 2. For system operations that are complex and

perhaps subtle in their results, or which are not clear in the use case,

construct a contract. 3. To describe the postconditions, use the following

categories: o instance creation and deletion o attribute modification o associations formed and broken

Page 29: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Guidelines: Contracts

To make contracts: 1. Identify system operations from the SSDs. 2. For system operations that are complex and

perhaps subtle in their results, or which are not clear in the use case, construct a contract.

3. To describe the postconditions, use the following categories:

o instance creation and deletion o attribute modification o associations formed and broken

Page 30: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Advice on Writing Contracts

State the postconditions in a declarative, passive past tense form (was ...) to emphasize the declaration of a state change rather than a design of how it is going to be achieved. For example:

# (better) A SalesLineltem was created. .) # (worse) Create a SalesLineltem.

Remember to establish a memory between existing objects or those newly created by defining the forming of an association. For example, it is not enough that a new SalesLineltem instance is created when the enterltem operation occurs. After the operation is complete, it should also be true that the newly created instance was associated with Sale; thus:

# The SalesLineltem was associated with the Sale (association formed).

Page 31: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

The Most Common Mistake in Creating Contracts

The most common problem is forgetting to include the forming of associations. Particularly when new instances are created, it is very likely that associations to several objects need be established. Don't forget!

Page 32: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

NextGen POS Example: Contracts

Page 33: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

NextGen POS Example: Contracts

Page 34: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

NextGen POS Example: Contracts

Page 35: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Changes to the Domain Model

Page 36: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Contracts, Operations, and the UML

The UML formally defines operations. To quote:

An operation is a specification of a transformation or query that an object may be called to execute [RJB99]

Page 37: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Contracts, Operations, and the UML

To summarize:The UML defines operation specifications,

which are specifiable in the pre- and post-condition contract style. Note that, as emphasized in this chapter, a UML operation specification may not show an algorithm or solution, but only the state changes or effects of the operation.

Page 38: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Operation Contracts Within the UP

Inception.Contracts are not motivated during inception.they are too detailed.

Elaboration.If used at all, most contracts will be written during elaboration, when most use cases are written. Only write contracts for the most complex and subtle system operations.

Page 39: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

FROM REQUIREMENTS TO DESIGN IN THIS ITERATION

Page 40: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Iteratively Do the Right Thing, Do the Thing Right

The requirements and object-oriented analysis has focused on learning to do the right thing; that is, understanding some of the outstanding goals for the Next-Gen POS, and related rules and constraints. By contrast, the following design work will stress do the thing right; that is, skillfully designing a solution to satisfy the requirements for this iteration.

Page 41: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

Didn't That Take Weeks To Do? No, Not Exactly.

After many chapters of detailed discussion, it must surely seem like the prior modeling would take weeks of effort. Not so. When one is comfortable with the skills of use case writing, domain modeling, and so forth, the duration to do all the actual modeling that has been explored so far is realistically just a few days.

Page 42: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

On to Object Design No, Not Exactly.

During object design, a logical solution based on the object-oriented paradigm is developed. The heart of this solution is the creation of interaction diagrams, which illustrate how objects collaborate to fulfill the requirements. After or in parallel with drawing interaction diagrams, (design) class diagrams can be drawn. These summarize the definition of the software classes (and interfaces) that are to be implemented in software. In terms of the UP, these artifacts are part of the Design Model.

Page 43: DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes

The Importance of Object Design Skill vs. UML Notation Skill