Requirements Modeling

Class Diagrams

What are Class Diagrams?

Pressman, R., Maxim, B. Software Engineering: A Practitioners Approach

  • Built from requirements elicited from the customer.
  • A representation understood by both stakeholders and software engineers.
  • Represents the objects that the system will manipulate.
  • Specifies the operations that will be applied to the objects
  • Specifies relationships between objects/classes

Why?

Pressman, R., Maxim, B. Software Engineering: A Practitioners Approach

  • Depicts a view of the system that the customer can understand.
  • Typically results in useful feedback at the earliest possible time.
  • With further refinements, becomes the basis for software design.

How do I build them?

Pressman, R., Maxim, B. Software Engineering: A Practitioners Approach

  • Identify Classes/Objects
  • Specify attributes
  • Define operations
  • Specify associations and dependencies

Identifying Classes

Pressman, R., Maxim, B. Software Engineering: A Practitioners Approach

  • Underline each noun or noun phrase and record them somewhere.
    • Pay attention to synonyms
  • Classes are typically: 
    • external entites (e.g. people, other systems)
    • things (e.g. reports, displays)
    • roles (e.g. manager, engineer)
    • any other entity that is important to the problem or solution space
  • Generally, classes should never have "procedural names" e.g. DeleteUser

Identifying Classes: Selection

Pressman, R., Maxim, B. Software Engineering: A Practitioners Approach

  • Review and select from your list of classes (nouns and phrases) as follows:
    • Information about the class must be remembered so that the system can function.
    • Has a set of identifiable operations that can change attributes of the class.
    • Multiple attributes: sometimes a class with a single attribute is better represented as an attribute of another class.
    • Has attributes that apply to all instances of the class.
    • Has operations that apply to all instances of the class.
    • External entities that produce or consume information.

Attributes and Operations

http://www.tutorialspoint.com/uml/uml_class_diagram.htm

  • Attributes describe a class.
  • Operations define the behavior of an object.

Relationships: Composition

Pressman, R., Maxim, B. Software Engineering: A Practitioners Approach

  • One class is composed of another.
  • The black diamond represents composition
  • Arrowhead denotes the relationship is navigable in only one direction.

Relationships: Inheritance

http://www.objectmentor.com/resources/articles/umlClassDiagrams.pdf

  • Depicted by triangular arrowhead that looks like a slice of pizza.
  • "is-a" relationship

Relationships: Aggregation

Pressman, R., Maxim, B. Software Engineering: A Practitioners Approach

  • "whole/part" relationships.
  • Represented by an open diamond.
  • Example: A window may contain many shape instances
  • Notice that the role has been named. This is the name that Window knows its Shape instance by.
  • "*" represents many.

Now, go forth into the world and build those class diagrams!

Class Diagrams

By David Adamo Jr.

Class Diagrams

  • 508