CIS-75 Home http://www.c-jump.com/CIS75/CIS75syllabus.htm
Basic Concepts:
Abstraction
Encapsulation and information Hiding
Modularity
Separating properties of an entity...
...which are relevant...
...in the context of the problem domain(*)...
...from other properties of the entity.
Abstraction optimizes the information needed to represent an entity
in attempt to solve a specific problem.
Abstraction represents a view of the entity consistent with the needs of the domain.
________________
(*) Domain is an area of expertise describing a group or a class of problems.
Consider an all-purpose concept of a book in library domain...
For example, consider different views of a book by
a reader (library customer)
an author (also a customer?)
a printer (a device)
a publisher (an organization)
a recycler (an organization)
Abstraction is a necessary condition of any problem solving process.
Abstraction identifies similarities among entities in terms of
structure
operations
behavior.
Lack of abstraction would result in: total diversification, total chaos (of thoughts), insanity.
Encapsulation means concealing characteristics of an entity
from the world that has no need for these characteristics.
Entities can be perceived either through their
specification ( from outside )
implementation ( from inside ).
Encapsulation should be enforced by entities themselves, rather than
by the policies in the environment in which the entities operate...
...Entities are given the priority in terms of how they want to be organized internally.
Modules are defined as highly cohesive parts of the system.
Modules are loosely coupled with other modules.
Modules interact with other modules through their interfaces.
A concept, an abstraction, or a thing with
crisp logical boundaries at design time
distinct per-instance memory allocation at run-time
file-level physical boundaries.
Object is an entity with a
state,
behavior,
identity,
persistence.
State of an object is defined by
static properties (attributes) and
dynamic current values of these properties.
Object changes its state by changing the values of a fixed set of properties.
The properties are defined by the class of the object.
Object behavior is determined by
actions and
reactions
of the object.
The behavior is revealed in its state changes, which occur in response to
incoming messages and
messages sent to other objects.
Objects can perform operations on behalf of other objects.
The operations are invoked by messages received from other objects.
Objects may require operations from other objects by sending them messages.
Identity is defined by the set of characteristics that distinguish particular object instance
from other objects of the same type.
Name of the object is not equivalent to its identity.
(The names are involved in mechanisms of overloading/aliasing, names can be re-defined in nested scopes... among other things specific to a particular programming language.)
The most common incarnations of object's identity are:
reference to the object instance in memory
set of unique values of primary keys
message digest (authenticator).
(Obtained by calling a deterministic procedure (often a cryptographic hash function) that takes an arbitrary block of data and returns a (presumably unique) fixed-size bit string, known as the hash value, or digest.)
// Integer object accessible through "count": int count; // An object of class "Account" accessible through "acct": Account acct = new Account();
Class represents the common
structure and
behavior
of a group of objects.
Class implements an abstract data type.
Objects are instances of their classes.
Objects obtain their attributes and operations from classes.
Objects are instances of the same class.
Objects have individual storage for data values (the state).
Objects share
the data layout, and
behavior.
Object-oriented software system (an architecture) is a...
...collection of classes...
...connected by relationships.
public class Account { private float balance; // property public float withdraw( float amount ) // operation { if ( amount >= balance ) { balance = balance - amount; return amount; } else { return 0.0; } }//withdraw }//class Account
public class Stack { // Operations public Stack() { storage = new double[100]; top = 0; } public Stack(int size) { storage = new double[size]; top = 0; } public void clear() { top = 0; } public void push( double dbl) { storage[top++] = dbl; } public double pop() { return storage[--top]; } public boolean full() { return top == storage.length; } public boolean empty() { return ( top == 0 ); } // Data members: private double storage[ ]; private int top; }//class Stack
public class Stack { // Constructors initialize the data members of the object: public Stack( ) // default constructor { storage = new double[ 100 ]; top = 0; } public Stack( int size) { storage = new double[ size ]; top = 0; } // data members private double storage[ ]; private int top; }//class Stack
public class User { public void any_method( ) { Stack st1; Stack st2; st1 = new Stack( ); // st1 has capacity of 100 st2 = new Stack( 200 ); // st2 has capacity of 200 }//any_method }//class User
Attribute whose value is common to all objects of the class
is considered to be an attribute of the class.
Class attribute represents a value that is global within all objects of that class.
Class attributes are defined as static data members.
Method that accesses only its local parameters and class attributes
is considered to be a method of the class.
Class methods are defined as static member functions.
public class SavingsAccount { private float balance; private static float minBalance; private boolean overdrawn; public void deposit( float amount) { balance += amount;} // Static method can only access // static members of of its class: public static void changeMinBalance( float newMin ) { minBalance = newMin; }//changeMinBalance }//class SavingsAccount
public class SavingsAccount { // Non-static method can access both // static and non-static members of its class: public float withdrawal( float amount ) { if ( balance > amount ) { if ( balance - amount < minBalance ) { overdrawn = true; } balance -= amount; return amount; } else { return 0.0; } }//withdrawal }//class SavingsAccount
|
|
Each problem domain consists of autonomous objects.
Autonomous objects exist in space and in time and interact with one another.
Interactions are operations invoked by objects on each other's behalf.
There are patterns (regularities) in the
structure and
behavior
of objects.
Behavior of objects, their structure, relationships, and interactions can be modeled...
...solutions to problems can be found using the model.
Object-oriented software system...
Is easier to understand and maintain.
Provides a clear mapping between objects of the problem domain (real world objects ).
Supports reuse of objects in the model.
Note inheritance reduces redundancy.
Model, design, and implementation consist of interacting objects.
Objects are autonomous and have their own state and behavior.
Objects encapsulate state and algorithms.
The algorithms are encapsulated in methods.
Model, design, and implementation consist of interacting functions.
Functions share centralized state, known as global.
Function local state does not survive their execution.
Functions encapsulate algorithms.
Global state is not encapsulated.
Functions can cause side effects, that is, functions impact other functions
by changing the global state.
Inheritance.
Polymorphism.
No free agent (global) variables...
...The only variables allowed are the data members of the classes.
No free agent (global) functions...
...The only functions are the methods of the classes.
A
promoting theory and practice of object technology
in distributed computing systems.
OMG aims to
reduce the complexity,
lower the cost, and
accelerate the introduction of new software applications.
OMG realizes its goals through creating standards.
The standards allow interoperability and portability of distributed object-oriented applications.
See also: