Académique Documents
Professionnel Documents
Culture Documents
Thus, C++ supports styles of programming that rely on fairly direct manipulation of hardware
resources to deliver a high degree of efficiency plus higher-level styles of programming that rely
on user-defined types to provide a model of data and computation that is closer to a humans
view of the task being performed by a computer. These higher-level styles of programming are
often called data abstraction, object-oriented programming, and generic programming.
A way of viewing world agents:In an object oriented programming every world agent are objects i.e OOP uses an
approach of treating a real world agent as an object. Object oriented
programming organizes a program around its data( that is , objects) and a set of
well defined interface to that data.
Consider an example sending flowers to the friend the friend who lives in different
city. But I cant deliver them myself. So I use my locat florist. I tell my
florist(named ram) the address for my friend. How much I want to spend and the
type of flowers, I wish to send . ram contacts a florist in my friends city. Who
arranges the flowers, then contacts a driver, who delivers the flowers. If we start to
think about it, there may even be other people involved in this transaction. There
is the flower grower, perhaps somebody in charge of arrangements, and so on.
Here in this work, every people involved are the objects (I.e myself, my friend, the
florist, the florist in my friends city, the driver, the flower arranger, and the
grower). Each agent has a part to play , and the result is produced when all work
together in the solution of a problem.
Computation as Simulation
The oop view of computation is similar to creating a universe of interacting
computing objects. It is also very similar to a style of simulation called discrete
event driven simulation. In discrete event driven simulation the user creates
computer models of the various elements of the simulation, describes how they
will interact with one another and sets them moving. This is almost identical to the
object oriented program, in which the user describes what the various entities in
the universe for the programs are and how they will interact with one another, and
finally sets them in motion. Thus in object oriented programming the computation
is simulation.
Similarly, a key step along the path to developing complex computer systems will
be the division of a task into component parts. These parts can then be developed
by different members of a team. Each component will have two faces: the interface
that it show to the outside world and an implementation that it uses to fulfill the
requirements of the interface.
The division between interface and implementation not only makes it easier to
understand a design at a high level but also makes it.d
Abstraction Mechanisms
Abstraction denotes the essential characteristic of an object the distinguishes it
from all other kinds of object and provides conceptual boundaries, relative to the
perspective view of the user.
Focuses on the outside view of an object and serve to separate an objects behavior
from its implementation.
Focuses upon the essential characteristic of some object , relative to the perspective
of the viewer.
The difference between the development of individual projects and of more sizable
software system is often described as programming in the small versus
programming in the large.
An interface may contain other interfaces and add new operations. An object
whose type is given by the expanded interface supports the union of the operations
of the contained interfaces and the new operations. An object supporting the
expanded interface may be accessed by code expecting an object supporting one of
the contained interfaces. If an interface is defined by combining multiple
interfaces, an interface lattice results.
Software reusability:When behavior is inherited from another class, the code that provides that behavior
does not have to be rewritten. This may seem obvious, but the implementations are
important. Many programmers spend much of their time rewriting code, they have
written many times before- for example, to search for a pattern in a string or to
insert a new element into a table. With object oriented techniques, these functions
can be written once reused.
Other benefits of reusable code include increased reliability and the decreased
maintenance cost because of sharing by all users of the code.
CRC CARD
A CRC Card is an index card that is use to represent the responsibilities of classes
and the interaction between the lasses. CRC cards are an informal approach to
object oriented modeling. The cards are created through scenarios, based on the
system requirement that model the requirement of the system.
CRC(class responsibility- collaborator) card modeling is a simple but yet powerful
object oriented analysis technique. Crc modeling often includes the user analysts,
and developers in a modeling and design process, bringing together the entire
development team to form a common understanding of an object oriented
development project. It is one of many tools that should be used in the
collaborative design of a system.
Responsibility
Collaborator
Class
Component
Responsibility
collaborator
The back of the crc card is often used for a model detailed description of the class
along with any other notes captured during the CRC session. Much time these
include the actual attributes of the class.
to complete a step in a scenario. The collaborator of a class appears along the right
side of the crc card.
}
It is key point to note that you can easily identify the IS-A relationship. Wherever
you seen an extends keyword or implements keyword in a class declaration, then
this class is said to have IS-A relationship.
HAS-A relationship:Composition(HAS-A) simply mean use of instance variables that are references to
other objects. As the name suggests A has a member variable of type B. A is not a
specialization of B and thus does not inherit anything from B. the corresponding
example:
Class B
{
};
Class A{
B b;
};
As you can see class A does not have to show the same behaviour as B. this means
that A does not have to respond to the same messages as B. i.e A does not have to
have the same methods as B. they can be completely different or partially
overlapping.
Lets understand these concepts with example or car class.