Sie sind auf Seite 1von 7

Chapter 3 Object-Oriented Concept

To define the CIM models and manage them well, understand the concept of Object Orientation is an
important work since the MOF is based on the object-oriented concept. In this chapter we will introduce the
concept of object-orientation, class modeling with object-oriented, the critical concept in object-oriented
programming and finally, we will introduce how to use Rational Rose to design the model.
3.1 Basic Concept
Object-orientation is so called because this method sees things that are part of the real world as objects. A
phone is an object in the same way as a bicycle, a human being, or an insurance policy are objects. In everyday
life, we simplify objects in our thinking ² we work with models. Software development does essentially the
same: objects occurring in reality are reduced to a few features that are relevant in the current situation. Instead
of real objects, we work with symbols. Properties and composition of objects correspond only roughly to
reality; the model selects only those aspects that are useful for carrying out a specific task. In figure 3.1, we use
model to describe a reality that a teacher owns a bicycle and he reads a book.

c
Figure 3.1 Complex realities are made more manageable by abstract models.
3.1.1 Data Abstraction
Abstraction is the presentation of simple concept (or object) to the external world. Abstraction concept is
to describe a set of similar concrete entities. It focuses on the essential, inherent aspects of an entity and
ignoring its accidental properties. The abstraction concept is usually used during analysis: deciding only with
application-domain concepts, not making design and implementation decisions.
Two popular abstractions: procedure abstraction and data abstraction. Procedure abstraction is to
decompose problem to many simple sub-works. Data abstraction is to collect essential elements composing to a
compound data. These two abstractions have the same objective: reusable and replaceable. Figure 3.2 shows an
example of data abstraction to abstract doors as a data structure with essential properties.

Figure 3.2 Example of Data Abstraction.


3.1.2 Encapsulationc
Encapsulation means as much as shielding. Each object-oriented object has a shield around it. Objects
can't 'see' each other. They can exchange things though, as if they are interconnected through a hatch. Figure
3.3 shows the concept of the encapsulation. It separates the external aspects of an object from the internal
implementation details of the object, which are hidden from other objects. The object encapsulates both data
and the logical procedures required to manipulate the data.
Figure 3.3 Example of Encapsulation Concept.
3.2 Class Modeling
3.2.1 Class and Object Instance
A class is used to describe something in the world, such as occurrences, things, external entities, roles,
organization units, places or structures. A class describes the structure and behavior of a set of similar objects.
It is often described as a template, generalized description, pattern or blueprint for an object, as opposed to the
actual object, itself. Once a class of items is defined, a specific instance of the class can be defined. An instance
is also called´object.µ Figure 3.4 shows an example of teacher class and its object in UML notation.
The following table gives some examples of classes and objects

 c c
c  c c
c  c
Occurrence Alarm Fire alarm
Things Car Ferrari 360
External entities Door Fire door
Roles Teacher John, Nick
Organizational units IECS department FCU_IECS,

Figure 3.4 Class and Object.


3.2.2 Property and Method
ð   in a class are used to present the structure of the objects: their components and the
information or data contained therein. (e.g., name, owner, ground clearance).An instance of a class has the
properties defined in its class and all of the classes from which its class inherits. In figure 3.5, name, weight
and breed are three properties of the class Dog.
  in a class describe the behavior of the objects. It represents a function that an instance of the
class can be asked to perform. In the figure 3.5, a Dog class defines three methods: sit, beg and run which
indicate the behavior a dog can have.

Figure 3.5 An example of a Dog Class


3.2.3 Association
An association is a relationship between different objects of one more classes. A simple example of an
association is the relationship among an enterprise, departments and employees showed in figure 3.6.
Figure 3.6 Associations
2   c
In the simple case, an association is represented by a single line between two classes. Usually, however,
associations are shown in as much detail as possible. Then, the association receives a name and a numerical
specification (
   indication) of how many objects on one side of the association are connected with
how many objects on the other side. In the Figure 3.6 shows an example of association with multiplicity.
Common 
  are:

0..1 No instance, or one instance


1 Exactly one instance
0..*, * Zero or more instances
1..* One or more instances

   
Aggregation is a special form of association. Aggregation is the composition of an object out of a set of
parts. A car, for example, is an aggregation of tires, engine, steering wheel, brakes and so on. These parts may in
turn be aggregations: a brake consists of disk, pads, hydraulic, etc. Aggregation represents a ´hasµ relationship:
a car  an engine. Instead of aggregation, some people talk about ´   hierarchy. For example, in figure
3.7, where an Enterprise represents a ´wholeµ end and Department represents a ´partµ end.

Figure 3.7 Aggregation


Inheritance
Inheritance is the property whereby one class extends another class by including additional methods
and/or variables. The original class is called the superclass of the extending class, and the extending class is
called the subclass of the class that is extended. Since a subclass contains all of the data and methods of the
superclass plus additional resources, it is more specific. Conversely, since the superclass lacks some of the
resources of the subclass, it is more general or abstract, than its subclasses. Figure 3.8 shows an example, where
  and    inherit from 
 and own all attributes and methods from 
.

Figure 3.8 Inheritance


3.3 Object-oriented Programming
3.3.1 Interface
Interface classes are abstract definitions of purely functional interfaces. They DO NOT define any
attributes or associations. An interface can not instantiate any object instances. They only define a set of
abstract operations. They often define pre-conditions, post-conditions, invariants and possible exceptions for
these operations. Figure 3.9 is an example the ï  class implements the interface ï  . Note that
  in
the interface ï   do not have method implemented, but ï  must have its implementation on 
 
since it is defined to implement ï  .

Figure 3.9 Interface


3.3.2 Event and Listener
Event and Listener is an important part using in CIM modeling. An event listener is an object to which a
component has delegated the task of handling a particular kind of event. In other words, if you want an object
in your program to respond to another object which is generating events, you must register your object with
the event generating object, and then handle the generated events when the come. A typical example is the
   shows in figure 3.10. !"
 is a kind of event source component. When the event is activated, it
will notify    to handle it. The #$  is a   responsible for the event.

Figure 3.10 ActionListener


3.3.3 Object Communication
Communication between objects is achieved by exchanging messages (Figure 3.11). These messages lead to
the operations, which means that an object understands precisely those messages for which it has operations.

Figure 3.11 Message Exchange in Classes


3.3.4 Polymorphism
Polymorphism indicates the meaning of ´many form.µ In object-oriented design, polymorphism present a
method can has many definitions (forms). Polymorphism is related to %#   and %#  . Overloading
indicates a method can have different definitions by defining different type of parameter, for example
ð  &# 
  ï &# 
ð   has two different forms ² is the same meaning of different definitions. Overriding indicates that
subclass and parentclass have the same methods, parameters and return types (namely to redefine the methods
in parentclass). In figure 3.12,  ï  method has three definitions, distribute in subclass and parentclass.
Document object claims Encryption object to assist ecryption. In its  ï  method, it doesn·t indicate
ï  or ' is the encryption actor, just only send a message to  object:
 ï  (

)* 
+
,
ù

Figure 3.12 Polymorphism


3.4 Unified Modeling Language
The Unified Modeling Language was originally developed at Rational Software but is now administered
by the Object Management Group (see link). It is a modeling syntax aimed primarily at creating models of
software-based systems, but can be used in a number of areas. It is:
l ï c  - UML is just a language, it tells you what model elements and diagrams are available and the
rules associated with them. It doesn't tell you what diagrams to create.
l    - it can be used to model anything. It is designed to be user extended to fill any modeling
requirement.
l   c - it doesn't matter what hi-level language is to be used in the code. Mapping into
code is a matter for the case tool you use.
l   c - the process by which the models are created is separate from the definition of the
language. You will need a process in addition to the use of UML itself.
l  c - UML leaves plenty of space for tool vendors to be creative and add value to visual
modeling with UML. However, some tools will be better than others for particular applications.
l c  - the UML notation guide is available as a reference to all the syntax available in the
language.
l  c  c c c c    - the UML notation guide is not sufficient to teach you how to
use the language. It is a generic modeling language and needs to be adapted by the user to particular
applications.
l   c c
c c  - some user defined extensions are becoming more widely used now,
for example for business modeling and modeling the design of web-based applications.c
In brief, UML is a standard modeling language from system analysis, system design to implementation.
 cc2c   c!ccï 
