Basic Concepts of Object Orientation
- Object
- Class
- Attribute
- Operation (Method)
- Interface
- Polymorphism
- Component
- Relationship
What is an Object?
An Object represents an entity either physical (box), conceptual (chemical
process), or software (list).
An Object is a concept, an abstraction, a thing with sharp boundaries and
meaning for an application. It has
- Identity - a name
- State - determined by the values of its attributes
- Behavior - determined by how the object acts or reacts to requests
(messages) from other objects
An Object is represented as a rectangle with a underlined name in UML.
What is a Class?
A Class is a description of a group of objects with common properties
(attributes), behavior (operations), relationships, and semantics
A class is an abstraction. An object is an instance of a class.
Example of a Class
- Class: Course
- Properties: Name, Location, Days Offered, Credit Hours, Professor
- Behavior: Add Student, Delete Student, Get Course Roster, Determine If Full
A class is represented by a compartmentalized rectangle in UML. It has three
sections - Name, Attributes, and Operations. You can show as many or as
few of the Attributes and Operations in the diagram. Most of the times
for the sake of clarity the Attribute and Operation lists are suppressed.
You start from real world objects - abstract out what you do not care and
go through the process of classification of what you care. A Class is the
result of this classification. Classes are then used as templates within
a software system to create software objects.
What is an Attribute?
An Attribute is a named property of a class. It has a type. It describes
the range of values that that property may hold.
What is an Operation (Method)?
An Operation is a service that can be requested from any object of the
Class to affect behavior. An Operation can either be a command or a
question. A question should never change the state of the object only a
command can. The outcome of the Operation depends on the current state
of the object.
What is an Interface?
An Interface is a collection of operations that are used to specify a service
provided by a class or component. It represents a contract with the user. In
UML an Interface is represented either by a "lollipop" or by a rectangle with
the word "interface" above the name of the Interface.
What is Polymorphism?
The Greek term polymorphous means "having many forms". Interfaces allow us to
define polymorphism in a declarative way. Two elements (classes) are polymorphic
with respect to a set of behaviors if they realize the same Interface. Interfaces
allow us to build a "plug-and-play" architecture. Classes that realize the
same Interface may be substituted for one another in the system, thereby
changing the implementation without affecting the User.
What is a Component?
A component is a physical and replaceable part of a system that conforms
to and provides the realization of a set of interfaces. Software
components include: Source code components (.java files, data files), Binary code
components (Java Beans, COM objects, DLLS), Executable components (.exe's).
A Package is a general purpose mechanism for organizing elements into
semantically related groups. A Package owns its elements. An element cannot
be owned by more than one package. In UML a Package is represented as a tabbed folder.
A Subsystem is a combination of a package and a class. It realizes one
or more interfaces which define its behavior.
What are the various Relationships?
- Dependency
- Association
- Generalization
- Realization
Dependency is a semantic relationship between two things in which a change
to one thing (independent thing) may affect the semantics of the other
(dependent thing). This is a non-structural, "uses" type relationship as in
Class Window uses Class Event. A change in Event (say a mouse click or key stroke)
causes a change in Window but not vice versa. In UML Dependency relationship
is denoted by a dashed line.
Association is a structural relationship between objects. The association
may have a name. Professor "works for" University. Each end of the
association has a role - Professor (employee) and University (employer).
An Association is represented by a solid line in UML.
Multiplicity defines how many objects participate in a relationship. For
each role you can specify the multiplicity of its class - how many objects
of the class can be associated with an object of the other class.
Aggregation is a relationship between a whole and its parts.
An object physically contains other objects - Car is physically composed
of an Engine and four Wheels. A Family is a collection of Parents and
Children. It is represented in UML as a solid line with an open diamond.
Composition is a form of aggregation with strong ownership and coincident
lifetimes of the part with the aggregate. The whole "owns" the part and
is responsible for the creation and destruction of the part. Student and
schedule. It is represented as a solid line with a filled diamond in UML.
Generalization is a relationship among classes where one class shares the
structure and behavior of one or more classes. Generalization defines a
hierarchy of abstractions in which a subclass inherits from one or more
superclass. Generalization is an "is-a-kind of" relationship.
A subclass inherits its parent's attributes, operations, and relationships.
A subclass may add additional attributes, operations, relationships. It may
also redefine inherited operations (use caution here!). This relationship is
represented as an open arrow going from the subclass to its parent(s) in UML.
A subclass may be used anywhere the superclass is used, but not vice versa.
Generalization is the name of the relationship. Inheritance is the mechanism
that the generalization relationship represents.
Realization is the relationship between one class that serves as the contract
that the other class agrees to carry out. (The interface and the class that
implements the interface). It is represented as a dashed line and an arrow in
UML.
Strengths of Object Orientation
- Facilitates code reuse
- Models more closely reflect the real world
- Promotes Stability - easier to understand and maintain. Small change in
requirements does not mean massive changes in the system under development.
What is UML?
Unified Modeling Language is a language for specifying, visualizing,
constructing, and documenting a software intensive system.
What is a Software Process?
A software process defines WHO is doing WHAT, WHEN and HOW to reach a certain goal
which could be to build a new software product or enhance an existing one.
The Rational Unified Process (RUP) is a generic process that uses UML as a
modeling language.
An actor is someone or something outside the system that interacts with
the system.
A use-case is a sequence of actions a system performs that yields an
observable result of value to a particular actor.
What are the different views of Software Architecture?
- Use-case view - End user - Functionality
- Logical View - Analysts/Designers - Structure
- Implementation View - Programmers - Software management
- Process View - System Integrators - Performance, Scalability, Throughput
- Deployment View - System Engineering - System topology, installation,
communication
What are the Lifecycle Phase in the development of Software?
- Inception - define the scope of the project
- Elaboration - Plan project, specify features
- Construction - Build the product
- Transition - Transition the product into the end user community
Within each phase there is a series of iterations. Each iteration results
in a release encompassing larger and larger subsets of the final
application
In our development process for this class we will take the following path
- Uses Cases
- Class Diagram
- Source Code
- Executable
Who is an actor?
An actor is someone or something outside the system that interacts with the
system. An actor can be a human being or another system or a device. An actor
is represented by a stick figure in UML.
What is a Use-Case?
A Use-Case is a sequence of actions a system performs that yields an observable
result of value to a particular actor. A Use-Case describes functionality of the
system from the user's point of view. A Use-Case is represented by an oval in UML.