Object-Oriented models are useful for : • understanding problems • communicating with application experts • modeling enterprises • preparing documentation
What is Procedure-Oriented Programming ? • Emphasis is on doing things (algorithms) • Large programs are divided into smaller programs (functions) • Most of the functions share global data • Data move openly around the system from fn.. to fn • Functions transforms data from one form to another • Employs top-down approach in program design
Relationship of data and functionsin Procedural Programming
What is Object-Oriented Programming ? • Emphasis is on data rather than procedure • Programs are divided into Objects (Abstracted into classes) • Data is encapsulated in the objects • Objects communicate with each other through functions • Follows bottom-up approach in program design.
Characteristics of Object-Oriented Model • Abstraction • Encapsulation • Polymorphism • Inheritance
Abstraction • Focus is an what an Object is and does before deciding how it should be implemented. • Use of abstraction preserves the freedom to make decisions as long as possible by avoiding premature commitments to details.
Encapsulation • Separates the external aspects of an object, which are accessible to other objects, from the internalimplementation details of the object. • Prevents a program from becoming so inter-dependent that a small change has massive ripple effects.
Polymorphism • The same operation may behave differently on different classes. • An operation is an action or transformation that an object performs or is subject to. • Example : 'move' operation may behave differently on the Window and Chess Piece Classes.
Inheritance • Is the sharing of attributes and operations among classes based on a hierarchical relationship. • The properties of a Superclass need not be repeated in the subclass. • Example : Scrolling Window and Fixed Window are subclasses of Superclass Window.
An Object Model • captures the static structure of the systemshows the objects, the relationship between them,and • the attributes and operations that characterize each class of objects.
Objects is a concept, abstraction, or thing with crisp boundaries and meaning for an application. Purpose promotes understanding of the real world provides a practical basis for computer information. Objects have identity and are distinguishable. Example : Two apples with the same color, shape and texture are still individual entities.
Classes It describes a group of objects, with common attributes, operations and semantics. Example : Fruit is a class. Objects in a class have the same attributes and behaviour patterns. A object's class is an implicit property of the object.
OBJECT DIAGRAMS • Object Diagrams provides a formal graphic notation for modeling objects, classes and their relationships to one another. • They are concise and easy to understand.
OBJECT DIAGRAMS OMT symbol for a class in a box. Person CLASS
ATTRIBUTES • is a property of the objects in a class • is a data value held by the objects in a class • different Object instances may have the same or different values for a given attribute.
ATTRIBUTES • Each attribute name is unique within a class. • An attribute should be a pure data value, not an object.
OPERATIONS • An operation is a function or transformation that may be applied to or by objects in a class. • Same operations may apply to many different classes (Polymorphic Operation).
Methods is the implementation of an operation for a class. Example : Operation 'Print' in class 'File' can be implemented for printing ASCII files, printing binary files are for printing digitized picture files.
Links and Associations A link is a physical or conceptual connection object instances i.e. represents the relationship between them. Example : Joe Smith works for Simplex Company
Links and Associations • An association describes a group of links with common structure and common semantics. • Example : A persons works for a company. • Association and links often appear as verbs in the problem statement.
Representation of Links / Associations Associations may be binary, ternary or higher order.
Representation of Links / Associations used to represent ternary and n-ary association.
Multiplicity of an Associations • Specifies how many instances of one class may to a single instance of an associated class. • Usually described as "one" or "many".
Multiplicity of an Associations In OMT notation, * Solid Ball => "many" meaning zero or more * Hollow ball => "optional" meaning zero or one * A line without balls => one-to- one association.
Link and Association Concepts Link Attribute is a property of the links in an association. In OMT notation, it is represented by a box attached to the association by a loop.
Link and Association Concepts Role Names * Role is one end of an association. * Role name is a name that uniquely identifies one end of an association.
Qualified Association Qualifier is a special attribute that reduces the effective multiplicity of an association. This reduces the effective multiplicity of this association from one-to-many to one-to-one.
Generalization • * Is the relationship between a class and one or more refined versions of it. • The class being refined is called the Super Class. • Each refined version is called the Sub Class. • Is also called the "is-a" relationship. In OMT notation, generalization is represented by a triangle connection a superclass to its subclass.
Inheritance • Each subclass is said to inherit the features of its superclass.
Inheritance • Each subclass not only inherits all the features of its ancestors but adds its own specific attributes and operations as well.
Inheritance A subclass may override a Superclass features by defining a feature with the same name.
Multiple Inheritance • A class may have more than one superclass and inherits features from all panels • Such a class is called a "Join Class".
Multiple Inheritance Example:
Generalization as Extension and Restriction Extension : When a subclass adds new features.
Generalization as Extension and Restriction Restriction : When a Subclass constrains the ancestor attributes. Example:
Generalization, Inheritance and Specialization Generalization and Inheritance: • Generalization is the relationship among classes. • Inheritance is the mechanism of sharing attributes and operations using the generalization relationship.
Generalization, Inheritance and Specialization Generalization and Specialization: • (Basically they are two different viewpoints of the same relationship) • Generalization => Superclass generalizes the subclass. • Specialization => Subclass refines or Specializes the Superclass.
Aggregation: • Is the "part-whole" or "a-part-of" relationship • Objects representing the components are associated with an object representing the entire assembly. • Aggregation is a special form of association.
Aggregation: In OMT notation, aggregation is represented by a small diamond at the assembly end of the relationship. Example:
Aggregation Versus Generalization • Aggregation relates instances • two distinct parts are involved, one is a part of • the other. • Generalization relates classes • Subclass inherits the properties of the • Superclass.
Aggregation Versus Generalization Aggregation and Generalization
ABSTRACT CLASSES • An abstract class is a class that has no direct • instances but whose descendent classes have direct • instances.
CONCRETE CLASSES A Concrete class is a class that is instantiable. Example:
META DATA • Is data that describes other data • Many real-world applications have metadata such as pats catalogs, blueprints and dictionaries.Example : The definition of a class is metadata.
META DATA • In RDBMS, a data table may store information such as capital of India is New Delhi. • Capital of Japan is Tokyo. And so on .…A meta table will store the fact that a • country has a Capital City.