Unit-1
Introduction
Object oriented analysis and design is an approach for analyzing the problem and designing the solution for the system or application or business using object oriented concepts and visual model throughout its development.
Object Orientation
Object orientation means the system under development is organized as a collection of objects. The system is designed in terms of objects and their relationship. Here the object is the discrete unit which is bound with data and its functions. There are many characteristics associated with object oriented approach, few are mentioned below
● Identity: identifying and recognizing objects that form the system. The object may be conceptual or physical objects. Physical objects are those objects which exist physically such as file, keys in the keyboard etc. whereas scheduling policies in an operating system can be considered as an example of conceptual objects. Objects are always unique in their own way hence they possess a unique identity.
● Classification: grouping together the object which has the same data and functions. For example, triangle, rectangle, square these objects are classified as shapes. We can say that shape is the classification for different objects as mentioned above. These objects have common data as no of edges, vertices etc. whereas they can have common functions to draw, move etc.
● Polymorphism: it is one of the object oriented concepts where one function behaves differently depending on the type of object. For example, if we call function draw, it may draw a rectangle, triangle or square depending on the type of instance we are passing to it.
● Inheritance: it is sharing of data and function with another class if they are hierarchically related to each other. The data and function of one class can be inherited into another class. Inheritance helps in reusability of the data and function and saves time. There are different types of inheritance in which the data and functions are shared.
Object Oriented Development
Object oriented development is conceptual processes of developing the software using object oriented analysis, design and implementation. In object oriented development the software developer identifies and organizes the system in terms of the object oriented concepts independent of the programming language for implementation.
The main phases of object oriented development using object oriented approach are mentioned below
1) Object oriented Analysis
2) Object oriented Design
3) Implementation
● Object Oriented Analysis:
In this phase, the problem statement is analyzed. The requirement from the user is gathered. Depending upon this information, different models are built by identifying the objects. The models show how the desired system is expected to work and how it must be developed. The models are visual aids which help the developer to understand the system.
In object oriented analysis, following tasks are done
● Prompt requirement: identify and elaborate what does the system need to do
● Specify the requirement: describe the information in terms of use cases or scenarios.
● Conceptual model: recognize the necessary objects, refine them and identify the relationships and behavior of the objects. Draw them in terms of different diagrams.
● Object Oriented Design:
The analysis model gets more refined in the design phase. In this phase the objects, their attributes and the operations are described in more detail. The design model must include all the details into it so that the programmer can implement it easily. The conceptual model is converted into a design model. The output of analysis is used as input in developing different design models. There
are two main stages defined under object oriented design as system design and object design.
In system design the system designer designs the system architecture. There are multiple tasks which are done in system design such as estimating the system performance, breaking the system into subsystems, modelling interaction among the objects and classes.
In object design, design model is developed depending upon the system architecture and the models developed during analysis phase. Implementation decisions are taken in this phase. All the required classes are identified, association between the identified classes are established.
● Implementation:
In this phase the design model is implemented using appropriate programming language. Databases are created and specific hardware requirement is ascertained.
Object Oriented Theme
There are many object oriented themes, few as mentioned below
1) Abstraction
2) Encapsulation
3) Sharing
4) Combining Data and behavior
5) Synergy
6) Emphasis on essence of an object
● Abstraction: It is one of the important concepts of object oriented development. It mainly focuses on what the object does irrespective of the task and how it will be done. For example, to change the TV channel, we just need to know which button of the remote control to press irrespective of how the channel gets changed by pressing the button on the remote control.
If we describe this in terms of object, which has remote control attributes as buttons and methods to change the channel. Remote control object is used to call the method to change the channel and channel gets changed as implementation of this method. So the concept of abstraction just focuses on calling of the method by the object and not how the method gets implemented.
● Encapsulation: It is also one of the important concepts of object oriented development. It is also called data hiding or information hiding. As per the OOP concept it binds the data and functions that access it together and prevent interference from external objects. Any attribute can be made hidden from other objects but access to such an attribute or variable can be done through methods or functions of the same class.
● Sharing: In object oriented development sharing of the data and functions is done through inheritance. The subclasses reuse the data and functions defined in parent class. Sharing prevents redundancy of the data and functions.
● Combining Data and behavior: In this OO concept, the data structure hierarchy matches with the procedure hierarchy forming a class hierarchy in OO approach. The caller of the function should not consider the level of implementations.
● Synergy: There are many OO concepts like classification, inheritance and polymorphism etc., these concepts when implemented individually work well but all complement each other synergistically.
● Emphasis on essence of an object: The object t Oriented development emphasizes mostly on the object of the classes i.e. object oriented approach rather than the procedure oriented approach.
Key takeaway:
● Object oriented analysis and design is an approach for analyzing the problem and designing the solution for the system or application.
● Object orientation means the system under development is organized as a collection of objects.
● Object oriented development is conceptual processes of developing the software using object oriented analysis, design and implementation.
In OOPS data is more important and it is treated as a critical element. OOP focuses mainly on data rather than the procedure. With the help of OOP concept, the problem is broken into simpler and smaller modules. OOPs provide data encapsulation that protects the access to data by data hiding.
OOPS help in modelling real world problems. OOPS makes the program modular hence understanding the program is easier as well as the maintenance is also easier. The basic advantage of having OOPS concept is code reusability. Using inheritance concept, we don’t need to write the code again while using the same class.
OOPS makes the task of writing the code, handling the code and maintaining the code easier.
Object Modeling Technique (OMT) was introduced by James Rambaugh. It is a Technique used in object oriented development of software projects. As the name suggests it supports object oriented programming. This technique is used in software design and modelling. OMT methodology is used in describing the methods for system analysis, design and implementation using object oriented
technique. It is an easy and fast way of modelling the objects.
OMT describes 3 different perspectives of the system through which a system can be visualized. It has 3 models which captures the static, dynamic and functional aspect of the system as mentioned below
1) Object Model- describes the structural aspect of the system
2) Dynamic Model- describes the behavioural aspect of the system
3) Functional Model-describes the functional aspect of the system
Object Model: it is used to identify the discrete objects in the system and to identify the relationship among them. All the objects are treated as static units which form the system and their behaviour is totally ignored. This model is static in nature. It divides the system in discrete objects and associate’s attributes and functions to the object. An object consists of the object name, its attributes and the functions it performs. This model also shows different objects are related to each other i.e. the relationship among the objects is also shown by the object model.
To graphically represent object model class diagrams and object diagrams are used. The class diagram uses the concept of class and establishes association between two classes whereas an object from one class can be associated with an object of another class using a link.
The concept of class and object described below
Class
● A class is the description for a set of objects having the same attribute, operations, relationship & behavior.
● A class describes the structure of an object.
● A class is a general classifier.
● All objects which belong to the same class have the same set of attributes, operations & relationships.
● a relationship between a class & objects is an << instantiate››
● The UML notation for class is as shown below
Name of the Class |
Attributes |
Operations |
ClassName |
Attribute - name1 : data-type1 = default-val1 Attribute - name2 : data-type2 = default-val2 |
Operation-name1(arguments 1): result-type1 Operation-name2(arguments 2): result-type2 |
1) Name component
● The top component of the class rectangle is the name compartment.
● The class name is written in UpperCamelCase at the center of the compartment.
● While giving names to the class one should avoid short forms, special symbols.
● names should always reflect the real world; entities should be simple & easily understood.
● The name of the class should have a name that is a noun or noun phase.
● Ex Customer ,Bank, Account, User etc.
2) Attribute:
● Attribute compartment is mandatory to include the attributes.
● attributes are written in lowercase letters.
● They are noun or noun phrases.
● the syntax for attributes is as follow
Visibility name: type[multiplicity] =initial value
Visibility
It is applied to attributes & operations of a class.
Visibility can be shown below.
Sign | Visibility name | Meaning |
+ | Public | The element that can access the class can access all the attributes of that class. |
- | Private | the attribute can be accessed by the function of the same class. |
# | Protected | The attribute can be accessed only by the functions from the same class and children class. |
~ | Package | any element that is in the same package as class or in a nested subpackage can access the attributes. |
Type
The type of attribute may be primitive type or other class.
UML specifies the following 4 primitive types.
|
Fig 1: UML primitives types
Multiplicity
It is defined as the no of things that participate in a relationship. It allows model collection or null values.
Collections:
If array : array [10] would model an attribute array that is a collection of 10 elements.
Null values: there is a difference between attributes that contain an empty or uninitialized object.
StudentDetails |
-name: String[2..*] -address: String[3] -emailId: String[0..1] |
initial value
Initial value is that value, the attribute takes when the object is created.
The value the attribute takes as soon as it is initiated from class.
3) Operations
● These are the functions of a class.
● The syntax of the operation as follows.
Visibility name (direction parameter name: parameter type=default value):return type
● operations are named in lowerCamelCase.
● operations names are verb or non phrases.
direction parameter name: parameter type = default value
Fig 2: example of classes
The above example shows how two classes are associated with each other. Name of the class are Employee and Company, where name, ID and Basic Pay of the employee are the attributes of employee and getsalary and mark attendance are the functions of employee class . the attributes and functions of the class Company are also shown above.
Object Diagram of the same is shown below
Fig 3: object diagram
Dynamic Model: it represents the behavioral aspect of the system. It shows object behavior with respect to certain events occurring in the system. Dynamic model can be graphically represented with the help of a state diagram that shows the change in state of the object due to occurrence of certain events that are transitioning from one state to another due to occurrence of event.
Functional Model: It shows the processing or functional aspect of the object oriented analysis model. It gives an overview of the functions of the system, flow of data across the system and data storage It captures what functions performed by the internal processes of the system on the data and not how they are derived. This can be shown with the help of the Data Flow Diagram (DFD).
Phases of Object Modeling Technique
Object Modeling Technique has the following phases:
1) Analysis:
It is the first phase of OMT. In this phase the requirement from the user of the system is collected. All the information gathered will then be analyzed to derive a problem statement. Depending on the problem statement different models like object model, dynamic model and functional model will be developed.
2) System Design:
It is the second phase of the object modeling technique and it comes after the analysis phase. It determines all system architecture, concurrent tasks and data storage. High level architecture of the system is designed during this phase.
3) Object Design:
Object design is the third phase of the object modelling technique and after system design is over, this phase comes. Object design phase is concerned with classification of objects into different classes and about attributes and necessary operations needed. Different issues related with generalization and aggregations are checked.
4) Implementation:
This is the last phase of the object modeling technique. It is all about converting prepared design into the software. Design phase is translated into the Implementation phase.
Key takeaway:
● Object Modeling Technique (OMT) was introduced by James Rambaugh.
● It is a Technique used in object oriented development of software projects.
● OMT methodology is used in describing the methods for system analysis, design and implementation using object oriented techniques.
● It is an easy and fast way of modelling the objects.
In an object-oriented setting that may have a physical or a conceptual nature, an object is a real-world element. Every object has a −
● Identity in the system which distinguishes it from other objects.
● The condition in which the characteristic properties of an object are defined as well as the values of the properties retained by the object.
● Behavior that describes an object's externally observable operations in terms of changes in its state.
Objects can be modelled according to the application's needs. An object, such as a consumer, a vehicle, etc., may have a physical existence or an intangible conceptual existence, such as a project, a procedure, etc.
Key takeaway :
● An object is a real-world element in an object–oriented environment.
● Objects can be modelled according to the application's needs.
A class represents a group of objects exhibiting similar actions with the same characteristic properties. It provides a blueprint or definition of the objects from which it can be produced. As a member of a class, the creation of an entity is called instantiation. Thus, an example of a class is an entity.
A class's constituents are −
● A collection of attributes from the class for the objects to be instantiated. Generally, there is a disparity in the values of the attributes of different objects in a class. Sometimes, attributes are referred to as class data.
● A series of operations that describe the behaviour of the class objects. Functions or processes are often referred to as operations.
Example :
Let us consider Circle, a simple class that represents the circle of geometric figures in a two-dimensional space. You may classify the attributes of this class as follows-
● X-coord, to denote the middle 'x-coordinate'
● Y-coord, to signify the y-coordinate of the middle
● To denote the circle radius, a,
Some of its activities can be defined as follows -
● Method for measuring area, findArea(),
● Method for measuring circumference, findCircumference(),
● Scale(), a technique for increasing or reducing the radius
During instantiation, values are allocated for at least some of the attributes. If we construct a my-circle object, we can assign values to represent its state, such as x-coord: 2, y-coord: 3, and a: 4. Now, if the operation scale() is performed with a scaling factor of 2 on my circle, the value of the variable a becomes 8. This operation brings a shift to the state of my circle, i.e. some activity has been displayed by the entity.
Key takeaway :
● A class represents a collection of objects having same characteristic properties that exhibit common behavior.
● It provides a blueprint or definition of the objects from which it can be produced.
● As a member of a class, the creation of an entity is called instantiation.
A link represents a connection through which an object collaborates with other objects. Rumbaugh has defined it as “a physical or conceptual connection between objects”. Through a link, one object may invoke the methods or navigate through another object. A link depicts the relationship between two or more objects
Associations
● Association is a connection between classes whereas link is the semantic connection between objects of class
● When two classes have association relationship, they are aware of the relationship
● Association are normally bidirectional
● It also called has-a relationship
● It is drawn as solid line between two classes
● Association has association name ,role names ,multiplicity & navigability
● Name of the association is usually verb phrase which indicate an action the source object is performing on the another object
● Association names written in a lower camel case
● Direction in to which the association name should read is indicated with an arrow head
● Role names can be given on both the ends of association which indicates role of that object
● Role names should be noun or noun phrases
|
Fig 4: association and links
Multiplicity
● These are the constraints imposed on the number of objects of a class involved in a particular relationship at any point in time.
Multiplicity | Semantic |
0..1 | Zero or 1 |
1 | Exactly 1 |
0..* | Zero or more |
* | Zero or more |
1..* | 1 or more |
1..6 | 1 to 6 |
● Ex. A college can have exactly five departments this can be shown as follow
Fig 5: example
In this association the class has association to itself i.e. the object of the class has linked between other objects of the same class.
Fig 6: link between 2 objects
Navigability
● It shows that navigation is possible from object of one class to one or more objects of another class
● Traversing is possible only in the direction of the arrow
Fig 7: navigability
Association class
● Association class is a association that is also a class
● It has attributes and operation to itself
● Association class exist between two classes which are associated with each other and having multiple instances of the class
Fig 8: association classes
● In the above diagram class job is the association class
● Explanation of the diagram can be like this
● Person object work for many companies and a company employ many person objects. If salary of the per person needs to be calculated, where should we put the attribute salary, in class person or in class company because a person who is working for many companies may get different salary with different companies and salary cannot be part of class company as every person working in the company gets different salaries, therefore we can say that salary is the property of association itself.
Qualified Association
● It shows how a specific object is selected from the set of objects using a unique key.
● Qualified association can be used to reduce a n-to-many association to a n-to one association with the help of a unique object from the target set
● Eg consider a bank object is linked to a set of customer objects and a customer is linked to exactly one bank object. In this scenario the question arises how can a bank object linked to a specific customer object. For doing this we need a unique key to link a specific object from a set of customer objects. This is known as a qualifier. We can use an account number that is unique to that object. This can be shown below by appending a qualifier i.e. account number to the bank end of the association.
Fig 9: example of qualified association
n-ary Association
● An n-ary association relates three or more classes.
● For example, in the project management system, the use of a worker involves the worker, her units of work, and her associated work products.
● In a UML class diagram, an n-ary association is shown as a large diamond with solid- line paths from the diamond to each class. An n-ary association may be labeled with a name. The name is read in the same manner as for binary associations.
● Figure below shows an n-ary association associated with the project management system using the most basic notation for n-ary associations
● This association states that utilization involves workers, units of work, and work products. As with a binary association, an n-ary association is also commonly named using a verb phrase.
Fig 10: n-ary association
Key takeaway :
● A link represents a connection through which an object collaborates with other objects.
● Association is a connection between classes whereas link is the semantic connection between objects of class
● Associations are normally bidirectional.
● It is a relationship shown between more general elements to more specific elements.
● It is also called as “is a kind of” or “is a type of” relationship.
● It is represented with the help of the following UML notation.
● The hollow triangle towards the more general element
|
Fig 11: generalization
Inheritance
● In the above example we can say that “a Manager is-a- type of Employee”, “a Teamleader is-a- type of Employee” and “a Teammember is-a- type of Employee”, etc.
● This shows that the manager ,Team Leader, Team member and Employee share some common attributes and behaviors.
● The concept of inheritance has a parent class which acts as generic superclass or an abstract class having the common attributes and methods inherited to child class or all subclasses.
Fig 12: inheritance
● Class Manager, TeamLeader and class TeamMember inherits all common attributes and functions written in Employee class. The sub classes can have their own attributes and functions in addition to the super class attributes and functions.
Key takeaway :
● Generalization is a relationship shown between more general elements to more specific elements.
● It is also called as “is a kind of” or “is a type of” relationship.
● The hollow triangle towards the more general element
● The concept of inheritance has a parent class which acts as generic superclass or an abstract class having the common attributes and methods inherited to child class or all subclasses.
In the assessment, design, and implementation of object systems, the notion of a community fills a void. Groups do not solve structural problems themselves, they offer a way of talking about problems that escape the constraints of definitions and notations solely class-based and object-based.
Modules
A category can be seen as an extension of the module notion (or subsystem or namespace). A module is a grouping, under a common scope, of similar objects and/or services. Modules, however, are too small to be useful in defining the structure of many of the applications in the above example. Strict containment of the module results in rigid," pyramidal " architectures, and most OO designs do not capture fluidity.
Groups include the extensions that are needed. The notion of a community requires the possibility that membership is complex. Objects may join and leave groups, and can concurrently be members of multiple groups. Community membership, therefore, is not inherently related to static scope. Group definitions are often multi-instantiable, allowing two or more distinctly distinct classes with the same characteristics to exist.
Objects
Although there are several characteristics they share, groups are not artefacts themselves. An individual entity possesses a specific locus of control under any rational description. And for composite objects, this applies. While during the processing of messages, a non-primitive host object can interact with other familiar objects, the host remains distinct from its acquaintances.
Groups, on the other hand, have no single control locus or single port of message. Instead, control and functionality are spread through member objects. In distributed systems, group-like structures have found the widest applicability, where groups of objects residing on various machines must somehow coordinate their activities without the help of centralized controllers to accomplish tasks.
Sets
Specific kinds of sets are classes. But groups have both intensive and extensive components, unlike Agha's otherwise similar but strictly intensively dependent set-like ActorSpace[1] construct. Group capabilities and minimal members' features are defined by interfaces. Two separate classes, each with the same interface, but with different members, may be constructed, however.
Collections
Groups serve as an alternative to numerous set-like collection entities that pervade OO systems. Groups are used in similar ways as popular OO collections whose interface memberships are limited, but otherwise circumstantially specified within applications, although perhaps triggered by evaluating predicates of inclusion. The definition of a community, rather than a collection object that governs it, offers a simpler modelling and design basis in most cases.
Classes
Obviously, a party is different from a class. All instances of a class, however, may be identified as members of a specific category. In this way, via community structures, certain elements of meta classes responsible for monitoring and handling instances of a given class can be reformulated.
Key takeaway :
● Groups do not solve structural problems themselves, they offer a way of talking about problems that escape the constraints of definitions and notations solely class-based and object-based.
● A module is a grouping, under a common scope, of similar objects and/or services.
● Groups serve as an alternative to numerous set-like collection entities that pervade OO systems.
● This relationship is also called the whole –part type of relationship.
● In this relation objects of one class act as whole or aggregate whereas objects of other class act as part which can exist independently of the aggregate.
● It is possible to have sharing of parts between other aggregates
● The whole or aggregate always know about the parts but some time it may happen that part don’t know about the whole
● Ex-relationship between car class & sound system class. Car class is weakly related to sound system class. Sound system may come & go,it can be shared with other cars also. sound system is not owned by the car class.sound system on its own may exist independently
Fig 13: aggregation
● The UML notation for this relationship is shown by the hollow diamond towards the whole.
● It is also called a strong form of association.
Composition
● It is strong form of aggregation
● The parts belongs to exactly one composite at a time
● The composite when destroyed also destroy the parts
● The parts does exist independently of the composite
● The part is tightly coupled within composite
|
Fig 14: composition
● In UML composition is represented with a filled diamond towards the composite
● Here composite class is the owner of the part classes
Key takeaway :
● The whole or aggregate always know about the parts but some time it may happen that part don’t know about the whole
● relation objects of one class act as whole or aggregate whereas objects of other class act as part which can exist independently of the aggregate.
● Abstract class is a class that has no direct instances but whose descendant classes have direct instances.
● It can only be inherited by the concrete classes (descendent classes), where a concrete class can be instantiated.
● Abstract class act as a generic class having attributes and methods which can be commonly shared and accessed by the concrete classes.
● The attributes and methods in the abstract class are non-static, accessible by inheriting classes.
● Abstract can be differentiated by a normal class by writing a abstract keyword in the declaration of the class
● It can be represented as below
Abstract public class RentalCar {
// your code goes here
}
|
Fig 15: example of abstract class
Key takeaway :
● Abstract class is a class that has no direct instances but whose descendant classes have direct instances.
● Abstract can be differentiated by a normal class by writing a abstract keyword in the declaration of the class.
Generalisation means that subclasses would bee an instantiation of all its ancestors. Any inherited features can not be omitted by a subclass and all ancestor operations must apply. However, operations may be reimplemented by a subclass, new features introduced, ancestor attributes limited and inherited features renamed. Membership in the class is regulated either by rules or directly by enumeration.
The criteria for becoming a class member are a ruled-based membership established in ruled governance memberships. If the criterion that defines class membership is clear by enumeration, the value of the attribute determines the membership of the class. Overriding is called modifying an action.
Overriding is conducted for:
● In which case, any additional behaviour is applied to the extension.
● Limitation if the kinds of potential arguments are reduced.
● In which case, optimization improves the programme code.
● For simplicity, a class's convenience is applied to a class tree and unnecessary attributes and incorrect operations are overridden.
Key takeaway :
● Generalisation means that subclasses would bee an instantiation of all its ancestors.
● Overriding is called modifying an action.
Inheritance enables a class to inherit parent-class characteristics (s). Inheritance allows a new class to be formed from an existing class or from existing classes.
Inheritance offers you some advantages by enabling you to:
Reduce duplication by building on what has been built and debugged.
Organize the classes in ways that complement circumstances and individuals in the real world.
It requires more than one super class to be owned and all parents to inherit characteristics. A class of more than one super class is referred to as a hybrid class.
A function found along more than one path from the ancestor class is inherited only once. Conflicts between parallel concepts generate uncertainties that need to be addressed in execution. A hollow triangle indicates subclasses that are disjointed, while a solid triangle indicates subclasses that overlap.
This definition is expanded by multiple inheritance to allow a class to have more than one parent class, and all parents to inherit features. Information may also be mixed from many sources. It is a more complicated kind of generalisation; a class hierarchy is not limited to a tree structure by several inheritances.
|
Fig 16: example of multiple inheritance
Multiple inheritance provides greater power for modelling to describe
Classes and strengthens the possibilities for reuse. The structure and function of the real world can be more closely reflected by the use of various inheritance object models. The downside to such models is that understanding and applying them becomes more difficult.
The benefit of multiple inheritance is that it makes it much easier than single inheritance to reuse existing classes. If it was appropriate to re-use the properties of two existing classes and only one inheritance was available, then one of the two classes would have to be updated to become a subset of the other class.
Multiple inheritances, however, should be used very carefully. As the relationships of inheritance that will be formed via multiple inheritance may become very complex and difficult to understand. It is seen as a contentious feature of object-orientation and, thus, in some object-oriented languages, such as Smalltalk, it is not enforced because many inheritances can often lead to unclear situations.
Key takeaway :
● The value of multiple inheritance is greater control and increased potential for reuse in defining classes.
● It can be difficult to deal with multiple inheritances in implementation if only Single heritage is supported, but models of research and design may be supported restructured to include a model that is functional.
● Inherit the most relevant class and assign the rest. A subset of its most significant super class is rendered here to join a class.
"Metadata is "data about data." Since it is used for two fundamentally distinct definitions (types), the term is vague. Structural metadata is about the design and specification of data structures and is more accurately referred to as "data about data containers"; descriptive metadata, on the other hand, is about individual application data instances, the content of data.
Basically, such a set of data representing other data is metadata. For starters, if an object needs to be defined, you need to provide a description of the class from which it is instantiated. Here, the data used for the class description is treated as metadata. You may remember that meta data may be available for every real-world event, since every real-world thing has a definition for it.
Let's take the example of the Modeling Institutes and their directors. You can save that school A has X as its direct one, school B has Y as its director, and so on. Now, you have unique information that every institute has a director to store in metadata.
Metadata is information which describes other data. Metadata is the description of a class. It is also useful for examples and test cases being reported.
Key takeaway :
● Models are metadata, because the items being modelled are identified.
● Metadata is used by RDBMS.
● A class determines a set of instances of a given type
A candidate key for a class is a mixture of one or more characteristics that distinguishes objects within a class uniquely. The set of attributes must be minimal in the candidate key; no attribute may be discarded from the candidate key.
Main candidate without the destruction of individuality. No attribute can be set to null in the candidate key. Multiple candidate keys can participate in a given attribute.
Notation is {}.
Airport |
airportCode {CK1} airportName {CK2} |
For example, AirportCode and airportName, are two candidate keys for the airport. The model specifies that an airport is defined uniquely by each airport code. An airport is also uniquely known by any airport name (such as Houston Intercontinental, Houston Hobby, Lambert St. Louis airport, and Albany NY airport).
Inheritance:
Inheritance is the process that, by expanding and improving its capabilities, enables new classes to be formed out of existing classes. The current classes are referred to as the base classes/parent classes/super-classes, and the derived classes/child classes/subclasses are considered the new classes.
The subclass can inherit or derive the super-class(es) attributes and methods, given that the super-class allows so. Besides, the subclass can add its own attributes and methods and can change any of the superclass methods. Inheritance describes a relationship between 'is-a'.
Types of inheritance
Different types of inheritance, defined below :
● Single Inheritance : A single super-class is derived from a subclass.
Fig 17: single inheritance
● Multiple Inheritance : A subclass derives from more than one super-class.
Fig 18: multiple inheritance
● Multilevel Inheritance : A subclass is derived from a super-class that is in turn derived from another class and so on.
Fig 19: multilevel inheritance
● Hierarchical Inheritance : A class has a number of subclasses, each of which may have subclasses, continuing for a number of levels in order to form a tree structure.
Fig 20: hierarchical inheritance
● Hybrid Inheritance : A mixture of multiple and multi-level inheritance to create a lattice structure.
Fig 21: hybrid inheritance
Key takeaway :
● A candidate key is a minimal set of attributes that identifies an entity or relation uniquely.
● A class may have one or more candidate keys, each of which can have various combinations and attribute numbers.
● Each main candidate restricts the cases in a class.
References:
- “Object Oriented Modeling and Design”, Rambaugh, Premerlani, Eddy, Lorenson, PHI.
2. “Object Oriented Analysis and Design”, Andrew High, TMG.
3. “Practical Object Oriented Design with UML”, Mark Priestley.