This document provides an introduction to object-oriented programming concepts including classes, objects, relationships between classes and objects, and modeling with UML diagrams. It discusses key OOP concepts like encapsulation, inheritance, and polymorphism. It also explains the object-oriented development life cycle including analysis, design, and implementation phases. Specific examples of class diagrams are provided for a library management system to illustrate class relationships and modeling.
2. Module 2: Object-Oriented Programming Constructs
Class, Object
relationships among classes- association, dependency (use, call), aggregation, grouping,
generalisation
relationships among objects - instantiation, links
meta-class
Modelling with UML Class and Sequence Diagrams
3. OOP Design
Object-oriented programming (OOP) is a computer programming model
that organizes software design around data, or objects, rather than
functions and logic. An object can be defined as a data field that has
unique attributes and behavior.
Is OOP used in software development?
Object Oriented programming (OOP) is a programming paradigm that
relies on the concept of classes and objects.
It is used to structure a software program into simple, reusable pieces of
code blueprints (usually called classes), which are used to create individual
instances of objects.
4. Object Oriented System Development Life Cycle
It consists of three macro processes −
Object Oriented Analysis (OOA)
Object oriented design (OOD)
Object oriented Implementation (OOI)
Object-Oriented Analysis(OOA)
This phase concerns with determining the system requirements and to
understand the system requirements build a use-case model.
A use-case is a scenario to describe the interaction between user and
computer system. This model represents the user needs or user view of
system.
5. Object-Oriented Design
The objective of this phase is to design and refine the classes,
attributes, methods, and structures that are identified during the
analysis phase, user interface, and data access.
This phase also identifies and defines the additional classes or objects
that support implementation of the requirement
Object Oriented Implementation
Prototyping
Prototyping enables to fully understand how easy or difficult it will be
to implement some of the features of the system.
6. Implementation
It uses either Component-Based Development (CBD) or Rapid
Application Development (RAD)
Incremental Testing
Software development and all of its activities including testing are an
iterative process.
Therefore, it can be a costly affair if we wait to test a product only
after its complete development.
Here incremental testing comes into picture wherein the product is
tested during various stages of its development.
7. Class Diagram Relationships
Class diagrams are the main building blocks of object-oriented modeling so it
is important that you understand the various class diagram relationships and
how they affect your solution.
Classes are interrelated to each other in specific ways. In particular,
relationships in class diagrams include different types of logical connections.
The following are such types of logical connections that are possible in UML
8. • Association
Association - One of the most common in class diagram relationships
It is a broad term that encompasses just about any logical connection or
relationship between classes. For example, passenger and airline may be
linked as above.
9. Directed Association
refers to a directional relationship represented by a line with an
arrowhead. The arrowhead depicts a container-contained directional
flow.
10. Aggregation
refers to the formation of a particular class as a result of one class being
aggregated or built as a collection.
For example, the class “library” is made up of one or more books, among
other materials.
In aggregation, the contained classes are not strongly dependent on the
lifecycle of the container. In the same example, books will remain so even
when the library is dissolved.
To show aggregation in a diagram, draw a line from the parent class to the
child class with a diamond shape near the parent class.
11. Composition
A composition association relationship represents a whole–part relationship and is a
form of aggregation.
A composition association relationship specifies that the lifetime of the part classifier is
dependent on the lifetime of the whole classifier.
In a composition association relationship, data usually flows in only one direction (that
is, from the whole classifier to the part classifier).
For example, a composition association relationship connects a Student class with a
Schedule class, which means that if you remove the student, the schedule is also
removed.
12. Dependency
Using a dependency relationship in UML, one can relate how various
things inside a particular system are dependent on each other.
Dependency is used to describe the relationship between various
elements in UML that are dependent upon each other
13.
14. Generalization
It is also called a parent-child relationship. In generalization, one element is
a specialization of another general component. It may be substituted for it. It
is mostly used to represent inheritance.
To show inheritance in a UML diagram, a solid line from the child class to
the parent class is drawn using an unfilled arrowhead
15. When to Draw Class Diagram?
Most of the UML diagrams can not be mapped directly with any
object-oriented programming languages except class diagrams. In
other words, class diagram ideally can have one to one mapping to
UML class diagrams. Besides, class diagrams are useful in the
following situations:
Describing the static view of the system.
Modeling the collaboration among the elements of the static view.
Describing the functionalities performed by the system.
Construction of software applications using object oriented languages.
Performing code forward engineering for the target systems
Classifying classes or components as library for future reuse
16. What are the Class Diagrams?
Class diagrams are the main building block in object-oriented
modeling. They are used to show the different objects in a system,
their attributes, their operations and the relationships among them.
The following figure is an example of a Simple class diagram with
attributes and operations
17. In the example, a class called “loan account” is depicted. Classes in class
diagrams are represented by boxes that are partitioned into three:
The top partition contains the name of the class.
The middle part contains the class’s attributes.
The bottom partition shows the possible operations that are associated with
the class.
The example shows how a class can encapsulate all the relevant data of a
particular object in a very systematic and clear way. A class diagram is a
collection of classes similar to the one above.
18. Class Diagram For LMS(Library Management
System)
Class Diagram for Library Management System simply describes structure of
Library Management System class, attributes, methods or operations,
relationship among objects.
• Classes of Library Management System :
• Library Management System class –
It manages all operations of Library Management System. It is central part of
organization for which software is being designed.
• User Class –
It manages all operations of user.
• Librarian Class – It manages all operations of Librarian.
• Book Class –
It manages all operations of books. It is basic building block of system.
19. • Account Class –
It manages all operations of account.
• Library database Class –
It manages all operations of library database.
• Staff Class –
It manages all operations of staff.
• Student Class –
It manages all operations of student.
20. Attributes of Library Management System :
• Library Management System Attributes –
• UserType, Username, Password
• User Attributes –
• Name, Id
• Librarian Attributes –
• Name, Id, Password, SearchString
• Book Attributes –
• Title, Author, ISBN, Publication
• Account Attributes –
• no_borrowed_books, no_reserved_books, no_returned_books, no_lost_books fine_amount
• Library database Attributes –
• List_of_books
• Staff Class Attributes –
• Dept
• Student Class Attributes –
• Class