Object-Oriented Programming Six ideas characterize object-oriented programming: An object, which represents a real-world thing or event A class, or group of related objects Messages, sent between objects Encapsulation, only an object makes changes through its own behavior
Object-Oriented Programming Six ideas characterize object-oriented programming (continued): Inheritance, a new class created from another class Polymorphism, meaning that a derived class behavior may be different from the base class
Encapsulation Encapsulation changes the manner in which data is updated by programs because data can only be changed via the services that encapsulate the data
Five-Layer Model Five-layer model, continued Service layer notes messages and object behaviors Subject layer divides the design into implementation units or team assignments
Criteria to Determine Need for a New Class of Objects Criteria to determine whether a new class of objects is justified There is a need to remember the object There is a need for certain behaviors of the object An object has multiple attributes A class has more than one object instantiation Unless it is a base class
Criteria to Determine Need for a New Class of Objects Criteria, continued Attributes have a meaningful value for each object in a class Services behave the same for every object in a class Objects implement requirements that are derived from the problem setting
Criteria to Determine Need for a New Class of Objects Criteria, continued Objects do not duplicate attributes and services that could be derived from other objects in the system
Basic Types of Structures There are two basic types of structures that might be imposed on classes and objects: Generalization-Specialization structure (Gen-Spec), which connect class-to-class Whole-Part structure which are collections of different objects that compose another whole object
Instance Connections Instance connections are references between objects such as associations or relationships indicated by a single line between objects using the same cardinality notation as Whole-Part structures
Methods Services (or methods or procedures) must be analyzed. Activities are Object state analysis, showing changes of state Service specification: creating, storing, retrieving, connecting, accessing, and deleting objects Message specification, consisting of control and data flow
Major Components of Object- Oriented Design Activities Object-oriented design activities are grouped into four major components: The problem domain component The human interface component The data management component The task management component
CRC Cards Class, responsibilities, and collaborators (CRC) cards are used to represent the responsibilities of classes and the interaction between the classes
Creating CRC Cards Analysts create CRC cards by Finding all the nouns and verbs in a problem statement Create scenarios that are actually walkthroughs of system functions Identify and refine responsibilities into smaller and smaller tasks, if possible
Creating CRC Cards Creating CRC cards, continued The group determines how tasks are fulfilled by objects or interacting with other things Responsibilities evolve into methods or operations
Use Case A use case describes three things: An actor (user) that initiates an event An event that triggers a use case The use case that performs the actions triggered by the event
Kinds of Use Cases There are two kinds of use cases: Primary, the standard flow of events within a system that describe a standard system behavior Use case scenarios that describe variations of the primary use case
Steps for Creating a Use Case Model The steps required to create a use case model are Review the business specifications and identify the actors within the problem domain Identify the high-level events and develop the primary use cases that describe the events and how actors initiate them
Steps for Creating a Use Case Model Creating a use case model, continued Review each primary use case to determine possible variations of flow through the use case Develop the use case documents for all primary use cases and all important use case scenarios Move to UML diagramming techniques to complete the systems analysis and design
Two General Groupings of Things There are two general groupings of things in UML: Structural things that define the conceptual and physical structures of an O-O system and are described by nouns Behavioral things, the verbs of a UML model that represent the behavior of the system and the states of the system before, during, and after the behaviors occur
Categories of Structural Things There are seven categories of structural things The first five are conceptual or logical The last two are physical in nature Component Node
Categories of Structural Things Seven categories of structural things: Classes, which have properties or attributes and methods or operations Interfaces, the behavior of a class or component of a system that is noticeable from outside the class or component
Categories of Structural Things Seven categories, continued Collaborations, which describe the interactions of two or more things in a system that perform a behavior that is more than any one of the things can do alone Use cases, which describe a series of actions that demonstrate a distinct behavior of the system and its interactions with the actors
Categories of Structural Things Seven categories, continued Control or active classes A control class can initiate and control an independent flow of activity within the system Components, which are a physical part of a system that represents the services and interfaces implemented by the elements contained within that component, including software code
Categories of Structural Things Seven categories, continued Nodes, which represent a piece of hardware on which your system executes Components are physically deployed on nodes
Behavioral Things Behavioral things consist of Interactions, or messages sent between a set of objects within the system to perform a specific task State machine, a series of states that an object goes through in response to actions within the system
Types of Structural Relationships There are four types of structural relationships: Dependencies, where one thing affects another thing that uses it Aggregations, which show how the whole object is composed of the sum of its parts Associations that describe structural connections between things
Types of Structural Relationships Four types of structural relationships, continued Generalizations, which describe a relationship between a general kind of thing and a more specific kind of thing, used for modeling class inheritance and specialization
Types of Active Behavioral Relationships There are four active behavioral relationships: Communicates is used to connect an actor to a use case Includes describes the situation where a use case contains a behavior that is common to more than one use case
Types of Active Behavioral Relationships Types of active behavioral relationships, continued Extends describes the situation where one use case possesses the behavior that allows the new use case to handle a variation or exception Generalizes implies that one thing is more typical than the other thing
UML Structural Diagrams UML structural diagrams include Class diagrams used to model the static structural design of a system Object diagrams portray the state of class instances and their relationships at a point in time
UML Structural Diagrams UML structural diagrams, continued Component diagrams show an overview of the system architecture A deployment diagram illustrates the physical implementation of the system, including the hardware
Behavioral Diagrams Behavioral Diagrams include Use case diagrams, showing the actors and the use cases Sequence diagrams that depict a succession of interactions between object instances over time and they show the processing described in use case scenarios Activity diagrams show the flow of activities within a process
Behavioral Diagrams Behavioral Diagrams, continued Collaboration diagrams illustrate a sequence of object interactions showing the organization of the objects during the interactions State chart diagrams show the states of an object and the events and conditions that trigger a transition from one state to another
Steps Used in UML The steps used in UML are Define the use case model Define the object model Continue UML diagramming to model the system during the systems analysis phase Begin system design by refining UML diagrams and using them to derive classes and their properties and methods