OOAD Notes - Module 5
OOAD Notes - Module 5
1. **Class Diagram**:
- **Description**: Class diagrams represent the static
structure of a system, showing classes, their attributes,
methods, and relationships.
- **Example**: Let's consider a simple class diagram for a
banking system.
```
------------------------------------
| BankAccount |
------------------------------------
| - accountNumber: String |
| - balance: double |
------------------------------------
| + deposit(amount: double): void |
| + withdraw(amount: double): void |
------------------------------------
```
In this example, "BankAccount" is a class with two attributes
(`accountNumber` and `balance`) and two methods (`deposit`
and `withdraw`).
```
--------------------------------
| Online Shopping |
--------------------------------
| <<System>> |
--------------------------------
| - Browse Products |
| - Add to Cart |
| - Checkout |
| - Make Payment |
--------------------------------
```
In this example, "Online Shopping" represents the system,
and the use cases are actions that users can perform within
the system.
3. **Sequence Diagram**:
- **Description**: Sequence diagrams show the interactions
between objects over time, illustrating the flow of messages
and the sequence of actions.
- **Example**: Let's look at a sequence diagram for a simple
login process.
```
User Authentication Database
| | |
| login() | |
|-------------->| |
| | verify() |
| |---------------> |
| | | Check Credentials
| | |---------------->|
| | | |
| | | Valid Credentials
| | |<----------------|
| | grantAccess()| |
| |<---------------| |
| Access Granted| | |
|<--------------| | |
```
In this example, the sequence diagram illustrates the
interactions between a user, an authentication module, and a
database during the login process.
4. **Activity Diagram**:
- **Description**: Activity diagrams represent the flow of
control within a system, similar to flowcharts but with added
features for modeling concurrency and decision points.
- **Example**: Consider an activity diagram for a simple
purchase process.
```
Start
|
v
[Check Stock]
| |
| v
| [In Stock?]
| | |
| | v
| | [Place Order]
| | |
| | v
| | End
| |
| v
| [Notify Customer]
| |
| v
| End
```
In this example, the activity diagram depicts the flow of
actions in the purchase process, including checking stock
availability, placing an order, notifying the customer, and
ending the process.
5. **State Diagram**:
- **Description**: State diagrams model the behavior of
objects over their lifetimes, depicting states, transitions, and
events that trigger transitions.
- **Example**: Consider a state diagram for a simple traffic
light.
```
+----------+
| Green |
| |
| |
+----+-----+
|
v
[Timer Expires]
|
v
+----+-----+
| Yellow |
| |
| |
+----+-----+
|
v
[Timer Expires]
|
v
+----+-----+
| Red |
| |
| |
+----------+
```
In this example, the state diagram represents the behavior of
a traffic light, transitioning between green, yellow, and red
states based on a timer.
These examples provide a glimpse into how each UML
diagram can be used to model different aspects of a software
system, aiding in analysis, design, and communication
throughout the software development process.
1. **Object Layer**:
- At the core of an object-oriented database architecture is
the Object Layer. This layer manages the representation of
data as objects. Each object encapsulates both data
(attributes) and behavior (methods or operations).
- Objects in an OODB are typically instances of classes
defined in an object-oriented schema. These classes may
have attributes (data fields) and methods (functions or
procedures) associated with them.
2. **Object Manager**:
- The Object Manager is responsible for handling the
creation, deletion, and manipulation of objects within the
database.
- It provides functionalities for storing objects persistently,
retrieving objects based on queries, and managing object
relationships (such as composition, aggregation, and
inheritance).
3. **Schema Layer**:
- The Schema Layer defines the structure and behavior of
objects stored in the database. It includes:
- Class Definitions: Define the types of objects that can be
stored in the database, including their attributes and methods.
- Inheritance Relationships: Specify inheritance hierarchies
between classes, allowing for code reuse and polymorphic
behavior.
- Relationships: Define associations between objects, such
as one-to-one, one-to-many, and many-to-many relationships.
4. **Query Processor**:
- The Query Processor interprets and executes queries
against the database.
- It supports querying based on object attributes,
relationships, and other criteria specified in the object-oriented
query language (e.g., OQL - Object Query Language).
5. **Storage Management**:
- Storage Management is responsible for managing the
physical storage of objects on disk or other persistent storage
devices.
- It handles tasks such as allocating storage space,
organizing objects efficiently, and ensuring data integrity and
durability.
1. **Component Diagram**:
```
+------------------------+
| E-commerce App |
+------------------------+
| User Interface (UI) |
| Business Logic (BL) |
| Data Access Layer (DAL)|
| External Services |
+------------------------+
```
In this example:
- The "E-commerce App" is the main component
representing the entire system.
- "User Interface (UI)" handles interactions with users.
- "Business Logic (BL)" contains the core logic and rules of
the application.
- "Data Access Layer (DAL)" provides access to the
database.
- "External Services" represent any external systems or
APIs integrated into the application.
2. **Deployment Diagram**:
```
+------------------------+
| Web Server |
+------------------------+
| E-commerce App |
| Database Server |
+------------------------+
```
In this example:
- The "Web Server" represents the server hosting the
e-commerce application.
- The "E-commerce App" component is deployed on the
web server.
- The "Database Server" hosts the database used by the
e-commerce application.
2. **Features**:
- Object Access: OQL allows users to access objects stored
in the database directly.
- Navigation: OQL supports navigation through object
relationships, enabling traversal of object graphs.
- Projection: Users can project specific attributes of objects
in query results.
- Aggregation: OQL supports aggregation functions for
summarizing data.
- Joins: OQL allows for the joining of objects based on their
relationships.
3. **Example**:
- Consider an OODB storing information about employees
and departments. Here's an example OQL query to retrieve
the names of employees in the "Engineering" department:
```
SELECT emp.name
FROM Employee emp
WHERE emp.department.name = 'Engineering'
```
5. **Limitations**:
- Query languages for OODBs may have a steeper learning
curve compared to SQL, especially for those unfamiliar with
object-oriented concepts.
- Performance optimization for complex queries can be
challenging in OODBs due to the dynamic nature of object
relationships.
1. **Data Model**:
- **RDBMS**: Relational databases follow the relational
model, organizing data into tables with rows and columns.
Relationships between tables are established using foreign
keys.
- **OODBMS**: Object-oriented databases store data as
objects, which encapsulate both data (attributes) and behavior
(methods). Objects can have complex relationships, including
inheritance, aggregation, and association.
2. **Schema**:
- **RDBMS**: Relational databases have a fixed schema
defined by tables, columns, and relationships. Changes to the
schema often require altering table structures, which can be
complex and may impact existing data.
- **OODBMS**: Object-oriented databases have a flexible
schema. Objects can evolve independently, allowing for
dynamic changes to the data model without affecting existing
objects.
3. **Query Language**:
- **RDBMS**: Relational databases primarily use SQL
(Structured Query Language) for data manipulation and
retrieval. SQL is declarative and optimized for querying
tabular data.
- **OODBMS**: Object-oriented databases typically use
Object Query Language (OQL) or provide APIs for querying
objects using programming languages. OQL allows for
navigation through object relationships and querying based on
object attributes.
4. **Performance**:
- **RDBMS**: Relational databases are highly optimized for
OLTP (Online Transaction Processing) workloads involving
structured data. They typically perform well for complex join
operations and transactional processing.
- **OODBMS**: Object-oriented databases are well-suited
for applications with complex object structures and
relationships. They offer efficient retrieval of objects and
support for complex queries involving object navigation.
5. **Scalability**:
- **RDBMS**: Relational databases can scale vertically by
adding more resources to a single server or horizontally
through techniques like sharding and replication. However,
scaling can be challenging for highly normalized schemas and
complex relationships.
- **OODBMS**: Object-oriented databases can scale
horizontally by distributing objects across multiple nodes.
They can handle complex data structures and relationships
more easily, making them suitable for applications requiring
high scalability.
6. **Concurrency Control**:
- **RDBMS**: Relational databases employ traditional
concurrency control mechanisms such as locking and MVCC
(Multi-Version Concurrency Control) to manage concurrent
transactions.
- **OODBMS**: Object-oriented databases often provide
fine-grained concurrency control at the object level, allowing
for more granular locking and concurrent access to objects.
7. **Use Cases**:
- **RDBMS**: Relational databases are commonly used for
transactional applications, such as banking systems, ERP
systems, and e-commerce platforms.
- **OODBMS**: Object-oriented databases are suitable for
applications with complex data structures, such as CAD/CAM
systems, multimedia databases, and complex modeling and
simulation applications.
Now, let's draw a class diagram for the "Country" class using
UML notations:
```
-----------------------------------
| Country |
-----------------------------------
| - name: String |
| - population: int |
| - capital: String |
| - area: double |
-----------------------------------
| + getName(): String |
| + setName(name: String): void |
| + getPopulation(): int |
| + setPopulation(pop: int): void|
| + getCapital(): String |
| + setCapital(capital: String): void |
| + getArea(): double |
| + setArea(area: double): void |
-----------------------------------
```
Explanation:
- The "Country" class is represented as a rectangle with its
name at the top.
- The attributes of the "Country" class are listed below the
class name, each with its name and data type. For example,
"name: String" indicates that the "Country" class has an
attribute named "name" of type String.
- The methods of the "Country" class are listed below the
attributes, each with its name and parameters (if any). For
example, "getName(): String" represents a method named
"getName" that returns a String.
- The "+" symbol before each method indicates that the
method is public and accessible from other classes.
1. **Sequence Diagram**:
- **Key Elements**:
- **Objects**: Represent instances of classes participating
in the interaction.
- **Lifelines**: Vertical lines representing the lifespan of
each object.
- **Messages**: Arrows indicating communication between
objects, depicting the order of messages exchanged.
- **Activation Boxes**: Rectangles representing the time
during which an object is performing an action.
- **Return Messages**: Arrows with a dashed line
indicating the return of control from the receiver to the sender.
- **Use Cases**:
- Modeling the flow of interactions in a system.
- Designing and documenting the behavior of a system's
components.
- Identifying dependencies and collaborations between
objects.
2. **Activity Diagram**:
- **Key Elements**:
- **Activity Nodes**: Represent actions or steps in the
process.
- **Control Flow**: Arrows indicating the flow of control
between activity nodes.
- **Decision Nodes**: Diamonds representing decision
points where the flow can diverge based on conditions.
- **Merge Nodes**: Symbols indicating the merging of
multiple paths of control flow.
- **Fork and Join Nodes**: Representing concurrent
execution paths and their synchronization.
- **Use Cases**:
- Modeling business processes and workflows.
- Describing the behavior of use cases or scenarios.
- Documenting the steps involved in a system operation.
1. **Arrow Direction**:
- Messages are represented by arrows pointing from the
sender object to the receiver object.
- The direction of the arrow indicates the flow of the
message, from the sending object to the receiving object.
2. **Message Label**:
- Each arrow representing a message may have a label
indicating the name or description of the message being sent.
- This label is placed near the arrow to provide additional
information about the message being transmitted.
4. **Self-Message**:
- If an object sends a message to itself, it is represented by
an arrow that loops back to the same object.
- This self-message indicates that the object is performing
some action or method invocation on itself.
5. **Return Message**:
- If a message triggers a response from the receiver object,
a return message arrow can be added to indicate the return of
control to the sender object.
- Return messages are represented by dashed arrows
pointing from the receiver object back to the sender object.
```
+-----------+ messageA +-----------+
| Object1 |---------------------->| Object2 |
+-----------+ +-----------+
| ^
| |
| return messageB |
+------------------------------------+
```
In this example:
- Object1 sends a message named "messageA" to Object2.
- Object2 processes the message and may send a return
message named "messageB" back to Object1.
- The direction of the arrows indicates the flow of
communication between objects.
- Optionally, each arrow may have a label indicating the name
or description of the message being transmitted.