1.1 What's Software Engineering?: Difference Between UML & SE
1.1 What's Software Engineering?: Difference Between UML & SE
Problem-Solving
Deploying And
Conception
Maintaining
Design
Programming Softwares
And
UML
Many people tend to confuse UML, which is merely a tool used for visualizing client needs, software architectures, and other elements
in easy-to-understand diagrams, with software engineering, which involves the entire project creation process . UML is simply one of
many skills within the field of software engineering.
1
2 The Birth of Software Engineering
2.1 Development of Hardware/Software and Their Relationship
• 1940-1950: Vacuum Tubes: Vacuum tubes were electronic components that controlled the flow of electricity in a vacuum. Used in
radios, televisions, and early computers, they were large, expensive, and consumed a lot of power, but were essential for electronics at the
time.
• 1950-1960: Transistors: Transistors are semiconductor devices used to amplify or switch electronic signals. They replaced vacuum
tubes due to their smaller size, greater efficiency, and lower cost. Transistors were used in radios, early computers, and have since become
fundamental in all modern electronics.
• 1960-1970: Integrated Circuits: An integrated circuit (IC) is a small chip that contains a set of electronic circuits, including transistors,
resistors, and capacitors. ICs made electronics more compact, affordable, and powerful, revolutionizing industries during the 1960s. ICs
were found in computers, calculators, and a wide range of other electronic devices.
• 1970-Present: Microprocessors: A microprocessor is a single-chip CPU (Central Processing Unit) that performs the functions of a
computer’s central processor. Microprocessors became more affordable in the 1970s, paving the way for the rise of personal computers,
smartphones, and embedded systems in countless devices today.
Software
Hardware
P rice
T ime
As shown in the graph above, there is an inverse relationship between hardware and software prices. As hardware becomes more affordable
and advanced, software prices tend to increase, a phenomenon often referred to as the ”Software Crisis.” This was primarily caused by a lack
of development methodology and reflection on part of the developers. Software projects frequently went over budget, were late to release, and
were often filled with bugs.
To address this issue, developers needed to establish efficient methodologies and practices for building better software.
2
2.2 Qualities of Good Software
A well-designed software product must meet several key criteria to be considered high-quality. Here are some essential qualities:
• Maintainability: The ease with which software can be modified to correct faults, improve performance, or adapt to a changed environment.
Code should be well-documented, modular, and easy to update without causing regressions in other parts of the software.
• Affordability: High-quality software should provide value for money. The cost of development, licensing, maintenance, and support
should be reasonable and aligned with the customer’s budget and expectations. Affordability doesn’t mean the cheapest option, but one
that balances cost with features and reliability.
• Functionality: The software must meet the specific needs of its users and perform the tasks it was designed for effectively. It should
deliver all required features and capabilities, ensuring that it fulfills its purpose.
• Reliability: Software should function consistently and accurately over time, without crashing or producing incorrect results. It should
handle errors gracefully and work well under various conditions, including edge cases and unexpected inputs.
• Performance: Good software should operate efficiently, with fast response times and minimal use of system resources. Performance
includes aspects like load times, memory usage, and the ability to handle multiple tasks or large amounts of data simultaneously.
• Scalability: The software should be able to grow and accommodate increasing amounts of work or users without a significant drop in
performance. This is especially important for systems that expect long-term growth or fluctuating demand.
• Usability: The user interface should be intuitive, making it easy for users to learn and navigate. Well-designed software provides a
positive user experience, with thoughtful layouts, clear instructions, and accessible features for all users, including those with disabilities.
• Security: Security is critical in today’s environment. High-quality software should protect user data and prevent unauthorized access,
ensuring compliance with security standards. It should include features like encryption, authentication, and protection against common
vulnerabilities such as SQL injection or cross-site scripting.
• Portability: Software should work across different platforms and environments with minimal modifications. This is especially important
for applications intended to run on multiple operating systems, browsers, or devices. A portable software solution can save significant
development effort.
• Interoperability: High-quality software should be able to integrate and work seamlessly with other systems and tools. This includes
support for standard formats, APIs, and protocols that allow it to exchange data and collaborate with other software.
• Minimization of Bugs: A good software product should have a minimal number of defects. This involves rigorous testing during the
development process to catch and fix bugs early, as well as ongoing maintenance and updates to address issues as they arise.
• Extensibility: Software should be designed in a way that allows new features and functionality to be added in the future without
significant changes to the core architecture. Extensible software can adapt to changing user needs and technology advances.
• Compliance with Standards: High-quality software adheres to industry standards and regulations, ensuring that it meets legal,
technical, and ethical guidelines. This is particularly important in industries like healthcare, finance, and government, where compliance
is mandatory.
3
P rice Quality
This graph illustrates the positive correlation between software quality and price. As the quality of the software improves, its price tends to
increase exponentially.
4
3 Life Cycle Of Software
3.1 Whats’s Life Cycle Of Software?
As the name suggest it’s the life cycle of a software from start to finish , life cycle also known as model is a methodology that serves to help
developers in building their product , each life cycle has steps and a chronology to follow
Requirements Document
Definition & Needs Analysis
Design Document
Design
Software’s Modules
Coding
Software
Testing
5
3.2.2 Improved Version
The Waterfall model was slightly improved by dividing some steps into two:
• Design:
– Architectural Design: Design how the software’s modules will interact with each other.
– Detailed Design: Design each module’s components in detail.
• Testing:
– Unit Testing: Test all the modules independently.
– Integration Testing: Test the interaction and communication between modules.
Requirements Document
Definition & Needs Analysis
Achitectural
Design
Design Document
Detailed
Design Software’s Modules
Coding
Unit
Testing
Software
Integration
Testing
Deployment & Maintenance
6
Note
Why Architectural Design before Detailed Design?
We first define the high-level structure of the modules and their interactions to provide an overall system architecture. This gives a
clear overview of the software before delving into the detailed characteristics of each module.
It is important to test each module individually to ensure that they function correctly in isolation. This helps to simplify debugging,
as any issues can be pinpointed within a module, rather than confusion over whether the problem lies in the module itself or in the
interaction between modules.
3.2.3 Pros
• Helps organize the project by providing a clear structure and well-defined stages.
• Simple to understand and execute, especially for small to medium-sized projects.
• Easy to manage due to its linear progression, making it suitable for projects with stable requirements.
3.2.4 Cons
• Lack of parallelism, as tasks cannot be done concurrently, leading to longer project timelines.
• High dependency between steps, meaning each phase must be completed fully before the next can begin.
• Inflexibility to handle changes during development, as going back to previous phases can be costly and time-consuming.
• Risk of significant rework if the needs analysis phase is not done properly, potentially requiring a restart from the beginning.
• Limited feedback during development, as testing and validation occur only at later stages.
7
Prepation
Definition & Needs Analysis Acceptation Test
Prepation
Architectural Design Integration Test
Prepation
Detailed Design Unit Test
Coding
Note
It’s important to note that while there is parallelism in the preparation for testing, the development steps themselves are still executed
sequentially, with no overlap.
3.3.1 Pros
• Improves time efficiency by preparing testing phases in parallel with development phases, allowing for faster transitions between steps.
• Allows early detection of potential issues, as test preparation begins immediately after design, enabling a quicker response to design flaws
or misunderstandings.
3.3.2 Cons
• Lacks parallelism in the execution of development steps, as each phase must still be completed sequentially.
• Carries the risk of significant rework if the needs analysis phase is not thoroughly completed, potentially requiring a restart from the
beginning.
• Maintains strong dependencies between steps, meaning that each phase relies heavily on the correct execution of the previous one. This
can create delays or issues if earlier phases were not executed properly.
8
3.4 Prototyping Life Cycle
The Prototyping Life Cycle was developed to reduce the risk of restarting the project due to incomplete, contradictory, or ambiguous requirements
in the initial requirement document. In this approach, the development team first meets with the client to conduct a needs analysis and create
the initial requirement document. Then, a small prototype is developed and presented to the client for feedback. This process helps clarify the
client’s needs, improve understanding, and refine the requirements document. The cycle of developing and reviewing prototypes continues until
the requirements document is fully defined and clear. Once finalized, the project proceeds through the remaining steps of the chosen life cycle
model.
However, if the prototype was designed with a solid foundation and can easily accommodate additional features, continuing to build on
it could save time and resources.
Updating RD Client
& Prototype Feedback
Prototype Creation
Completed RD
& Prototype
3.4.1 Pros
• Reduces the risk of restarting the project due to continuous client feedback, as a complete requirements document is established upfront.
9
3.4.2 Cons
• Creates uncertainty about whether to discard the prototype or continue building on it, which can be time-consuming and resource-intensive.
• Carries the cons of the used life cycle
Incr3
Incr6
Core Increment
(Incr1 )
Incr7 Incr2
Incr4 Incr5
3.5.1 Pros
• Dividing the project into smaller sets of features makes it easier for developers to manage and focus on one increment at a time.
• Constant client feedback throughout the development process ensures that adjustments can be made as new features are added.
• Minimizes the risk of wasted effort, as nothing is discarded—each increment builds upon the previous one.
10
3.5.2 Cons
• There is a risk of restarting the project if the developers do not select the right initial set of features for the core increment, as future
increments depend on this foundation.
• Each increment inherits the flaws or limitations of the chosen life cycle model.
• Planning(Objective): The project’s objectives are identified, and alternatives and constraints are defined. High-level requirements
gathering (Needs Analysis) is also performed.
• Risk Analysis(Risk Management): This phase focuses on evaluating risks, uncertainties, and potential problems of the current
iteration, ensuring that risks and strategies to mitigate them are identified early on.
• Engineering (Development & Testing): The actual designing, development, and testing of the product occur in this phase, which
includes activities such as unit testing and integration testing.
• Evaluation(Planning next itteration): After each iteration (loop) of the spiral, there’s an evaluation of the product by the customer
or stakeholders. Feedback is collected, and necessary changes are made before the next loop begins, allowing for continuous improvement
throughout the project.
11
2.Risk Management 1.Planning
3.Engineering 4.Evaluation
3.6.1 Pros
• Continuous client feedback facilitates timely adjustments and improvements to the project.
• Regular identification and assessment of risks, along with strategies for mitigation, help ensure a smoother development process.
3.6.2 Cons
• The model can be complex and challenging to implement effectively, requiring careful planning and coordination.
• It can be resource-intensive, potentially demanding significant time and effort from the development team.
12
3.7 Hybrid Life Cycle
The Hybrid Life Cycle involves dividing the project into n parts, where each parti follows its corresponding lifeCyclei .This model provides the
greatest flexibility among all the methodologies discussed so far.
The Project
• Incremental: This approach breaks the project into a set of features called increments, building each subsequent increment on the
core increment.
• Spiral: The Spiral model follows an iterative loop structure, where each loop consists of four steps: Planning, Risk Analysis,
Development & Testing, and Evaluation.
13
3.7.1 Pros
• Offers significant flexibility since each part can adopt a different life cycle model tailored to its specific needs and requirements, enabling
teams to capitalize on the strengths of various methodologies.
3.7.2 Cons
• Can be complex to manage, as coordinating different life cycles for various parts of the project may require additional resources and effort.
• Potential for misalignment between parts if communication and integration aren’t carefully managed, which could lead to inconsistencies
in the overall project.
14
4 Needs Analysis
A thorough needs analysis is critical in software development. Any ambiguity, contradiction, or missing information found in the requirements
document can lead to significant setbacks, potentially requiring a restart of the project. In this section, we will take a detailed look at how the
requirements document is structured.
Example :
The client might request a ”pleasant user interface” , This can be interpreted in many ways:
and so on. To turn this into a clear need, we must clarify what the client means. For instance, they might want the UI to be organized
with all features accessible through a dropdown menu.
– Scope: A high-level summary of the software’s main functionality, without going into too much detail.
– Context: The reason for creating the software, which could be to sell it to a client or company, to develop an open-source project, or
other similar motivations.
• Hardware : This section states whether the software requires any special hardware components like : GPU, sensors, or a camera ...etc
. It also outlines the minimum hardware requirements needed to run the software, as well as the optimal hardware configuration for the
best and smoothest experience.
• Conceptual Model : This section describes the overall software architecture through a high-level graphical representation, highlighting
key components and their relationships. It provides an overview of how the system is structured and operates, making it easier for
stakeholders to understand.
Example :
A desktop system composed of an email service, a spreadsheet, a document processing service, and an information retrieval service.
15
User
Document
Processing
Email
Management
Information
Retrieval
Network
Spreadsheet DB
The next step consist into creating a new conceptual model for each complexe fonction
User
Message
Creation Document
Spreadsheet
Processing
Message
Deletion
Message
Transfer
Network
16
• Functional Requirements: These define what the system should do, focusing on the specific features and functions the software must
deliver to meet user or business needs. They describe the expected behavior of the system in various situations. Functional requirements
are concrete and measurable. They can be expressed using natural, semi-formal, or formal language, or a mix of these.
– Natural Language: Easy to implement and understand, but lacks structure and precision, which can lead to ambiguity. It makes
automating analysis of the document harder, relying heavily on the writer’s linguistic experience.
– Structured (Semi-Formal) Language: Limited use of natural language, more structured and precise than natural language ,
often accompanied by graphical notations.
– Formal Language: Hard to master and time-consuming to implement. It is difficult for clients to understand but is based on
mathematical theory, making it the most precise language and easier to automate verification.
• Non-Functional Requirements: Define the restrictions and constraints related to both hardware and software within the context of
the ongoing project. Non-functional requirements are particularly influenced by changes in technologies (both hardware and software) and
are crucial for complex software systems. As the project develops, changes in hardware may occur. These changes can be anticipated by
projecting the expected performance levels that will be required by the end of the project.
• Maintenance Information: Anticipates possible actions after the software’s initial release, such as adding new features, improving
performance, or addressing potential issues.
• Glossary: Provides definitions of the terms and concepts used in the document to help readers. This ensures that the terminology is clear,
as the requirements document is shared and read by the design team, developers, and stakeholders, without assuming prior knowledge of
these terms.
• Index: Helps the reader find specific topics and sections of the document more efficiently by providing a detailed list of references to
relevant sections, parts, and page numbers.
17
5 UML
5.1 Introduction
As seen in the previous sections, the requirements document is very important, as any mistake, ambiguity, or misunderstanding of the client’s
needs can lead to a project restart. We’ve reviewed the high-level structure of a requirements document; one of the most important parts is the
functional requirements, which can be expressed in natural language. This approach is easy to implement and understand but isn’t very precise,
doesn’t automate verification, and relies solely on the linguistic experience of the writer. There is also a formal approach based on mathematical
theory, which automates verification, is very precise, but is hard to master and time-consuming. Finally, there is a semi-formal approach that
benefits from the advantages of both natural and formal language; an example of this is UML (Unified Modeling Language).
Diagram
Structure Behaviour
Diagram Diagram
18
5.3 Use Case Diagram
A use case diagram is a graphical representation of a behavior diagram, composed of three main elements:
• Actors: Actors represent roles that interact with the system. Each actor performs a set of actions called use cases, which represent features
of the software they interact with. Actors are depicted as stick figures and can be either human or non-human.
– Human actors: Individuals using the system.
– Non-human actors: Entities such as hardware (e.g., sensors, cameras) or software (e.g., APIs, dependencies).
• Use Cases (Features): These represent features or functions of the software and are shown as ellipses , they have to be programmable.
• Associations: Associations are the connections between actors and use cases, depicted as lines. These lines indicate what action (use case)
each actor can perform.
Example:
Actor
Place Order Print Logistic Report
Customer
Association
Cancel Order Arrange Delivery
Logistic Departement Manager
19
The Ideal Level Of Decomposition Of Use Cases
In a use case diagram, the level of decomposition for use cases should strike a balance. It shouldn’t be too specific, as this can make the
diagram cluttered and difficult to read, nor too generic, which can make it hard to understand. A moderate level of detail is ideal.
It’s acceptable to leave some use cases at a more generic level without decomposing them, especially since the diagram is accompanied
by a document that provides detailed explanations. This document defines and elaborates on all sub-use cases as needed.
– Between Use Cases: Allows a feature to be divided into multiple, more specific versions. These child use cases represent the same
general feature but can differ in their implementation or method. This promotes reusability and clarity in how features are handled
in different scenarios.
• Inclusion: This relationship applies only between use cases. The destination use case must execute before the source use case whenever
the source use case is invoked.
”include”
Source Destination
20
• Extension: This relationship applies only between use cases. Before executing the destination use case, a specific condition is checked. If
the condition is met, the source use case will execute before the destination use case.
”extend”
Source Destination
Example:
Let’s Take the example of a bank application
Transfer
Teller
Service Manager
”include”
Transfert Identification
21
Extension Between Use Cases:
the diagram below shows an extension relationship between use cases where each time the transfert case is invoked the balance check case will
be executed if the value is >= 10000 DA
”extend”
Balance Check Transfert
If value >=10000DA
22
5.4.1 UML Elements
Class
Each class is represented as a rectangle containing the following components:
• Class Name: Displayed at the top of the rectangle. It may have an access modifier and other modifiers:
– +: Public
– -: Private
– #: Protected
– (no symbol): Default (Package-private)
– static: Inner class (indicating that the class can exist without an instance of the outer class)
– final: The class cannot be subclassed (i.e., it is a non-extendable class)
– abstract: The class cannot be instantiated directly (i.e., it is intended to be subclassed)
• Attributes: Attributes include both methods and variables of the class. Each method or variable has can have an access modifier
and other modifiers:
– Variables:
∗ +: Public
∗ -: Private
∗ #: Protected
∗ (no symbol): Default (Package-private)
∗ static: The variable belongs to the class, not to instances. It is shared by all instances and has the same value for every
instance.
∗ final: The variable can only be assigned a value once and cannot be modified afterward.
– Methods:
∗ +: Public
∗ -: Private
∗ #: Protected
∗ (no symbol): Default (Package-private)
∗ static: The method can be accessed without creating an instance of the class.
∗ final: The method cannot be overridden by subclasses.
∗ abstract: The method has no implementation in the class and must be implemented by subclasses.
Enumeration
Enumerations are represented in a rectangle as well. The top displays ≪ Enumeration ≫ enumName . Below that, the rectangle holds
the possible values of the enum. it is placed next to the class that uses the enum
23
Interface
Interfaces are represented in a rectangle as well. The top displays ≪ Interface ≫ interfaceName. Below that there are the constant and
method prototypes of the interface it is linked to classes that implements it using the realization relation
Example :
UML :
<<Enumeration>> + Vehicle
VehicleType
Model: String <<Interface>>
Type : VehicleType Drivable
CAR
TRUCK
+ Vehicle(Model :String, Type:VehicleType) drive()
MOTORCYCLE
Note
When class implements an interface there is no need to list the implemented methods
Java Code :
Vehicle Class :
24
VehicleType Enumeration :
Drivable Interface :
5.4.2 Cardinalities
Cardinality
Cardinality in UML defines the number of instances of one class that can or must be associated with an instance of another class. It
helps indicate the number of objects involved in aggregation , association, compostion relation.
How to Read Cardinality:
Cardinality is represented by numbers near a class, The format is typically ‘min..max‘ , so if there is association between student and
teacher , cardinality near to teacher would be how many instance of teacher for 1 student , and cardinality near student class would be
how many instance of student for 1 teacher
Examples:
• ‘1‘ means exactly one instance.
• ‘0..1‘ means zero or one instance.
25
5.4.3 Relations Between Class
Simple Relation(Association)
Association
Association is represented as a solid line between classes. It indicates that one class references another. There are several types of
associations:
• Reflexive Association: A class references itself.
• Unidirectional Association: One class references another class, but the reverse is not true.
Note
There is no need to explicitly list references of the other classes in the class association because it is implicitly implied
Example :
Reflexive Association
Employee class that references itself to have a supervisor or manager , so an employee is managed by one manager , and a manager manages
many employees
UML
1..*
is managed by
+ Employee
firstName: String
lastName : String
ID : int
Manager : Employee
1..1
+ Employee(firstName: String, lastName: String, ID: int, Manager: Employee )
26
Employee Class
Uni-direction Association
UML
+ Address + Person
country: String firstName: String
state: String 1 1..*
lastName: String
city: String address: Address
street: String associated to
+ Person(firstName: String, lastName: String, address: Address)
+ Address(country: String, state: String, city: String, street: String)
Java Code
Person Class
27
Address Class
Bi-direction Association
UML
+ Teacher + Article
Java Code
Teacher Class
1 import java . util . LinkedHashSet ;
2 import java . util . Set ;
3
4 public class Teacher {
5 String firstName ;
6 String lastName ;
7 int ID ;
8 Set < Article > articleList = new LinkedHashSet < >() ;
9
10 public Teacher ( String firstName , String lastName , int ID ) {
11 this . firstName = firstName ;
12 this . lastName = lastName ;
13 this . ID = ID ;
14 }
15
16 public void addArticle ( Article article ) { this . articleList . add ( article ) ;}
17 public void removeArticle ( Article article ) { this . articleList . remove ( article ) ;}
18 }
28
Article Class
29
Association Class
UML
+ Organization
+ Person
ID: int
firstName: String
1..* 0..* name: String
lastName: String
address: String
address: String
employeList: Map<Integer,Person>
workingList: Set<WorkFor>
+ person(firstName: String, lastName: String, address: String) + Organization(ID: int, name: String, address: String)
+ printEmploye(organizationID: int) + addEmployee(IDemp: int, employe: Person): boolean
+ removeEmployee(IDemp: int): boolean
+ searchEmployee(IDemp: int)
+ WorkFor
salary: double
hiringDate: Date
empID: int
Person Class
30
Organization Class
31
WorkFor Class
32
3-ary Association
UML
+ Student
studentName: String
studentID: int
0..*
+ Instructor + Enrollment
0..*
instrutorName: String hour: int
instructorID: int classRoom: String
+ Instructor(name: String, ID: int)
1..*
+ Course
courseName: String
courseID: int
Java Code
Course Class
33
Instructor Class
Student Class
Enrollment Class
34
Dependency
Dependency
A dependency is represented by a dashed line with an arrow pointing to the provider class. It indicates a temporary relationship
between two classes, where one class relies on the other to perform a specific function or operation. The types of dependency include:
• Method Call: One class calls a method of another class without retaining a permanent reference.
• Object Usage: One class temporarily interacts with an object of another class, either as:
– method parameter.
– return type.
• The referenced object is used only temporarily and is eligible for garbage collection once the interaction ends.
• The classes are loosely coupled, meaning changes to one class have a lower impact on the other.
In contrast, an association involves a permanent reference to another class that exists as long as the object itself exists.
Example
Method Call
UML
+ Document + Printer
Printer Class
35
Document Class
+ Email
+ EmailService
subject: String
+ sendEmail(email: Email)
+ Email(subject: String)
Email Class
EmailService Class
36
Return Type Of A Method
UML
+ Report
+ ReportGenerator
content: String
+ generateReport(content: String): Report
+ Report(content: String)
Report Class
ReportGenerator Class
1 public class Re p or tG en e ra to r {
2 public Report generat eReport ( String content ) {
3 return new Report ( content ) ;
4 }
5 }
Inheritance
Inheritance
Inheritance occurs when a class extends (inherits from) another class. It is represented in UML by a solid line with a hollow triangle
at the end, pointing to the parent class.
Note
Since the child class inherits all attributes and methods from the parent class, there’s no need to explicitly list them unless a
method is overridden or the visibility of an attribute is changed. The constructor is mentioned in the subclass only if it
takes more parameters than the parent class constructor or if its body contains more than just a call to the parent
constructor.
37
Example
UML
+ Animal
name : String
+ Animal(name: String)
+ sound()
+ Cat
+ Dog
- name: String
+ sound() <<Override>>
+ Cat(name: String)
+ sound() <<Override>>
Animal Class
Cat Class
38
Dog Class
Aggregation
Aggregation
Aggregation is a stronger relationship than association. It involves two classes: a whole class and a part class. The whole class references
the part class, but the part class exists independently of the whole class. The part class is unaware of the whole class. Even if the whole
class is destroyed by the garbage collector, the part class continues to exist.
Example
UML
+ Teacher + Department
Teacher Class
39
Department Class
Composition
Composition
Composition is a stronger relationship than aggregation. In composition, when the whole class is deleted, the part class is also deleted,
as the part is tightly bound and dependent to the whole.
40
Example
UML
<<Enumeration>>
fileExtension
PDF
WORD
PPTX
TEX
+ Document
name: String
+ Version extension: fileExtension
content: StringBuilder
version: double 0..* 1 versionList: Set<Version>
content: StringBuilder
+ Document(name: String,extension: fileExtension, content: StringBuilder)
+ Version(version: double, content: StringBuilder) + createVersion(version: int)
+ deleteVersion(version: int)
+ revertTo(version: int)
+ deleteDocument(version: int)
Version Class
fileExtension Enumeration
41
Document Class
42
5.5 Summary
Enumeration
<<Enumeration>>
Class1
Enum1
field: enum1
value_1
method(type): type value_2
value_3
Interface
<<Interface>>
Interface1
Class1
field1: Type
field: type
field2: Type
method(type): type
method1(par: Type): Type
method2(): Type
Reflexive Association
card_1
Class1
field: type
43
Simple Association
Class1 Class2
card_1 card_2
field: type field: type
N-ary Association
Class1
field: type
method(type): type
card_1
Class3
card_3
field: type
method(type): type
card_2
Class2
field: type
method(type): type
44
Class Association
Class1 Class2
ClassAssociation
field: type
Dependency
dependentClass providerClass
Inheritance
subClass parentClass
Aggregation
partClass wholePart
card_1 card_2
field: type field: type
45
Composition
partClass wholePart
card_1 card_2
field: type field: type
Note
We can read composition and aggregation as whole class contains part class.
46
6 Conception
6.1 Introduction
Conception Introduction
Conception represents the solution to a problem, expressed through structured diagrams such as UML. Creating a conception is an
iterative process that requires significant time and creativity. Initially, a solution is developed, and subsequent iterations focus on
optimizing it.
Each iteration refines and expands the conception until reaching a final result that is easy to maintain. This ensures better implemen-
tation, facilitates adding or removing features, and simplifies bug fixes.
UML is merely a tool used to represent the conception, it is not the conception itself. Conception encompasses more than just diagrams—it
includes algorithms, explanations of diagrams, and other documents.
Importance of Maintainability
Easy maintainability is one of the key qualities of a good conception and arguably the most important criteria. This is because we want
the software to be long-lasting, and effective maintenance is essential to achieving that.
The conception should have high ratio of cohesion and low ratio of coupling
47
Why Global Conception Then Detailed Conception
We first define the high-level structure of the modules and their interactions to provide an overall system architecture. This gives a clear
overview of the software before delving into the detailed characteristics of each module.
– High Cohesion: The module has a clear, well-defined responsibility, making it easier to understand, maintain, and modify.
– Low Cohesion: The module handles multiple, unrelated responsibilities, making it harder to maintain and understand.
• Coupling: How dependent the modules are on each other.
– High Coupling: Modules are highly dependent on each other. A failure in one critical module may cause the entire system
to fail.
– Low Coupling: Modules are loosely connected, and changes or failures in one module are less likely to impact the others.
Function-Oriented
The software is structured using a functional paradigm. It is divided into a set of functions that interact with each other. The software
is viewed as a complex main function that is progressively decomposed into smaller, less complex sub-functions. This process continues
until we reach a detailed conception.
Each function has its own local state (local variables), while the software has a global state (global variables) that is shared among all
functions.
48
6.3.2 Object Oriented Conception
Object-Oriented Design
The software is viewed as a collection of encapsulated and independent objects. These objects communicate with each other by sending
messages (method calls).
Each object is identified by its name and encapsulated attributes (variables and methods).
Data-Oriented
The software’s structure must reflect the structure of the data it traits . Therefore the conception is influenced by the ouput input data.
Principles
• Abstraction: Focuses on the essential characteristics while hiding unnecessary details.
• Modularity: Divides the system into modules with well-defined interactions, adhering to the principle of high cohesion and low
coupling.
• Encapsulation: Hides internal details of a module from other modules.
• Structuring: Ensures a structured conceptions (levels) , we can at least have general & detailed conception.
Notation
• Data Flow Diagram (DFD): Shows how data is transformed and passed from one module to another.
• Structure Diagram (SD): A hierarchical diagram that illustrates the structured relationships between the components of the
software.
49
Relation Between DFD & SD
DFD and SD are complementary to each other, working together to clearly describe the functional design of a software system.
6.5.1 DFD
DFD
A DFD diagram consists of four components:
D1 D1.1 D1.2
T1 T2
D3
* T3 T4
D2
D3.1 + D3.2
Note
A DFD specifies the operations without detailing how they are performed. Each node in the diagram can be further described with
another DFD, allowing for a hierarchical decomposition of processes.
Example :
A Software that processes a text document by splitting it into individual words. It then checks each word against a dictionary. If the word
exists in the dictionary, it is marked as correct. Otherwise, the software notifies the user and allows them to decide whether the word is valid.
If the user identifies the word as incorrect, it is added to the list of misspelled words. If the user confirms the word is valid, it is added to the
dictionary.
50
DC Split into MSL Legends
words
WL CWL DC : Document
* Update WL: Word List
MSL DCT: Dictionary
* L UMSL
* Verify UIW CWL: Correct Word List
IWL: Incorrect Word List
DCT IWL Notify * UD: User Decision
* UIWL: User Incorrect Word List
UCW MSL: Miss Spelled Word List
L Update UMSL: Updated MSL
DC UCWL: User Correct Word List
UD UDCT
UDCT: Updated DCT
6.5.2 SD
SD
A structure diagram is a hierarchical representation of a system in the form of a tree. It illustrates how the transformation elements of
a Data Flow Diagram (DFD) can be implemented within the hierarchical units of software architecture.
51
Symboles
Symboles
Tree Nodes
• Synchronisation Unit : The root node at the top represent the the global idea of the software
• Transformation Unit : The parent node has to point to at least one other units , represent a function of the software
• Input/Output Unit : The leaf node same as parent node just never points to another unit
Note
Synchronisation Unit’s Role
The synchronisation unit (root node) never creates the data it only pass it to other units.
No Link Between Unit Of Same Level
There can be link between units with simple arrow only with units of different level.
SD Level
It’s the number of levels beside the root node (don’t count the synchronisation unit).
52
Synchronisation
Unit
A
X
Z
Z
X
Tranformation
Unit B C D
I I Tranformation Output
d
Unit Unit
E F
Input Output
Unit Unit
Example :
We will take same example of word checker, we will make level 1 SD then level 2 SD
Level 1 SD :
To Correct
UMSL
DC,DCT,MSL
DC WL UDCT
CWL, UD UD
IWL
WL IWL
UD
Update Update
Read Split Verify Notify
Dictionary Miss-Spelled
53
Level 2 SD :
To Correct
DC,DCT,MSL
CWL,
IWL
DC WL
WL
IWL
UDCT UD UMSL
UD
UD
Update Update
Notify
Dictionary Miss-Spelled
Sequence Diagram
A sequence diagram illustrates the dynamic behavior of a system over time (notion of time). It visualizes the messages exchanged
between objects/actors and is read from top to bottom.
54
Symboles :
Symboles
ObjectName
Rectangle represent internal object of the software.
sendingMessage
A horizontal rectangle represents the activation
of an object or actor, indicating when it is Self
performing a task. During this time, the object can Call
returnMessage
send messages, receive responses, and make
self-calls.
55
Example :
Qoute Demand
Calculating Price
purchase
verification
Calculating Sold
Qoute
Creation Object
Destruction
acknowledgment
X
State Diagram
A state diagram illustrates how the state of an object changes in response to events.
56
Symboles :
Symboles
Note
We can have only one initial state , but we can have many final state.
57
Example :
]
em
command
bl
ro
delivered
oP
[N
ed
er
liv
De
expedition [nbObj>20]
Command in Command in
preparation delivery
initial Ca
nc Lo
state ele
d[
st
[P
nb ro
Ob bl
j<=
20 em
] ]
Canceled
command Lost
command
Activity Diagram
An activity diagram describes the progression of activities within the system and outlines the logical flow of processes.
58
Symboles :
Symboles
Fork
To receive signal
receive signalName
59
Example :
Activity 1
Activity 2
if condition else
Activity 3 Activity 4
Activity 5
60
Commercial Director Stock
Activity 1 Activity 2
Activity 3
Activity 5
Note
• We can have only one begin , but we can have end.
• Even though activity diagram has the notion of state it focuses more on the logical flow of activities of the system.
Definition
A design pattern describes proven and abstract solutions to recurring problems in software design.
61
Why Proven
Proven solutions have been tested on real projects, ensuring reliability and effectiveness.
Why Abstract
Abstract solutions can be adapted and customized to meet specific needs.
Why Recurring
We want model for recurring problems to address patterns in design problems that repeat across different contexts.
History
The concept of design patterns was first introduced by Christopher Alexander in the field of architecture. It was later adapted to the
field of computer science in 1977.
Categories :
The first influential book on design patterns, Design Patterns: Elements of Reusable Object-Oriented Software by the ”Gang of Four”
(Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides), was published in its second edition in 1995. It presents a collection of 23
design patterns, classified into three categories.
62
Behavioral Design Pattern
Focuses on the interaction and communication between objects to define the behavior of an application, such as the Observer pattern.
Note
The design patterns from the ”Gang of Four” are intended for object-oriented design.
Pros:
• Solves recurring problems with proven and reliable solutions.
• Improves quality and speed.
• Design patterns provide a common language for communication between designers.
• Design patterns are independent of implementation languages and sufficiently generic (abstract) to be applied in various situations.
Cons:
• Design patterns need to be mastered and thoroughly studied.
63
Some Design Pattern:
Singleton:
Singleton is a creational design pattern that aims to limit the instanciation of the a class to only one object and give global acess to it.
+ Singleton
- instance: Singleton
- Singleton()
+ getInstance(): Singleton
Explication
We first initialize a static private attribut called instance to null , when ever we want to get instance of singleton we call the public static
method getInstance that checks if instance is null if yes it will call the private constructor and in either case it returns the instance
Java Code:
64
1 public class Main {
2
3 public static void main ( String [] args ) {
4
5 Singleton . getInstance () ;
6 Singleton . getInstance () ;
7 }
8
9 }
Output:
Instance Of Singleton
Example:
+dataBaseManager
- instance: dataBaseManager
- connectionString: String
- user: String
- password: String
- pdb: String
- server: String
- dataBaseManager()
+ getInstance(): dataBaseManager
Java Code:
65
1 public class dataBas e Ma na ge r {
2 private static d a ta Ba s eM an ag e r instance = null ;
3 private String c o n n e c t i o n S t r in g ;
4 private String user = " system " ;
5 private String password = " 1234 " ;
6 private String pdb = " XE " ;
7 private String server = " localhost :1521 " ;
8
9 private dataBaseM an a ge r () {
10 connectionSt r i ng = " system /1234// localhost :1521/ XE " ;
11 System . out . println ( " d at aB as e Ma na ge r Initialized " ) ;
12 }
13
14
15
16 public static dat aB a se Ma na g er getInstance () {
17 if ( instance == null ) {
18 instance = new d a ta Ba se M an ag e r () ;
19 }
20 else {
21 System . out . println ( " Already Initialized " ) ;
22 }
23 return instance ;
24 }
25
26
27 public String g e t C o n n e c t i o n S t r i n g () {
28 return this . c o n n e c t i o n S t r in g ;
29 }
30
31 public String getUser () {
32 return this . user ;
33 }
34
35 public String getPDB () {
36 return this . pdb ;
37 }
38
39 public String getPassword () {
40 return this . password ;
41 }
42
43 public String getServer () {
44 return this . server ;
45 }
46
47 public void setUser ( String user ) {
48 this . connectio n S t r i n g = this . c o n n e c t i o n S t ri n g . replace ( this . user , user ) ;
49 }
50
51 public void setPassword ( String password ) {
52 this . connectio n S t r i n g = this . c o n n e c t i o n S t ri n g . replace ( this . password , password ) ;
53 }
54
55 public void setServer ( String server ) {
56 this . connectio n S t r i n g = this . c o n n e c t i o n S t ri n g . replace ( this . server , server ) ;
57 }
58
59 public void setPDB ( String pdb ) {
60 this . connectio n S t r i n g = this . c o n n e c t i o n S t ri n g . replace ( this . pdb , pdb ) ;
61 }
62
63 }
66
Output:
dataBaseManager Initialized
system /1234// localhost :1521/ XE
Dbaiot / psw // localhost :1521/ XE
Already Initialized
Composite:
The Composite pattern is a structural design pattern that imposes a hierarchical tree structure, consisting of simple elements and composite
elements.
+ Element
+ operation()
+ Leaf + Composite
- elementList: List<Element>
+ operation()
+ operation()
+ add(element: Element)
+ delete(element: Element)
Explication
The Element class serves as an abstract parent class with an unimplemented method, operation(). The Leaf class inherits from Element
and overrides the operation() method to provide its specific implementation. Similarly, the Composite class also inherits from Element
and implements operation(). However, it has an attribute that is a collection of Element objects. This design allows the collection to
hold both simple elements (Leaf) and complex elements (Composite), organizing them into a tree structure.
Note
Element can be an abstract class or an interface both implementations are valid.
67
Java Code:
68
1 public class Main {
2
3 public static void main ( String [] args ) {
4 Composite com = new Composite () ;
5
6 Leaf l1 = new Leaf () ;
7 Leaf l2 = new Leaf () ;
8 Leaf l3 = new Leaf () ;
9 Leaf l4 = new Leaf () ;
10 Leaf l5 = new Leaf () ;
11
12 com . add ( l1 ) ;
13 com . add ( l2 ) ;
14
15 Composite comInner1 = new Composite () ;
16 comInner1 . add ( l3 ) ;
17
18 Composite comInner2 = new Composite () ;
19 comInner2 . add ( l4 ) ;
20 comInner2 . add ( l5 ) ;
21
22 comInner1 . add ( comInner2 ) ;
23
24 com . add ( comInner1 ) ;
25
26 for ( Element element : com . g etEleme ntList () ) {
27 element . operation () ;
28 }
29
30 System . out . println ( " \ n " ) ;
31
32 com . printTree (0 , com . getEle mentList () ) ;
33
34 }
35
36 }
Output:
Leaf Operation
Leaf Operation
Composite Operation
Leaf
Leaf
Composite
Leaf
Composite
Leaf
Leaf
69
Graphical Representation Of The Composite
Composite
Leaf Leaf
Example:
+ GeoFrom
+ draw()
+ simpleForm + complexForm
+ draw() + draw()
+ add(form: GeoForm)
+ delete(form: GeoForm)
<<enumeration>>
formType
Line
Circle
Triangle
Square
70
Java Code:
71
1 import java . util . LinkedList ;
2 import java . util . List ;
3
4 public class complexForm extends GeoForm {
5 private List < GeoForm > formList = new LinkedList < >() ;
6
7 @Override
8 public void draw () {
9 System . out . println ( " Draw Complexe Form " ) ;
10 }
11
12 public void add ( GeoForm form ) {
13 this . formList . add ( form ) ;
14 }
15
16 public void delete ( GeoForm form ) {
17 this . formList . remove ( form ) ;
18 }
19
20 public List < GeoForm > getFormList () {
21 return this . formList ;
22 }
23
24 public void printTree ( int deepness , List < GeoForm > formList ) {
25 for ( GeoForm form : formList ) {
26 if ( form instanceof simpleForm ) {
27 simpleForm sim = ( simpleForm ) form ;
28 System . out . println ( " " . repeat ( deepness ) + sim . getType () ) ;
29 }
30
31 else if ( form instanceof complexForm ) {
32 ++ deepness ;
33 System . out . println ( " " . repeat ( deepness ) + " Complex " ) ;
34 complexForm com = ( complexForm ) form ;
35 printTree ( deepness +1 , com . formList ) ;
36 }
37 }
38 }
39
40 }
72
1 public class Main {
2
3 public static void main ( String [] args ) {
4 simpleForm sim1 = new simpleForm ( " line " ) ;
5 simpleForm sim2 = new simpleForm ( " circle " ) ;
6 simpleForm sim3 = new simpleForm ( " square " ) ;
7 simpleForm sim4 = new simpleForm ( " triangle " ) ;
8
9 complexForm com = new complexForm () ;
10 com . add ( sim1 ) ;
11 com . add ( sim4 ) ;
12
13 complexForm comInner2 = new complexForm () ;
14 comInner2 . add ( sim1 ) ;
15 comInner2 . add ( sim1 ) ;
16
17 complexForm comInner1 = new complexForm () ;
18 comInner1 . add ( sim3 ) ;
19 comInner1 . add ( sim2 ) ;
20
21 comInner1 . add ( comInner2 ) ;
22
23 com . add ( comInner1 ) ;
24
25 for ( GeoForm form : com . getFormList () ) {
26 form . draw () ;
27 }
28
29 System . out . println ( " \ n " ) ;
30
31 com . printTree (0 , com . getFormList () ) ;
32
33
34
35 }
36
37 }
Output:
Draw LINE
Draw TRIANGLE
Draw Complexe Form
LINE
TRIANGLE
Complex
SQUARE
CIRCLE
Complex
LINE
LINE
73
Observer:
The Observer pattern is a behavioral design pattern.It monitors the state of a subject object, and when the state changes, the subject notifies
the observers, which then update accordingly.
+ Subject
+ Observer
- observerList: List<Observer>
+ update(state: String)
+ add(observer: Observer)
+ delete(observer: Observer)
+ notify()
+ concretSubject
+ concretObserver
- state: String
+ update(state: String)
+ getState() : String
+ setState(state: String)
Explication
The Observer is an abstract class that defines an unimplemented method, update(state), which is executed each time the state
changes. The Subject is also an abstract class. It holds a collection of observers and defines unimplemented methods: add(observer),
delete(observer), and notify(). The notify() method calls the update method of each observer when the state changes. A ConcreteOb-
server inherits from Observer and implements the update method. A ConcreteSubject inherits from Subject, overrides all unimplemented
methods, and includes a state attribute with its getter and setter. Whenever the setter is called, the notify() method is invoked within
its body to ensure all observers are updated.
Note
Subject and Observer can be an abstract class or an interface both implementations are valid.
74
Java Code:
75
1 public class c oncretSu bject extends Subject {
2
3 private String state ;
4
5 @Override
6 public void add ( Observer observer ) {
7 this . ge tO b se rv er L is t () . add ( observer ) ;
8
9 }
10
11 @Override
12 public void delete ( Observer observer ) {
13 this . ge tO b se rv er L is t () . remove ( observer ) ;
14 }
15
16 @Override
17 public void no ti f yO bs er v er s () {
18 for ( Observer obs : ge t Ob se rv e rL is t () ) {
19 obs . update ( this . state ) ;
20 }
21 }
22
23 public String getState () {
24 return this . state ;
25 }
26
27 public void setState ( String state ) {
28 this . state = state ;
29 System . out . println ( " Setting state to " + state ) ;
30 n ot if yO b se rv er s () ;
31 }
32
33 }
76
Output:
Example:
+ Teacher + Student
+ concretSubject
77
Java Code:
78
1 public class c oncretTe acher extends Teacher {
2
3 private String activity ;
4
5 @Override
6 public void add ( Student student ) {
7 getS tudentLi st () . add ( student ) ;
8 }
9
10 @Override
11 public void delete ( Student student ) {
12 getS tudentLi st () . remove ( student ) ;
13 }
14
15 @Override
16 public void not ifyStud ents () {
17 for ( Student student : getS tudentL ist () ) {
18 student . update ( this . activity ) ;
19 }
20 }
21
22 public String getActivity () {
23 return this . activity ;
24 }
25
26 public void setActivity ( String activity ) {
27 this . activity = activity ;
28 System . out . println ( " Teacher Setting Activity To " + activity ) ;
29 notif yStuden ts () ;
30 }
31
32
33 }
79
Output:
80