Notation Name Description
Class A class describes the
structure and behavior of a
set of similar objects.
Object An instance of a class

Association A relationship between


different objects of one more
classes
Inheritance One class extends another
class

Interface Abstract definitions of


purely functional interfaces

Interface Implement the functions


Implementation defined in interface
Aggregation Aggregation is the
composition of an object out
of a set of parts.
V Others refer to UML Spec.

3.5 Modeling tool - introduction to Rational Rose


There are many tools that support UML modeling. Here we take    to introduce these basic
modeling concepts.
3.5.1 Rational Rose
Rational Rose is a program that allows you to build models based on the Unified Modeling Language or
more commonly known as the UML. You are able to create three diagrams in Rational Rose, the use-case
diagram, the sequence diagram, and the class diagram. Here we simple introduce the class diagram part. The
class diagram describes the types of objects in the program and how they are related to each other.
Before we start modeling, it is important that we know the important features of the main window. If you
look to the far left you will see a side panel as shown in Figure 3.13. The Use Case View is where you will see all
the use cases that you will make. Along with the use cases you will see any actors used in your use case
diagrams and the different associations created between the use case and the actor. The Logical View is where
you will build your class diagram and your sequence diagrams. Inside here as well you will see the different
classes you created and the associations that exist between them.

Figure 3.13 Side panel


Beside the side menu you will see a very important toolbox. This toolbox allows you to create many of the
different elements that you will use in your diagrams. Figure 3.14 shows some of the most important elements.

Figure 3.14 Notations


Now I am going to teach you how to model in class diagram. When you think of UML diagrams, class diagrams
are typically the ones that come to mind. Figure 3.15 shows a simple example of a class diagram with three
classes named VideoStore, Database, and Video.
Figure 3.15 Example of class diagram
When creating a class diagram the first thing that you need to do is create the class diagram window. To do
this:
l Right click on Logical View shown on the side bar
l Go to new and Class Diagram
l Type in the name of the class diagram
l Double click on the name you just typed to bring the window up.
Now that you have your window ready, lets create our first class.
l On the toolbox click the fifth button from the top. Refer to Figure 3.14
l Now just drag where you want your class to be in the window.
Now that you have a class lets put some attributes and operations into it. When you double click on the class
that you just created a box will pop up like in figure 3.16 this is where you will be editing your class. Here you
can do many things including changing the name of the class and adding attributes and operations.

Figure 3.16 Property editor


Now you should see a box like in Figure 3.16. To add operations:
l Click on the tab that reads ´operationsµ
l Right click anywhere on the white part and select insert
l Type in the name of the operation and then hit enter
If you double click on the operation you created another box will pop up that allows you to customize the
operation. Things you can customize includes adding parameters and return types. To create an attribute click
on the attribute tab and follow the same procedure
Once you create your class you can make another class in the same fashion, and connect the two classes
with an association. To see how to connect using an association, refer back to the Use Case Diagram section.
3.5.2 Other Modeling tools
Except the Ration Rose, there are still many other UML modeling tools, such as ArgoUML, Borland Together,
Rational XDE, Eclipse, Power Designer, Visual Paradigm for UML, MagicDraw and so on.
3.6 Summary
According to the introduction we describe above, you can more understand the concept of Object-Orientation
and UML. Then, at the same time, you will know how to use the UML modeling tool ² Rational Rose here we
introduced to model the complexity realities.

Das könnte Ihnen auch gefallen