0% found this document useful (0 votes)
19 views

Conducting Object-Oriented Analysis and Design for Python Applications (Final)

This document is a competency-based learning material for a Programming (Python) Level III course, focusing on conducting object-oriented analysis and design for Python applications. It outlines the module's content, learning outcomes, and assessment criteria, emphasizing the application of object-oriented principles, SOLID principles, and system design. The module includes various learning activities and resources to facilitate self-paced learning and competency assessment.

Uploaded by

Khenny Labanero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Conducting Object-Oriented Analysis and Design for Python Applications (Final)

This document is a competency-based learning material for a Programming (Python) Level III course, focusing on conducting object-oriented analysis and design for Python applications. It outlines the module's content, learning outcomes, and assessment criteria, emphasizing the application of object-oriented principles, SOLID principles, and system design. The module includes various learning activities and resources to facilitate self-paced learning and competency assessment.

Uploaded by

Khenny Labanero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 176

COMPETENCY-BASED LEARNING

MATERIAL

Sector: INFORMATION AND COMMUNICATIONS TECHNOLOGY

Qualification Title: PROGRAMMING (PYTHON) LEVEL III

Unit of Competency: CONDUCT OBJECT-ORIENTED ANALYSIS AND DESIGN


FOR PYTHON APPLICATIONS

Module Title: CONDUCTING OBJECT-ORIENTED ANALYSIS AND DESIGN


FOR PYTHON APPLICATIONS

Digital Business Training Center


Pueblo De Panay, Brgy. Lawa-an
Roxas City, Capiz

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 1 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
HOW TO USE THIS MODULE

Welcome to the Module “Conducting Object-Oriented Analysis and Design for


Python Applications”. This module contains training materials and activities for you to
complete.

The unit of competency “Conduct Object-Oriented Analysis and Design for


Python Applications " contains knowledge, skills and attitudes required for a
Programming (Python) Level III course.

You are required to go through a series of learning activities to complete each of the
learning outcomes of the module. In each learning outcome there are Information
Sheets, Job Sheets, Operation Sheets, and Activity Sheets. Follow these activities on
your own and answer the Self-Check at the end of each learning activity.

If you have questions, don’t hesitate to ask your facilitator for assistance.

Recognition of Prior Learning (RPL)

You may already have some of the knowledge and skills covered in this module
because you have:
o been working for some time
o already have completed training in this area.

If you can demonstrate to your teacher that you are competent in a particular skill or
skills, talk to him/her about having them formally recognized so you don’t have to do the
same training again. If you have a qualification or Certificate of Competency from previous
training show it to your teacher. If the skills you acquired are still current and relevant to
this module, they may become part of the evidence you can present for RPL. If you are not
sure about the currency of your skills, discuss it with your teacher.

After completing this module ask your teacher to assess your competency.
The result of your assessment will be recorded in your competency profile. All the learning
activities are designed for you to complete at your own pace.

Inside this module you will find the activities for you to complete followed by
relevant information sheets for each learning outcome. Each learning outcome may have
more than one learning activity.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 2 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
PROGRAMMING (PYTHON) LEVEL III
COMPETENCY-BASED LEARNING MATERIALS

List of Competencies
No. Unit of Competency Module Title Code

Perform basic Python Performing basic Python


1. ICT0601914251301
programming programming

Conducting object-
Conduct object-oriented
oriented analysis and
2. analysis and design for ICT0601914251302
design for Python
Python applications
applications
Craft and refine Python Crafting and refining
applications employing Python applications
3. ICT0601914251303
advanced programming employing advanced
techniques programming techniques

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 3 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
MODULE CONTENT

UNIT OF COMPETENCY: Conduct Object-Oriented Analysis and Design for Python


Applications

MODULE TITLE: Conducting Object-Oriented Analysis and Design for Python


Applications

MODULE DESCRIPTOR:

This unit guides learners in applying Object-Oriented Analysis and Design (OOAD)
principles to Python programming. Learners explore Object-Oriented Concepts, delve
into SOLID principles integration in Python for code robustness, and learn to
systematically identify and validate system requirements. The unit also covers the
development of system designs and architectures in Python, providing learners with a
comprehensive skill set for crafting scalable and efficient solutions.

NOMINAL DURATION: 80 hours

LEARNING OUTCOMES NO. 1

EXAMINE OBJECT-ORIENTED CONCEPTS FOR PYTHON APPLICATIONS

Contents:

1. Principles of object-oriented programming.


2. Class and object concepts in Python.
3. Attributes and methods in Python classes.
4. Implementation of OOP Principles in Python.
5. Access modifiers
6. Analyzing OOP principles for Python.
7. Interpreting concepts of classes and objects in Python.
8. Defining attributes and methods for classes in Python.
9. Defining access modifier in Python.

Assessment Criteria:

1. Fundamental principles of object-oriented programming (OOP) are identified in


accordance with python syntax.
2. Concepts of classes and objects are explained in accordance with python
syntax.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 4 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
3. Attributes and methods associated with classes are defined in accordance with
python syntax.
4. Access modifiers are defined in accordance with python syntax.

Condition:

The Student/Trainees should have access/understand the following:

 Principles of object-oriented programming (OOP)


 Single Responsibility Principle (SRP)
 Open-closed principle (OCP)
 Liskov Substitution Principle (LSP)
 Interface Segregation Principle (ISP)
 Dependency Inversion Principle (DIP)
 System Requirements
 Modeling Techniques
 Principles of Generalization and Specialization
 Design specifications
 Design Principles
 Architectural Design
 System Design

Assessment Method:

1. Written Examination
2. Direct Observation

LEARNING OUTCOMES NO. 2

EXAMINE SOLID PRINCIPLES IN PYTHON

Contents:

1. Single Responsibility Principle (SRP).


2. Open-Closed Principle (OCP).
3. Liskov Substitution Principle (LSP).
4. Interface Segregation Principle (ISP).
5. Dependency Inversion Principle (DIP).
6. Code review and static analysis tools.
7. Designing classes and modules adhering to SRP.
8. Ensuring OCP through extension without modifying existing code.
9. Analyzing LSP through proper inheritance and polymorphism.
10. Analyzing ISP to create focused and specific interfaces.
11. Demonstrating DIP through inversion of control or dependency injection.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 5 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
12. Performing validation of SOLID principles through code reviews and static
analysis tools

Assessment Criteria:

1. Single Responsibility Principle (SRP) is identified based on industry practices.


2. Open-closed principle (OCP) is identified by allowing extension without
modifying existing code based on industry practices.
3. Liskov Substitution Principle (LSP) is utilized using proper inheritance and
polymorphism.
4. Interface Segregation Principle (ISP) is utilized to create focused and specific
interfaces based on industry practices.
5. Dependency Inversion Principle (DIP) is demonstrated through inversion of
control or dependency injection based on industry practices.
6. SOLID principles through code reviews and static analysis tools are validated in
accordance with industry practices.

Condition:

The Student/Trainees should have access with the following:

 Principles of object-oriented programming (OOP)


 Single Responsibility Principle (SRP)
 Open-closed principle (OCP)
 Liskov Substitution Principle (LSP)
 Interface Segregation Principle (ISP)
 Dependency Inversion Principle (DIP)
 System Requirements
 Modeling Techniques
 Principles of Generalization and Specialization
 Design specifications
 Design Principles
 Architectural Design
 System Design
Assessment method:

1. Written Examination
2. Direct Observation

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 6 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
LEARNING OUTCOMES NO. 3

IDENTIFY SYSTEM REQUIREMENTS

Contents:

1. Techniques for gathering and documenting system requirements.


2. Modeling techniques.
3. Principles of generalization and specialization.
4. Identifying stakeholder needs.
5. Utilizing modeling techniques.
6. Applying principles of generalization and specialization.

Assessment Criteria:

1. System requirements are identified and documented based on stakeholder


needs.
2. Modeling techniques such as use case and activity diagrams are utilized to
represent system functionality based on user interactions, system processes,
and workflows.
3. Class diagrams are developed to depict the static structure of the system based
on the identified system requirements.
4. Sequence diagrams are created to illustrate the dynamic interactions among
objects based on the identified system requirements.
5. Principles of generalization and specialization are applied in creating class
hierarchies based on common attributes and behaviors of classes.

Condition:

The Student/Trainees should have access with the following:

 Principles of object-oriented programming (OOP)


 Single Responsibility Principle (SRP)
 Open-closed principle (OCP)
 Liskov Substitution Principle (LSP)
 Interface Segregation Principle (ISP)
 Dependency Inversion Principle (DIP)
 System Requirements
 Modeling Techniques
 Principles of Generalization and Specialization
 Design specifications
 Design Principles
 Architectural Design
 System Design

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 7 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Assessment method:

1. Written Examination
2. Direct Observation

LEARNING OUTCOMES NO. 4

DEVELOP SYSTEM DESIGN AND ARCHITECTURE

Contents:

1. Translating system requirements into design specifications.


2. Effective Documentation Practices for Design Decision Management.
3. Class specifications including attributes and methods.
4. System Design and Architecture.
5. Translating requirements into detailed design specifications.
6. Creating design specifications.
7. Implementing design principles.
8. Developing system design and architecture.

Assessment Criteria:

1. System requirements and analysis models are translated into design


specifications based on best practices.
2. Design principles are applied to enhance the modularity and maintainability of
the system based on design patterns such as SOLID principles.
3. Architectural design is developed based on design specifications.
4. System design is developed in accordance to system requirements.

Condition:

The Student/Trainees should have access with the following:

 Principles of object-oriented programming (OOP)


 Single Responsibility Principle (SRP)
 Open-closed principle (OCP)
 Liskov Substitution Principle (LSP)
 Interface Segregation Principle (ISP)
 Dependency Inversion Principle (DIP)
 System Requirements
 Modeling Techniques
 Principles of Generalization and Specialization
 Design specifications

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 8 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
 Design Principles
 Architectural Design
 System Design
Assessment Method:

1. Written Examination
2. Direct Observation

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 9 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
LEARNING EXPERIENCE
Learning Outcome 1
Learning Activities Special Instructions
1. Read Information Sheet No. 1.1-1
2. Answer Self-Check 1.1-1 Compare answers with the answer key
1.1-1. You are required to get all answers
correct. If not, read the information
sheets again to answer all questions
correctly.
3. Read Information Sheet No. 1.1-2
4. Answer Self-Check 1.1-2 Compare answers with the answer key
1.1-2. You are required to get all answers
correct. If not, read the information
sheets again to answer all questions
correctly.
5. Read Information Sheet No. 1.1-3
6. Answer Self-Check 1.1-3 Compare answers with the answer key
1.1-3. You are required to get all answers
correct. If not, read the information
sheets again to answer all questions
correctly.
7. Read Information Sheet No. 1.1-4
8. Answer Self-Check 1.1-4 Compare answers with the answer key
1.1-4. You are required to get all answers
correct. If not, read the information
sheets again to answer all questions
correctly.
9. Read Information Sheet No. 1.1-5
10. Answer Self-Check 1.1-5 Compare answers with the answer key
1.1-5. You are required to get all answers
correct. If not, read the information
sheets again to answer all questions
correctly.
11. Perform Task Sheet No. 1.1-5 Evaluate your own work using
the Performance Criteria.
Present your work to your trainer for
evaluation and recording.
After doing all activities of this LO,
you are ready to proceed to the next
LO.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 10 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
INFORMATION SHEET 1.1-1

PRINCIPLES OF OBJECT-ORIENTED PROGRAMMING (OOP)

Learning Objectives:

After reading this INFORMATION SHEET, you should be able to:

1. Understand the fundamental principles of Object-Oriented Programming


(OOP).
2. Explain how abstraction, encapsulation, inheritance, and polymorphism are
applied in Python.
3. Identify the advantages of using OOP to structure code and enhance
reusability.

Object Oriented Programming is a basic notion in Python, allowing developers to


create modular, maintainable, and scalable programs. Understanding the key OOP
principles—classes, objects, inheritance, encapsulation, polymorphism, and abstraction
—allows programmers to fully utilize Python's OOP capabilities to create elegant and
efficient solutions to complicat ed problems.
OOPs Concepts in Python
 Class in Python
 Objects in Python
 Polymorphism in Python
 Encapsulation in Python
 Inheritance in Python
 Data Abstraction in Python

Python OOP Concepts

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 11 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Principles of Object – Oriented Programming (OOP)

Object-Oriented Programming (OOP) is a programming paradigm based on the


concept of "objects," which can contain data (attributes) and code (methods).
 Inheritance: Inheritance lets one class inherit the properties and methods of
another class. This helps in reusing code.
 Polymorphism: Allowing objects of different classes to be treated as objects of a
common super class, typically through inheritance. Polymorphism allows the
same method to do different things based on which class is calling it.
 Encapsulation: Bundling data and methods that operate on the data within one
unit, such as a class, and restricting access to some of the object's components.
 Abstraction: Hiding the complex implementation details and exposing only the
necessary parts to the user.

Why OOP?
 Improve Code Organization: By structuring code into classes and objects, OOP
helps in organizing complex systems into more manageable, modular
components. This structure makes it easier to understand and maintain the code.
 Enhance Reusability: OOP promotes the use of existing code through
inheritance and polymorphism, allowing developers to reuse and extend
functionalities without duplicating code. This reduces redundancy and speeds up
development.
 Increase Scalability: OOP supports the design of scalable systems by
encouraging a hierarchical structure. This makes it easier to add new features or
modify existing ones without disrupting the entire system.
 Facilitate Maintainability: With OOP, changes to one part of the system are less
likely to affect others, thanks to encapsulation. This separation of concerns makes
it easier to update and fix bugs in the codebase.
 Improve Collaboration: The modular nature of OOP makes it easier for teams to
work on different components concurrently. Each team member can focus on
specific classes or objects, enhancing productivity and reducing integration
issues.
 Model Real-World Scenarios: OOP allows for the modeling of real-world entities
as classes and objects, making it easier to conceptualize and implement solutions
that reflect real-world relationships and behaviors.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 12 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF CHECK 1.1-1

Multiple Choice
Directions: Read and understand the questions and circle the letter of the correct answer.
1. Which of the following principles of OOP involves bundling data and
methods that operate on the data within one unit?
a. Inheritance

b. Polymorphism

c. Encapsulation

d. Abstraction
2. What is the primary advantage of using inheritance in OOP?
a. To hide complex implementation details from the user

b. To allow one class to inherit the properties and methods of another class

c. To enable objects of different classes to be treated as objects of a common


superclass

d. To group related data and methods into one unit


3. Which OOP principle allows different classes to define the same method,
but each class can have its own unique implementation of that method?
a. Encapsulation

b. Polymorphism

c. Inheritance

d. Abstraction

4. What is the purpose of abstraction in Object-Oriented Programming?


a. To expose all details of the implementation to the user

b. To allow objects to inherit properties from multiple classes

c. To hide complex implementation details and expose only the necessary parts
to the user

d. To allow one class to be treated as another

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 13 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
5. How does OOP improve code organization?
a. By hiding all implementation details from the user

b. By structuring code into functions and procedures

c. By structuring code into classes and objects, making complex systems more
manageable

d. By using loops and conditional statements more effectively

6. What is the advantage of encapsulation in OOP?


a. It allows objects of different classes to interact freely without restrictions.

b. It groups related data and methods into one unit and restricts access to some
components.

c. It allows multiple classes to share the same properties and methods.

d. It enables the creation of new classes based on existing ones.

7. In OOP, how does polymorphism benefit the code structure?


a. By grouping data and methods into one unit

b. By enabling code reusability and allowing methods to do different things based


on the class calling them

c. By allowing one class to inherit the properties and methods of another class

d. By hiding complex implementation details from the user

8. Which of the following best describes the purpose of OOP in relation to real-
world scenarios?
a. OOP makes it easier to model real-world entities and relationships using
classes and objects.

b. OOP is only used to structure code into functions and procedures.

c. OOP simplifies the use of global variables across a codebase.

d. OOP eliminates the need for data encapsulation.

9. What is a key benefit of using OOP in collaborative software development?


a. OOP allows developers to work on the same function simultaneously.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 14 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
b. OOP promotes modularity, enabling teams to work on different components
concurrently.

c. OOP reduces the need for comments and documentation.

d. OOP automatically generates code documentation.

10. How does OOP facilitate the maintainability of a codebase?


a. By allowing all parts of the system to be updated simultaneously.

b. By keeping code in a single, large module.

c. By separating concerns through encapsulation, making it easier to update and


fix bugs without affecting other parts.

d. By removing the need for classes and objects.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 15 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 1.1-1

Multiple Choice

1. c

2. b

3. b

4. c

5. c

6. b

7. b

8. a

9. b

10. c

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 16 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
INFORMATION SHEET 1.1-2

CLASSES AND OBJECTS IN PYTHON

Learning Objectives:

After reading this INFORMATION SHEET, you should be able to:

1. Understand the concept of classes and objects and how they relate to each other
in Python.
2. Define and implement classes in Python.
3. Explain how objects are instances of classes and how they interact with class
attributes and methods.

Class Concepts
A class is a collection of objects. A class contains the blueprints, or prototypes,
from which things are produced. A class combines data (attributes) and methods
(functions) that work with that data into a single, solid unit.
Defining Class:
 Classes are created by keyword class

This example shows how to define a simple class in Python. The Car class is defined but
doesn’t have any attributes or methods yet.

Object Concepts
Objects are individual instances of classes, containing specific attributes and
methods.
Creating an Object:
 You create an object by calling the class as if it were a function.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 17 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Here, my_car is an instance of the Car class, meaning it's an object created using the
Car blueprint.

Interaction Between Classes and Objects


Objects interact with class attributes and methods to perform actions or hold data.

This example shows how an object (my_car) interacts with the class attributes (make
and model). The Car class initializes these attributes, and they can be accessed through
the object.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 18 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF CHECK 1.1-2

Multiple Choice
Directions: Read and understand the questions and circle the letter of the correct answer.
1. What is a class in Python?
a. A specific instance of an object
b. A blueprint for creating objects
c. A function that performs an action
d. A method that modifies an attribute

2. Which of the following correctly defines a class in Python?


a. class myClass()
b. def class MyClass:
c. class MyClass:
d. MyClass class:

3. What is an object in Python?


a. A blueprint that defines attributes and methods
b. A single unit that bundles data and functions
c. An instance of a class
d. A method that operates on data

4. How do you create an object from a class in Python?


a. my_object = ClassName()
b. my_object = class ClassName:
c. my_object = class()
d. my_object = ClassName

5. In the example provided, what does my_car represent?


a. A class definition
b. A method inside the Car class
c. An attribute of the Car class
d. An object (instance) of the Car class

6. Which of the following statements best describes the relationship between


a class and an object?

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 19 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
a. A class is a specific instance of an object.
b. An object is a blueprint that defines how a class works.
c. A class is a blueprint, and an object is an instance of that class.
d. An object and a class are the same things.

7. Which of the following correctly accesses an attribute of an object in


Python?
a. object.attribute
b. object(attribute)
c. attribute.object
d. object->attribute

8. What happens when an object interacts with a class method?


a. The method is deleted from the class.
b. The method modifies the object's attributes or performs an action.
c. The object is destroyed.
d. The class is redefined.

9. Which of the following is NOT true about classes in Python?


a. Classes can bundle data and functions together.
b. Classes are instances of objects.
c. Classes serve as blueprints for creating objects.
d. Classes can have attributes and methods.

10. In the example, what will happen if you try to access an attribute that
doesn’t exist in the my_car object?
a. The attribute will be created automatically.
b. Python will raise an AttributeError.
c. The program will silently fail.
d. The class definition will be modified to include the attribute.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 20 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 1.1-2

Multiple Choice

1. b

2. c

3. c

4. a

5. d

6. c

7. a

8. b

9. b

10. b

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 21 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
INFORMATION SHEET 1.1-3

ATTRIBUTES AND METHODS IN PYTHON CLASSES

Learning Objectives:

After reading this INFORMATION SHEET, you should be able to:

1. Define and initialize attributes in Python classes.


2. Understand the role of methods in manipulating class data.
3. Apply attributes and methods to create functional class structures in Python.

Attributes
Attributes are variables defined within a class, representing the data for each object.
Initializing Attributes:
 The __init__() method is a special method that initializes an object’s attributes
when the object is created.

This example defines the Car class with two attributes, make and model. The __init__()
method sets these attributes when a new Car object is created.
Method
Methods are functions defined within a class that manipulate data or perform
operations using the class’s attributes.
 Defining Methods:

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 22 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
In this example, the Car class has a method called start_engine. This method accesses
the make and model attributes to print a message when the engine is started.

 Using Methods:

The start_engine method is called using the object my_car. The method uses the self
keyword to access the attributes of the object and performs the action of printing a
message.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 23 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF CHECK 1.1-3

Part 1: Multiple Choice


Directions: Read and understand the questions and circle the letter of the correct answer.
1. The __init__() method is used to:
o A) Delete an object’s attributes

o B) Modify an object’s attributes

o C) Initialize an object’s attributes

o D) Access an object’s attributes

2. Attributes in a class represent the:


o A) Methods for each object

o B) Data for each object

o C) Operations for each object

o D) Functions for each object

3. Methods in a class are:


o A) Attributes that manipulate data

o B) Variables that store information

o C) Functions that manipulate data or perform operations using the class’s


attributes
o D) Objects that perform actions

4. The keyword __________ is used within methods to access the attributes of an


object.
o A) class

o B) object

o C) self

o D) method

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 24 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
5. The start_engine method in the Car class accesses the __________ and
__________ attributes to print a message.
o A) color, type

o B) make, model

o C) speed, fuel

o D) brand, year

Part 2: True or False


Directions: Read and understand the questions and put T if it is True and F if it is False.
_____1. The __init__() method is optional when defining a class in Python.
_____2. Attributes can only be initialized within the __init__() method.
_____3. Methods in a class cannot access the attributes of an object.
_____4. The self keyword is automatically passed to every method defined in a class.
_____5. Methods in a class are similar to functions, but they are associated with class
instances.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 25 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 1.1-3

Part 1: Multiple Choice

1. c

2. b

3. c

4. c

5. b

Part 2: True or False

1. T (The __init__() method is not required, but it is commonly used to initialize


object attributes.)
2. F (Attributes can be defined and initialized elsewhere in the class, though
__init__() is the most common place for initialization.)
3. F (Methods can access and modify the attributes of an object using the self
keyword.)
4. T (The first parameter of every method in a class is self, which refers to the
instance of the object calling the method.)
5. T (Methods are functions defined within a class and are associated with instances
of that class.)

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 26 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
INFORMATION SHEET 1.1-4

ACCESS MODIFIERS IN PYTHON

Learning Objectives:

After reading this INFORMATION SHEET, you should be able to:

1. Define and explain the significance of public, protected, and private access
modifiers in Python.
2. Understand how access control protects data integrity.
3. Implement access modifiers in Python to restrict data visibility and
manipulation.

PUBLIC, PROTECTED, AND PRIVATE


Public Attributes and Methods:
 Public attributes and methods are accessible from anywhere in your code, both
within and outside the class. There are no restrictions on accessing these parts.

The brand attribute and show_brand method is public, so they can be accessed directly
outside the class without any restrictions.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 27 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Protected Attributes and Methods:
 Protected properties and methods are identified by a single underscore _ before
their names. They are meant to be accessed only by the class and its subclasses.
While Python does not require strict access control, it is standard practice to state
that these parts should not be accessed directly from outside the class.

The brand attribute and show_brand method are protected by convention (using a single
underscore). While they can still be accessed directly, it's generally discouraged.
Private Attributes and Methods:
 Private attributes and methods are indicated by a double underscore __ before
their name. These are intended to be inaccessible directly from outside the class.
Private parts are not accessible outside the class unless through specific
methods provided by the class itself.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 28 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
The __brand attribute and __show_brand method are private and cannot be accessed
directly from outside the class. The get_brand method provides a controlled way to
access the private __brand attribute.

Purpose of Access Control:


 Data Integrity: By using access modifiers, you ensure that the internal state of an
object cannot be altered accidentally or maliciously. This protects the consistency
and reliability of the data.
 Encapsulation: Helps in hiding the internal implementation details of a class and
only exposes what is necessary, leading to a cleaner and more maintainable
codebase.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 29 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF CHECK 1.1-4

Short Answer
Directions: Answer each question in one or two sentences. Be clear and concise in your
responses.
A. Explain the difference between protected and private attributes in Python.

B. Describe how access control helps in maintaining data integrity in Python.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 30 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 1.1-4

Short Answer

Answer Base Only

A. Protected attributes are indicated by a single underscore _ and are intended to be


used within the class and its subclasses. However, they can still be accessed
directly from outside the class, though it's generally discouraged. Private
attributes, indicated by a double underscore __, are intended to be inaccessible
directly from outside the class. Python uses name mangling to make private
attributes harder to access, providing better data protection.

B. Access control helps maintain data integrity by restricting how and where
attributes and methods can be accessed or modified. By using protected and
private modifiers, you ensure that the internal state of an object is not altered in
unintended ways. This prevents accidental changes or malicious manipulation,
ensuring that the data remains consistent and reliable.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 31 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
INFORMATION SHEET 1.1-5

IMPLEMENTATION OF OOP PRINCIPLES IN PYTHON

Learning Objectives:

After reading this INFORMATION SHEET, you should be able to:

1. Implement OOP principles such as inheritance, encapsulation, and polymorphism


in Python classes.
2. Understand how these principles improve code reusability and maintainability.
3. Demonstrate the application of OOP principles in solving real-world programming
problems.

Inheritance
Inheritance allows a class to inherit attributes and methods from another class.
The class that is inherited from is called the parent or base class, and the class that
inherits is called the child or derived class.

The Dog class inherits the __init__ method from the Animal class, which initializes the
name attribute. The Dog class overrides the speak method to provide a specific
implementation for dogs.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 32 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Encapsulation
Encapsulation is the practice of bundling data (attributes) and methods that
operate on the data into a single unit or class, and restricting access to some of the
object's components.

The __name and __salary attributes are private, ensuring they cannot be modified
directly from outside the class. The get_details and set_salary methods provide
controlled access to these attributes.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 33 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Polymorphism
Polymorphism allows different classes to be treated as instances of the same
class through a common interface. Typically, this is achieved through method overriding.

The Parrot and Sparrow classes both override the sound method from the Bird class.
The make_sound function treats instances of both Parrot and Sparrow as Bird objects,
allowing for flexibility in handling different bird sounds.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 34 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF CHECK 1.1-5

True or False
Directions: Read and understand the questions and put T if it is True and F if it is False.

_____1. Inheritance allows a derived class to access the private attributes of the base
class.

_____2. Encapsulation helps in protecting the internal state of an object by providing


controlled access through methods.

_____3. Polymorphism means that different classes must have the same methods with
the exact same implementation.

_____4. Method overriding in polymorphism allows a derived class to provide a different


implementation of a method that is already defined in its base class.

_____5. Encapsulation involves exposing all attributes and methods of a class to the
outside world.
_____6. The __init__ method in Python classes is used to define static methods.
_____7. A protected attribute in a Python class is indicated by a double underscore.
_____8. In Python, all methods within a class are implicitly public unless otherwise
specified.
_____9. Polymorphism can be implemented using method overloading in Python.
_____10. A class method in Python is a method that operates on class-level data rather
than instance-level data.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 35 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 1.1-5

True or False

1. F (Private attributes of the base class are not accessible from the derived class.)

2. T (Encapsulation hides internal data and provides controlled access through


methods.)

3. F (Polymorphism allows different classes to have methods with the same name but
potentially different implementations.)

4. T (Method overriding allows the derived class to provide a specific implementation


of a method defined in the base class.)

5. F (Encapsulation involves restricting access to some attributes and methods while


exposing only what is necessary.)
6. T (The __init__ method is used to initialize instance attributes, not to define static
methods.)

7. T (A protected attribute is indicated by a single underscore, while a double


underscore indicates a private attribute.)

8. T (Methods are public by default in Python unless prefixed with an underscore


(protected) or double underscore (private).)

9. T (Python does not support method overloading directly; it uses method overriding
and default arguments to achieve polymorphism.)

10. T (Class methods, defined with the @classmethod decorator, operate on class-
level data rather than instance-level data.)

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 36 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 37 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
TASKS SHEET 1.1-5
Title: Implementation of OOP Principles in Python
Performance Objective:
Implement the OOP principles of inheritance, encapsulation, and polymorphism in
Python classes. Understand how these principles improve code reusability and
maintainability and demonstrate their application in solving real-world programming
problems.
Supplies/Materials: Computer with Python installed

Equipment: Computer with Python installed

Steps/Procedure:
1. Inheritance Implementation
 Create a base class Vehicle with attributes make and model. Define a method
display_info() to print these attributes.
 Create a derived class Car that inherits from Vehicle and adds an attribute
fuel_type. Override display_info() in the Car class to include the fuel type.
 Test the classes by creating an instance of Car and calling display_info().
2. Encapsulation Implementation
 Define a class BankAccount with private attributes __account_number and
__balance. Include methods for initializing these attributes, depositing funds,
withdrawing funds, ad checking the balance.
 Create an instance of BankAccount, perform a deposit and a withdrawal, and
then check the balance.
3. Polymorphism Implementation
 Define a base class Shape with a method area(). Create two derived classes:
Rectangle and Circle, each implementing their own version of area().
 Write a function print_area(shape) that accepts any Shape object and prints its
area.
 Create instances of Rectangle and Circle, and use print_area() to display their
areas.

Assessment Method:
Demonstration with Oral Questioning

PERFORMANCE CRITERIA CHECKLIST 1.1-5


Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 38 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Did I? Yes No
Inheritance Implementation
1. Was a base class created with appropriate attributes and
methods?
2. Was a derived class successfully created, inheriting from the
base class?
3. Were additional attributes or methods added to the derived class
as needed?
4. Was method overriding correctly implemented in the derived
class?
5. Was the functionality of the derived class tested by creating an
instance and calling the necessary methods?
Encapsulation Implementation
6. Were private attributes defined and properly encapsulated within
a class?
7. Were methods for modifying and accessing the private attributes
implemented?
8. Was an instance of the class tested by performing operations
such as modifying or accessing the private attributes?
Polymorphism Implementation
9. Was a base class defined with a general method intended for
polymorphism?
10. Were derived classes created, each implementing its own
version of the general method?
11. Was a function or mechanism used to demonstrate
polymorphism across the derived classes?
12. Were the derived class instances correctly handled by the
polymorphic function?
Implementation of OOP Principles in Python
Comments/Suggestions:
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________

Trainer: _____________________________ Date: ______________________

LEARNING EXPERIENCE
Learning Outcome 2

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 39 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Learning Activities Special Instructions
1. Read Information Sheet 2.1-1
2. Answer Self-Check 2.1-1 Compare answers with the answer key
2.1-1. You are required to get all answers
correct. If not, read the information
sheets again to answer all questions
correctly.
3. Perform Task Sheet 2.1-1 Evaluate your own work using the
Performance Criteria. Present your work
to your trainer for evaluation and
recording.

4. Read Information Sheet 2.1-2


5. Answer Self-Check 2.1-2 Compare answers with the answer key
2.1-2. You are required to get all answers
correct. If not, read the information
sheets again to answer all questions
correctly.
6. Perform Task Sheet 2.1-2 Evaluate your own work using the
Performance Criteria. Present your work
to your trainer for evaluation and
recording.

7. Read Information Sheet 2.1-3


8. Answer Self-Check 2.1-3 Compare answers with the answer key
2.1-3. You are required to get all answers
correct. If not, read the information
sheets again to answer all questions
correctly.
9. Perform Task Sheet 2.1-3 Evaluate your own work using the
Performance Criteria. Present your work
to your trainer for evaluation and
recording.

10. Read Information Sheet 2.1-4

11. Answer Self-Check 2.1-4 Compare answers with the answer key
2.1-4. You are required to get all answers
correct. If not, read the information
sheets again to answer all questions
correctly.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 40 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
12. Perform Task Sheet 2.1-4 Evaluate your own work using the
Performance Criteria. Present your work
to your trainer for evaluation and
recording.

13. Read Information Sheet 2.1-5


14. Answer Self-Check 2.1-5 Compare answers with the answer key
2.1-5. You are required to get all answers
correct. If not, read the information sheets
again to answer all questions correctly.

15. Perform Task Sheet 2.1-5 Evaluate your own work using the
Performance Criteria. Present your work
to your trainer for evaluation and recording

16. Read Information Sheet 2.1-6


17. Answer Self-Check 2.1-6 Compare answers with the answer key
2.1-6. You are required to get all answers
correct. If not, read the information
sheets again to answer all questions
correctly.
After doing all activities of this LO,
you are ready to proceed to the next
LO

INFORMATION SHEET 2.1-1


SINGLE RESPONSIBILITY PRINCIPLE (SRP)

Learning Objectives:
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 41 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
After reading this INFORMATION SHEET, you should be able to:

1. Understand the Single Responsibility Principle (SRP) and how it applies to class
design in Python.

2. Design classes and modules with a single, specific responsibility, making them
easy to maintain and extend.

3. Recognize and refactor classes that violate SRP in existing Python code.

What is SOLID?

SOLID is an acronym representing five


fundamental principles of object-oriented
software design and architecture, identified by
Robert C. Martin (Uncle Bob) around the
2000s. The acronym SOLID was introduced by
Michael Feathers, after observing that the five
principles could fit into this word.

Following these principles can result in a


system that is more comprehensible, flexible,
and modular, which is easy to scale, modify,
and test.

Single Responsibility Principle (SRP)

The Single Responsibility Principle (SRP), the first of the five principles
of SOLID, is a fundamental concept in object-oriented software development. This
principle states that a class should have only one reason to change, meaning it should
be responsible for only one part of the software’s functionality. Martin describes
responsibility as an “axis of change” such that they represent possible rigidity in design.

Imagine a team in a restaurant. In this team, we have various functions: cooks,


waiters, and the manager. Each of these team members has a unique responsibility. The
cooks prepare the food, the waiters serve the food to the customers, and the manager
takes care of the restaurant’s administration. Imagine the chaos if a single person tried to
perform all these tasks, it would generate a totally inefficient and confusing system.

Similarly, a class in software should specialize in a single functionality or


responsibility. This makes maintenance easier, code comprehension better, and aids in
reusability.

Designing Classes

When designing classes, it’s crucial to break down larger classes into smaller
ones, each responsible for one specific task. This approach aligns with the Single

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 42 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Responsibility Principle (SRP) and enhances the overall design and maintainability of
your code. Each new class should handle a single responsibility, allowing for clearer
organization and easier management of your code. Here’s a step-by-step approach:

1. Identify Responsibilities:

 Analyze the current class to identify different responsibilities or tasks it


performs.

 Group related responsibilities together to determine how they can be


separated into distinct classes.

2. Create Focused Classes:

 For each responsibility, create a separate class that encapsulates that


task.

 Ensure each class has a clear, specific purpose and manages its own
data and methods related to that purpose.

3. Refactor Code:

 Move relevant methods and properties from the larger class to the
newly created classes.

 Adjust class interactions to maintain proper functionality while keeping


each class focused on its designated responsibility.

Benefits of Smaller, Focused Classes

1. Clarity: Smaller classes with a single responsibility are easier to understand.


Each class has a clear purpose, making the codebase more readable.

2. Maintainability: Changes are easier to manage when each class handles only
one aspect of the system. This reduces the risk of unintended side effects.

3. Testability: Focused classes are simpler to test. Unit tests can be more precise,
targeting specific functionalities without interference from unrelated code.

4. Reusability: Classes that do one thing well can be reused across different parts
of the application or even in other projects.

Consider the Example Below:

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 43 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
The class above violates the single responsibility principle. Why?

This Student class has three responsibilities – registering students, calculating


their results, and sending out emails to students.

The code above will work perfectly but will lead to some challenges. We cannot
make this code reusable for other classes or objects. The class has a whole lot of logic
interconnected that we would have a hard time fixing errors. And as the codebase grows,
so does the logic, making it even harder to understand what is going on.

To improve the design, we can break it down into smaller classes:

Now, each class has a single responsibility: StudentRegister handles student


registration, StudentResult takes care of calculating the student’s result, and
StudentEmails sends email.

The examples we used use just showed each class having one method – this is
mainly for simplicity. You can have as many methods as you want but they should be
linked to the responsibility of the class.

Now that we have separated the logic, our code is easier to understand as each
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 44 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
core functionality has its own class. We can test for errors more efficiently.

The code is now reusable. Before, we could only use these functionalities inside
one class but now they can be used in any class.

The code is also easily maintainable and scalable because instead of reading
interconnected lines of code, we have separated concerns so we can focus on the
features we want to work on.

SELF-CHECK 2.1-1

Multiple Choice

1. What does SRP stand for?


a) single refactor principle
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 45 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
b) simple responsibility protocol
c) single responsibility principle
d) system responsibility principle

2. Which of the following is one of the five SOLID principles?


a) simplified object logic
b) single responsibility principle
c) strategic object principle
d) system optimization protocol

3. Who introduced the acronym SOLID?


a) Robert C. Martin
b) Michael Feathers
c) James Gosling
d) Alan Turing

4. According to SRP, what should a class be responsible for?


a) multiple tasks
b) a single responsibility
c) any number of responsibilities
d) system-wide functionalities

5. What is the benefit of having a class follow the SRP?


a) it becomes harder to test
b) the class can change multiple parts simultaneously
c) it becomes easier to maintain and extend
d) it has more dependencies

6. Which of these is an example of a violation of SRP?


a) a class responsible only for registering students
b) a class that calculates student results, sends emails, and registers students
c) a class that performs database operations
d) a class that handles user input validation

7. How does SRP contribute to testability?


a) it makes tests more complex
b) it requires more methods per class
c) focused classes are simpler to test
d) it makes unit tests unnecessary

8. Which of the following is NOT a benefit of smaller, focused classes


following SRP?
a) clarity
b) reusability
c) higher complexity
d) maintainability

9. In the example discussed, what are the three responsibilities that should be
separated into different classes?
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 46 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
a) registering students, sending emails, printing receipts
b) sending emails, processing data, handling errors
c) registering students, calculating results, sending emails
d) printing invoices, handling login, logging data

10. Why does separating responsibilities into multiple classes make code more
maintainable?
a) it makes the code longer
b) each class can be updated independently without affecting others
c) it hides all responsibilities in one place
d) it increases the dependencies between classes

11. Which of the following is an advantage of refactoring a large class into


smaller classes?
a) it becomes less reusable
b) code becomes more readable and organized
c) it reduces the need for testing
d) it makes the code harder to modify

12. What is the 'axis of change' in SRP?


a) a measure of how many methods is in a class
b) a potential source of changes in the system
c) a way to group unrelated responsibilities
d) a technique to make classes handle multiple tasks

13. How can SRP help in scaling a software project?


a) by making classes handle more responsibilities
b) by simplifying code and breaking it down into smaller pieces
c) by ensuring all responsibilities are managed by one class
d) by reducing the need for new classes

14. What is an example of a well-designed class following SRP?


a) a class that both handles user input and processes data
b) a class that is responsible only for managing user input validation
c) a class that stores data and manages database connections
d) a class that generates reports and prints them

15. Why is reusability enhanced when classes follow the SRP?


a) because each class has multiple tasks
b) because smaller, focused classes can be used in various parts of the
application
c) because the class includes all necessary functionalities in one place
d) because it makes classes dependent on each other

ANSWER KEY 2.1-1

Multiple Choice

1. c
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 47 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
2. b

3. b

4. b

5. c

6. b

7. c

8. c

9. c

10. b

11. b

12. b

13. b

14. b

15. b

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 48 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
TASKS SHEET 2.1-1
Title: Applying the Single Responsibility Principle (SRP) in Python Class Design
Performance Objective:
Trainee will be able to recognize and apply the Single Responsibility Principle (SRP) in
class design for Python, creating modular, maintainable, and reusable classes.
Supplies/Materials:
Python installed
IDE installed
Existing Python project with classes that violate SRP
Equipment:
Computer with Python and IDE installed
Steps/Procedure:

1. Identify Responsibilities in the Existing Class:


 Open the existing Python project in your IDE.
 Review the class and list all the responsibilities it handles (e.g., student
registration, result calculation, email sending).
 Determine which responsibilities are unrelated and need to be separated into
distinct classes.
2. Create Focused Classes:
 For each responsibility identified, create a new Python class with a clear,
specific purpose (e.g., StudentRegister, StudentResult, StudentEmail).
 Ensure that each class handles only one task or responsibility.
3. Move Methods and Properties:
 Move methods and properties from the original class to the newly created
classes.
 For example, move the registration method to the StudentRegister class and the
email-sending method to the StudentEmail class.
4. Adjust Class Interactions:
 Ensure the original class interacts correctly with the new classes by adjusting
method calls and object initialization where needed.
 Replace any direct responsibility in the original class with calls to the new
specialized classes.
5. Test the Refactored Code:
 Write unit tests to ensure each new class works correctly and handles only the
responsibilities assigned to it.
 Test the overall functionality to verify the system behaves as expected after
applying SRP.
6. Refactor and Improve Code Structure:
 Remove any redundant or duplicate code created during the refactoring.
 Simplify interactions between classes to minimize dependencies.
 Ensure the refactored classes follow the principles of clarity, maintainability, and
reusability.
7. Document Changes:
 Document each class's responsibility and how it interacts with other classes.
 Write a summary of the changes made during the SRP refactoring process.

Assessment Method:
Demonstration and code review, followed by oral questioning about the refactoring
Date Document No. AB-ICT0601914251302
process and principles of SRP.
Conducting Object-Oriented Developed: Issued by:
Page 49 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
PERFORMANCE CRITERIA CHECKLIST 2.1-1
Did I? Yes No
1. Identify multiple responsibilities in the original class.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 50 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
2. Create new, focused classes for each responsibility.
3. Move methods and properties to the appropriate classes.
4. Adjust interactions between the original class and new classes
5. Test the refactored code for correct functionality
6. Ensure clarity, maintainability, and reusability of the new classes
7. Document the refactored code and class responsibilities
Applying the Single Responsibility Principle (SRP) in Python Class Design
Comments/Suggestions:
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________

Trainer: _____________________________ Date: ______________________

INFORMATION SHEET 2.1-2


OPEN-CLOSED PRINCIPLE (OCP)

Learning Objectives:
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 51 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
After reading this INFORMATION SHEET, you should be able to:

1. Understand the Open-Closed Principle (OCP) and its importance in designing


extensible software.

2. Learn how to extend functionality in Python without modifying existing code.

3. Apply OCP through inheritance, composition, or polymorphism in Python


projects.

Open-Closed Principle (OCP)

The Open-Closed Principle (OCP) is the second of the five SOLID principles and
is essential for building scalable, maintainable software. It states that software entities
such as classes, modules, or functions should be open for extension but closed for
modification. In simple terms, this means that the behavior of a class or function should
be extendable without altering its existing code.

Think of a car’s design. When new features like advanced navigation or autopilot
are added, manufacturers don’t rebuild the entire car. Instead, they create add-ons or
modules that enhance the car’s functionality while keeping the core structure intact. The
existing car remains untouched, but its capabilities grow.

Similarly, in software, when new features or changes are required, we avoid


altering the core code, which could introduce bugs or break existing functionality.
Instead, we extend the functionality through mechanisms like inheritance, composition,
or polymorphism. This ensures the system remains stable while allowing for future
enhancements.

This principle encourages developers to think ahead and create systems that can
evolve gracefully, enabling smooth expansion without disturbing the core structure. This
results in fewer bugs, easier maintenance, and a cleaner codebase, much like how a
well-built car can adapt to new technologies without needing a complete overhaul.

Ensuring Open-Closed Principle (OCP)

Achieving the Open-Closed Principle (OCP) requires designing software in a way


that allows for extensions without modifying existing code. This method promotes a
flexible, scalable system that can adapt to new requirements with minimal disruption to
existing functionality. Below is a structured approach to ensure OCP in your Python
projects:

1. Identify Areas for Extension:

 Review the current system to determine where future changes or


enhancements may be necessary.

 Look for parts of the codebase where behavior may need to be modified
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 52 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
or extended in the future, such as adding new features or supporting
new types of data.

2. Use Inheritance:

 Create base classes or interfaces that define common behaviors.

 Extend these base classes by creating new subclasses to implement


specific variations of the behavior.

 Ensure that existing classes remain unchanged while allowing new


classes to be introduced.

3. Apply Composition:

 Instead of modifying existing classes, design systems by composing


objects that contain behaviors.

 Use composition which involves building more complex functionality by


combining simpler, independent classes to dynamically adjust or extend
functionality without altering the core classes.

 For example, inject different strategy objects into a class to change its
behavior based on context.

4. Utilize Polymorphism:

 Implement polymorphism by defining common interfaces or abstract


base classes.

 Allow objects to be treated as instances of these base types, but


dynamically execute the appropriate subclass behavior.

 This allows you to add new behaviors without needing to modify any
part of the code that interacts with the base type.

Benefits of Following OCP:

1. Extensibility: Systems adhering to OCP are easier to extend. New features can
be added by writing new code, not by altering existing, tested code.

2. Reduced Risk of Bugs: By avoiding modifications to existing classes or modules,


the risk of introducing bugs into stable, functioning parts of the application is
minimized.

3. Maintainability: Systems built with OCP are more maintainable, as new


requirements do not demand extensive rework of existing code. Instead,
developers focus on extensions.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 53 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
4. Flexibility: OCP promotes a more flexible design, allowing developers to
introduce new features or adapt to changes in the requirements without disrupting
the existing functionality.

Consider the Example Below:

The class above violates the Open-Closed Principle (OCP). Why?

This ReportGenerator class is responsible for generating reports in different


formats (PDF, CSV). If we want to support a new format, say, HTML, we will need to
modify the existing class and add more conditional logic. This means the class is not
closed for modification.

In the long run, continually adding formats will bloat the class and make it harder
to maintain. Any changes to one report format might inadvertently affect the others. This
violates the core idea of OCP, which states that software entities (classes, modules, etc.)
should be open for extension but closed for modification.

To improve the design, we can refactor it using polymorphism. Let's create a


common interface for generating reports and then create different classes to handle each
format.

Refactored Code:

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 54 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Now, each report format has its own class that implements the Report interface.
To generate a report, you simply pass the appropriate report type to the
ReportGenerator. If you want to add support for an HTML report, you can do so without
changing the existing classes:

Why is this better?

1. No Need for Modifications: The existing classes (PDFReport, CSVReport)


remain untouched when adding new functionality, such as HTMLReport.

2. Easy to Extend: You can add new report formats by simply creating a new class

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 55 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
that implements the Report interface. No need to touch existing code.

3. Maintains Flexibility: Each report format can be tested independently, and any
changes are isolated to their respective classes.

4. Follows OCP: The core principle of being open for extension but closed for
modification is maintained. Our design allows adding new features without risking
bugs in the existing code.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 56 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF-CHECK 2.1-2

Identification

1. The second principle in the SOLID framework.

2. The principle that states software entities should be open for ______ but closed
for ______.

3. The method of creating new behavior by creating a new subclass without


changing the existing class.

4. An example of a violation of OCP is modifying a class to support additional


______ formats.

5. The design mechanism that combines smaller classes to extend functionality


without modifying existing classes.

6. A strategy where new features are added without altering the original code is
achieved through ______.

7. The risk minimized by following OCP and avoiding changes to stable classes.

8. The programming feature allowing objects to take on multiple forms, used to


achieve OCP.

9. The pattern of providing a common interface for generating reports, extended to


various formats.

10. OCP ensures the system remains scalable and maintainable by allowing the
introduction of new ______.

11. Refactoring the design by splitting functionality into multiple classes is an example
of applying ______.

12. The concept where future changes are anticipated and planned for in advance,
without modifying existing code.

13. The violation occurs when adding a new feature by modifying an existing class
instead of extending it, which violates ______.

14. A common way to follow OCP in Python is by using ______.

15. OCP promotes designing software in a way that allows extension through new
classes, without changing the ______.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 57 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 2.1-2

Identification

1. open-closed principle (OCP)

2. extension, modification

3. inheritance

4. report

5. composition

6. polymorphism

7. introducing bugs

8. polymorphism

9. report interface

10. features

11. open-closed principle (OCP)

12. open-closed principle (OCP)

13. open-closed principle (OCP)

14. inheritance or composition

15. core code

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 58 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
TASKS SHEET 2.1-2
Title: Designing a Flexible System Using the Open-Closed Principle (OCP).
Performance Objective:
The trainee will create a Python class that adheres to the Open-Closed Principle
(OCP), allowing for future feature extensions without modifying the existing class.
Supplies/Materials:
Python installed
IDE installed
Basic understanding of Python classes, inheritance, and polymorphism
Equipment:
Computer with Python and IDE installed
Steps/Procedure:

1. Define a Core Problem or Feature:

 Choose a scenario where you would need to implement a feature that could
require future extensions (e.g., a payment processing system or notification
system).
 Define the basic functionality that your core class should have.

2. Design the Base Class or Interface:

 Create a Python class or an interface that will represent the core functionality
(e.g., a Payment class with basic payment processing).
 Ensure this class is closed for modification but ready for extension by defining
key methods that future features will inherit or override.

3. Implement the Base Class:

 Add necessary methods to your base class that provide the foundation for the
core behavior.
 Keep this class minimal and focused on the shared functionality that all
extensions will need.

4. Extend the Functionality with New Classes:

 Create at least two new classes that extend the base class’s functionality (e.g.,
CreditCardPayment, PayPalPayment).
 Implement or override methods in these new classes to demonstrate how
additional behaviors can be added without modifying the original class.

5. Introduce Future Extensions:

 Think of another feature that could be required later (e.g., BitcoinPayment for
the payment system).
 Plan how you would extend the system in the future by adding new classes
while keeping the base class untouched.

6. Refactor to Use Composition or Polymorphism:

 Refactor your design to use polymorphism or composition so that your system


can dynamically choose the appropriate class based on the situation.
 Ensure your system can switch between behaviors (e.g., selecting the right
Date Document No. AB-ICT0601914251302
payment method) without altering the base class. Issued by:
Developed:
Conducting Object-Oriented
Page 59 of
Analysis and Design for
7. Test the System: Developed by: 176
Python Applications
Revision #
 Write test cases to ensure your system works correctly with the newly added
features.
 Verify that the base class remains untouched, and the new classes behave as
PERFORMANCE CRITERIA CHECKLIST 2.1-2
Did I? Yes No
1. Define a core problem and identify future extension needs.
2. Create a base class or interface that follows OCP.
3. Move methods and properties to the appropriate classes.
4. Ensure that the base class remains untouched after extensions.
5. Use composition or polymorphism to handle behavior
dynamically.
6. Test the system to verify it works with added features.
7. Document the design and explain the OCP implementation.
Designing a Flexible System Using the Open-Closed Principle (OCP)
Comments/Suggestions:
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________

Trainer: _____________________________ Date: ______________________

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 60 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
INFORMATION SHEET 2.1-3
LISKOV SUBSTITUTION PRINCIPLE (LSP)

Learning Objectives:
After reading this INFORMATION SHEET, you should be able to:

1. Understand the Liskov Substitution Principle (LSP) and how it ensures the
proper use of inheritance in Python.

2. Learn how to implement inheritance in a way that ensures derived classes can
replace base classes without issues.

3. Refactor classes that violate LSP to ensure they adhere to inheritance


principles.

The Liskov Substitution Principle (LSP)

The Liskov Substitution Principle (LSP) is the third of the five SOLID principles,
crucial for ensuring robust and maintainable software. It states that objects of a base
class should be replaceable with objects of a derived class without affecting the
correctness of the program. Essentially, derived classes must extend the base class
without changing its intended behavior.

Think of LSP like this: Imagine you have a universal remote that controls various
devices like TVs, DVD players, and streaming boxes. Each device follows the same
basic commands—power on, volume up, channel change. If you replace a device with a
new one that supports additional functions but still follows the basic commands, the
remote should work seamlessly without needing adjustments. The remote’s functionality
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 61 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
doesn’t break, and the new device integrates smoothly.

In software, adhering to LSP means that derived classes should honor the
contracts established by their base classes. This ensures that the software remains
predictable and reliable as new features are added or existing features are extended.

Ensuring Liskov Substitution Principle (LSP)

Adhering to LSP involves designing your classes in a way that ensures derived
classes can be used interchangeably with their base classes without altering expected
behavior. Here’s a structured approach to ensure LSP in your Python projects:

1. Design Base Classes Thoughtfully:

 Define Clear Contracts: Ensure the base class defines clear, consistent
contracts (methods and behaviors) that derived classes must adhere to.

 Avoid Overly Broad Base Classes: Keep base classes focused on


specific responsibilities to avoid situations where derived classes need
to override methods inappropriately.

2. Implement Derived Classes Carefully:

 Respect Base Class Contracts: Ensure derived classes honor the


contracts of the base class. They should not alter the behavior expected
by the base class users.

 Maintain Consistent Behavior: Derived classes should extend


functionality while keeping the behavior consistent with what users
expect from the base class.

3. Refactor Violations:

 Identify Violations: Look for scenarios where derived classes do not


behave as expected when used in place of the base class.

 Redesign: Refactor the design to ensure derived classes maintain


expected behaviors. This may involve adjusting inheritance hierarchies
or redesigning class responsibilities.

4. Test Substitutability:

 Use Base Class References: Test derived classes by substituting


them for their base classes in various scenarios to ensure they behave
correctly.

 Verify Behavior: Ensure that derived classes perform correctly in all


contexts where the base class is used.

Benefits of Following LSP:


Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 62 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
1. Predictability: Code remains predictable and reliable as new derived classes are
introduced. The behavior of the base class remains consistent across different
contexts.

2. Reduced Bugs: By ensuring derived classes adhere to the contracts of the base
class, the risk of introducing bugs through incorrect subclass behavior is
minimized.

3. Improved Maintainability: Code that adheres to LSP is easier to maintain


because changes in derived classes do not require alterations to the base class or
other parts of the system.

4. Enhanced Flexibility: LSP allows for flexible extension of functionality through


derived classes, ensuring that the system can evolve without disrupting existing
functionality.

Consider the Example Below:

Problem: The Penguin class violates LSP. Although it inherits from Bird, it cannot fulfill
the fly method as expected. Substituting Penguin for Bird breaks the expected behavior,
violating LSP.

Refactor to Adhere to LSP:

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 63 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
The refactored design illustrates how to adhere to LSP effectively by creating
specialized subclasses. Each class now properly implements the behavior expected by
the base class, demonstrating that adherence to LSP does not limit complexity. The
examples provided with FlyingBird and SwimmingBird are simplified to highlight the
principle, but the approach scales with additional methods and functionality.

With this design, the code becomes easier to understand as each class now fulfills
its specific role without disrupting the behavior of other classes. Testing becomes more
straightforward since each class adheres to a clear contract, making it easier to identify
and fix errors.

Furthermore, this approach enhances reusability. The FlyingBird and


SwimmingBird classes can be used interchangeably in any context expecting a Bird,
while respecting the contract defined by the base class.

Lastly, the code is more maintainable and scalable. By following LSP, you avoid
entangling logic, ensuring that changes or additions to one class do not inadvertently
affect others. This modularity allows you to focus on expanding functionality or adjusting
specific behaviors without risking unintended consequences across the system.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 64 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF-CHECK 2.1-3

Multiple Choice

1. What is the primary goal of the Liskov Substitution Principle (LSP)?


a) To ensure that subclasses can be used in place of base classes without
affecting functionality
b) To allow modification of base classes without altering derived classes
c) To force derived classes to modify the behavior of base classes
d) To ensure that base classes override derived class methods
2. Which of the following correctly defines the Liskov Substitution Principle?
a) Classes should have only one reason to change
b) Objects of a base class should be replaceable by objects of a derived class
c) Classes should be open for extension but closed for modification
d) Methods should be public for all classes to access
3. Which situation would violate the Liskov Substitution Principle?
a) A subclass adds new functionality while keeping base class behavior intact
b) A subclass overrides a base class method but causes the method to behave
differently
c) A base class defines common methods for subclasses to implement
d) A subclass extends the functionality of the base class by adding new
methods
4. Why is Liskov Substitution Principle important for maintainable code?
a) It eliminates the need for unit testing
b) It ensures that changes to base classes don’t affect subclasses
c) It allows code to remain predictable when extending systems with new
derived classes
d) It enables the modification of base classes without refactoring
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 65 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
5. Which example best illustrates adherence to Liskov Substitution
Principle?
a) A Bird class with a fly() method is extended by a Penguin subclass that does
not implement fly()
b) A Vehicle base class is extended by both Car and Bicycle subclasses, both of
which implement the move() method consistently
c) A Payment class where the PayPal subclass overrides the process() method
with completely different behavior
d) A Shape class with calculateArea() that is overridden by a subclass without
adhering to the base functionality
6. What is one way to ensure that derived classes adhere to LSP?
a) Overwrite all base class methods in derived classes
b) Make derived classes modify base class behavior
c) Ensure that derived classes only add functionality without altering inherited
behavior
d) Use if statements to conditionally change subclass behavior
7. Which principle is violated if a subclass breaks the behavior expected
from its base class?
a) Interface Segregation Principle
b) Dependency Inversion Principle
c) Single Responsibility Principle
d) Liskov Substitution Principle
8. How does LSP promote flexibility in software design?
a) By allowing developers to extend classes without worrying about breaking
existing functionality
b) By enabling direct modification of base classes to meet new requirements
c) By ensuring that classes don’t follow a single responsibility
d) By allowing different types of objects to inherit different methods
9. Which of the following benefits is associated with adhering to LSP?
a) Increased complexity due to method overriding
b) Simplified code testing and predictable behavior
c) Reduced flexibility due to strict method inheritance
d) The need to rewrite base class code frequently
10. In which case would refactoring be necessary to maintain LSP
compliance?
a) A Worker class is extended by both Manager and Intern classes, each adding
new methods
b) A Bird base class includes a fly() method that is overridden by a Penguin
subclass, which cannot fly
c) A Book class defines a method open() which is implemented identically in all
subclasses
d) A Vehicle base class has a move() method, and the Bicycle subclass
implements it correctly
11. What can be used to enforce Liskov Substitution Principle in Python?
a) Conditional logic to handle different subclasses
b) Abstract base classes or interfaces
c) Private methods that restrict subclassing
d) Overriding all base class methods in subclasses
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 66 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
12. Which of the following best demonstrates a violation of LSP?
a) A subclass adds more specific functionality without breaking the base class
contract
b) A subclass overrides a method in the base class and introduces unintended
side effects
c) A subclass uses all methods of the base class correctly but introduces new
ones
d) A subclass provides an additional feature, leaving the base class untouched
13. Why is predictability a benefit of following Liskov Substitution Principle?
a) It eliminates the need for writing tests
b) It ensures that subclasses will behave in unexpected ways
c) It allows subclasses to replace base classes without changing expected
outcomes
d) It forces developers to rewrite the base class constantly
14. What should a derived class NOT do when following LSP?
a) Inherit all methods from the base class
b) Change the base class's behavior in a way that breaks its contract
c) Extend functionality by adding new methods
d) Use the base class’s methods as designed
15. How does Liskov Substitution Principle (LSP) reduce the risk of bugs?
a) By requiring that base classes be rewritten often
b) By ensuring that changes to subclasses do not alter the expected behavior of
the base class
c) By allowing modifications to the base class as new subclasses are created
d) By preventing the use of inheritance entirely

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 67 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 2.1-3
Multiple Choice

1. a

2. b

3. b

4. c

5. b

6. c

7. d

8. a

9. b

10. b

11. b

12. b

13. c

14. b
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 68 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
15. b

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 69 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
TASKS SHEET 2.1-3
Title: Applying the Liskov Substitution Principle (LSP) in Class Design.
Performance Objective:
The trainee will create a base class and a set of derived classes that adhere to the
Liskov Substitution Principle, ensuring that derived classes can replace the base class
without altering system behavior.
Supplies/Materials:
Python installed
IDE installed
Understanding of class inheritance and polymorphism
Equipment:
Computer with Python and IDE installed
Steps/Procedure:

1. Define a Base Class:

 Design a base class that represents a general concept (e.g., a Vehicle class).
 Include methods that reflect the core behavior expected from all derived classes
(e.g., start(), stop()).

2. Create Two or More Derived Classes:

 Implement at least two subclasses that extend the base class (e.g., Car and
Bicycle).
 Ensure that each derived class adheres to the base class's methods and
functionality without changing the expected behavior.

3. Test Substitutability of Derived Classes:

 Replace instances of the base class with derived class instances and test if the
program continues to work as expected.
 Ensure that the substitution of derived classes does not alter the overall
functionality of the program.

4. Refactor Violations (if any):

 Review your design for any violations of LSP, such as derived classes that do
not fully conform to the behavior of the base class.
 Refactor the derived classes or adjust the inheritance hierarchy to maintain LSP
compliance.

5. Document the Design:

 Write brief documentation explaining how LSP has been applied in your class
hierarchy.
 Describe how derived classes can be used interchangeably with the base class.

Assessment Method: Document No. AB-ICT0601914251302


Date
Code review to verify adherence to the Liskov SubstitutionIssued
Conducting Object-Oriented Developed:
Principle
by: (LSP) in class
design, followed by functionality tests to ensure correct behavior Page 70
when derived of
classes
Analysis and Design for
replace the base class. Developed by: 176
Python Applications
Revision #
PERFORMANCE CRITERIA CHECKLIST 2.1-3
Did I? Yes No
1. Design a base class with consistent methods and behavior?
2. Implement two or more derived classes that extend the base
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 71 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
class?
3. Test that derived classes can substitute the base class without
issues?
4. Refactor the design to resolve any violations of LSP?
5. Document the design and explain how LSP has been applied?
Applying the Liskov Substitution Principle (LSP) in Class Design
Comments/Suggestions:
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________

Trainer: _____________________________ Date: ______________________

INFORMATION SHEET 2.1-4


INTERFACE SEGREGATION PRINCIPLE (ISP)

Learning Objectives:
After reading this INFORMATION SHEET, you should be able to:
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 72 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
1. Understand the Interface Segregation Principle (ISP) and how it applies to
designing interfaces in Python.

2. Learn how to split large interfaces into smaller, more focused ones to avoid
client overload.

3. Apply ISP by designing smaller, specific interfaces that cater to client needs.

The Interface Segregation Principle (ISP)

The Interface Segregation Principle (ISP) is the fourth SOLID principle,


essential for creating clean and efficient interfaces in software design. It asserts that
clients should not be forced to depend on interfaces they do not use. In other words, an
interface should be divided into smaller, more specific ones to avoid burdening clients
with methods they don’t need.

Imagine a universal remote designed to control multiple devices like TVs, DVD
players, and audio systems. Instead of a single, complex remote with buttons for every
possible function, you have separate remotes for different devices. Each remote is
customized for its device, making it simpler and more user-friendly.

In software, applying ISP means designing interfaces so that clients only interact
with the methods they need. This avoids unnecessary dependencies and makes the
system easier to maintain and extend.

Ensuring Interface Segregation Principle (ISP)

To effectively apply ISP in your Python projects, follow this structured approach:

1. Design Specific Interfaces:

 Identify Core Responsibilities: Break down large interfaces into


smaller ones that focus on specific responsibilities.

 Avoid Overloading: Ensure interfaces are not bloated with methods


unrelated to their core purpose.

2. Create Client-Specific Interfaces:

 Determine Client Needs: Design interfaces based on the exact


requirements of clients or classes that will implement them.

 Segregate Functionality: Ensure each interface only includes methods


that are relevant to its intended clients.

3. Refactor Existing Interfaces:

 Analyze Large Interfaces: Examine any large, multi-purpose interfaces


in your codebase and identify opportunities for segmentation.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 73 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
 Implement Smaller Interfaces: Refactor these large interfaces into
several smaller, more focused ones and update the implementing
classes accordingly.

4. Verify Interface Implementation:

 Implement Multiple Interfaces: Where necessary, have classes


implement multiple smaller interfaces instead of one large one.

 Test Compliance: Ensure that each class correctly implements its


interfaces and that clients only use the methods they need.

Benefits of Following ISP:

1. Reduced Complexity: Smaller, more focused interfaces are easier to understand


and manage. Clients interact only with relevant methods, simplifying the
codebase.

2. Enhanced Flexibility: Changes to one interface do not affect clients that do not
use it, making the system more adaptable to new requirements.

3. Improved Reusability: Specialized interfaces can be reused across different


projects or parts of the system, increasing code reuse.

4. Easier Maintenance: With well-defined interfaces, maintenance is straightforward


because changes are localized to specific interfaces rather than impacting
multiple clients.

Consider the Example Below:

Problem: A single Device interface contains methods for printing, scanning, and faxing.
A class implementing Device might not use all methods, leading to unused or irrelevant
code in some clients.

Refactor to Adhere to ISP:

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 74 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
The examples provided illustrate interfaces with a single method each for
simplicity. In practice, you can include multiple methods, but each should align with the
specific responsibility of the interface.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 75 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
By breaking down a large interface into smaller, targeted ones, our code becomes
more understandable. Each interface now serves a specific role, making it easier to
manage and test.

The code is now more reusable. Previously, functionalities were confined to a


single interface, but now they can be employed in various contexts or projects.

Additionally, the code is more maintainable and scalable. With concerns


separated into distinct interfaces, you can focus on enhancing or adjusting specific
features without impacting unrelated parts of the system.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 76 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF-CHECK 2.1-4

Identification

1. The principle that states clients should not be forced to depend on interfaces they
do not use.

2. This design approach breaks large interfaces into smaller, more focused ones to
avoid client overload.

3. In ISP, interfaces are created based on the exact needs of these entities.

4. A large interface that contains methods irrelevant to certain clients violates this
principle.

5. This benefit of ISP ensures that clients only interact with relevant methods,
reducing the code’s complexity.

6. ISP allows for this by making sure changes to one interface do not affect clients
that do not use it.

7. This type of interfaces, created under ISP, can be reused across different
projects or parts of a system.

8. An interface that focuses on a specific responsibility is easier to maintain and


supports this benefit.

9. ISP promotes creating smaller interfaces instead of having this type of interface
with many unrelated methods.

10. This term refers to when multiple, smaller interfaces are implemented by the
same class, as recommended by ISP.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 77 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 2.1-4

Identification

1. Interface Segregation Principle (ISP)

2. Interface Segregation

3. Clients

4. Interface Segregation Principle (ISP)

5. Reduced complexity

6. Enhanced flexibility

7. Reusability

8. Easier maintenance

9. Bloated interface

10. Multiple interfaces

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 78 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
TASKS SHEET 2.1-4
Title: Applying the Interface Segregation Principle (ISP) in Python Design.
Performance Objective:
The trainee will be able to break down a large, multi-purpose interface into smaller,
focused interfaces, ensuring each class only implements the methods it needs,
adhering to the Interface Segregation Principle (ISP)..
Supplies/Materials:
Python installed
IDE installed
Basic understanding of object-oriented programming and inheritance
Equipment:
Computer with Python and IDE installed
Steps/Procedure:
1. Analyze a Large Interface:
 Select a Python project with a large interface that is implemented by multiple
classes (e.g., a Device interface with print(), scan(), and fax() methods).
 Review the interface and identify methods that are irrelevant to certain classes.
2. Design Smaller Interfaces:
 Create smaller, focused interfaces based on the specific methods needed by
different clients (e.g., PrinterInterface, ScannerInterface, FaxInterface).
 Ensure each new interface has methods that align with the specific
responsibility of the client classes.
3. Refactor Implementing Classes:
 Update the existing classes to implement only the smaller, relevant interfaces
(e.g., a Printer class should only implement PrinterInterface).
 Ensure no class is overloaded with methods it does not need.
4. Test Interface Segregation:
 Verify that each class now interacts with the appropriate interface, and all
unnecessary methods have been removed.
 Ensure that the code is easier to maintain and scalable by extending new
interfaces without affecting unrelated classes.
5. Document the Changes:
 Write documentation explaining how the large interface was broken down into
smaller ones.
 Include examples of how client classes now implement the appropriate
interfaces and how this follows the Interface Segregation Principle (ISP).

Assessment Method:
Code review to ensure the refactored classes only implement methods they need, as
per the Interface Segregation Principle. Tests will verify the system’s functionality after
breaking down large interfaces into smaller ones.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 79 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
PERFORMANCE CRITERIA CHECKLIST 2.1-4
Did I? Yes No
1. Identify a large interface that violates ISP?
2. Break the large interface into smaller, focused ones?
3. Ensure each class only implements the interfaces it needs?
4. Refactor classes to remove irrelevant methods from their scope?
5. Test the implementation to verify compliance with ISP?
6. Document how the refactor follows the Interface Segregation Principle?
Applying the Interface Segregation Principle (ISP) in Python Design
Comments/Suggestions:
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________

Trainer: _____________________________ Date: ______________________

INFORMATION SHEET 2.1-5

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 80 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
DEPENDENCY INVERSION PRINCIPLE (DIP)

Learning Objectives:
After reading this INFORMATION SHEET, you should be able to:

1. Understand the Dependency Inversion Principle (DIP) and how it promotes


flexible, decoupled design in Python.

2. Learn how to use dependency injection and interface abstraction to adhere to


DIP.

3. Implement DIP by inverting dependencies through abstraction layers and using


dependency injection.

Understanding Dependency Inversion Principle (DIP)

The Dependency Inversion Principle (DIP) is a cornerstone of SOLID design


principles, focused on promoting a flexible and decoupled system architecture.
Essentially, it dictates that high-level modules should not be directly dependent on low-
level modules. Instead, both should rely on abstractions—such as interfaces or abstract
classes. This approach enhances modularity and makes the system easier to adapt and
maintain.

Consider a modular smartphone. Instead of being built with a fixed camera or


battery, it uses standard interfaces for these components. This means you can upgrade
or replace the camera or battery without redesigning the whole phone. The high-level
functionalities of the phone, like photography or battery management, remain unaffected
by changes in the specific components.

Similarly, in software, adhering to DIP means your high-level modules (like a


service or controller) don’t need to know about the specifics of low-level modules (like a
database or API). They interact through defined abstractions, making your system more
adaptable and resilient to changes.

How to Implement DIP:

1. Define Abstractions:

 Create Interfaces or Abstract Classes: Identify common


functionalities that can be abstracted. Define these as interfaces or
abstract base classes.
 Keep Abstractions Neutral: Ensure that these abstractions are not
tied to specific implementations. They should define only the necessary
methods that different implementations will follow.

2. Design High-Level Modules:

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 81 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
 Depend on Abstractions: Structure high-level modules to depend on
these abstractions rather than concrete implementations. This keeps
high-level logic independent of low-level details.
 Use Dependency Injection: Inject dependencies into high-level
modules through constructors or setters. This practice allows you to
provide different implementations at runtime without modifying the high-
level module.

3. Implement Low-Level Modules:

 Conform to Abstractions: Ensure that your low-level modules


implement the defined abstractions. They should adhere to the
contracts specified by the interfaces or abstract classes.
 Avoid Direct Dependencies: Low-level modules should not directly
reference high-level modules. This separation helps maintain the
principle of inversion.

4. Refactor and Maintain:

 Review Dependencies: Regularly check for any direct dependencies


between high-level and low-level modules. Refactor the code to ensure
all dependencies pass through abstractions.
 Update Abstractions: As requirements evolve, update your
abstractions to accommodate new functionalities or changes while
maintaining the separation of concerns.

Benefits of Applying DIP:

1. Enhanced Flexibility: DIP allows you to modify or extend functionalities by


simply swapping implementations or adding new ones, without affecting existing
high-level modules.
2. Reduced Coupling: By depending on abstractions, components are less tightly
coupled, leading to a more modular and manageable codebase.
3. Improved Maintainability: Changes in low-level modules are less likely to impact
high-level modules, making the system easier to maintain and extend.
4. Better Reusability: High-level modules can interact with various implementations
of the same abstraction, increasing the reusability of your code.

Example of DIP in Practice:

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 82 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
The provided code snippet demonstrates the application of the Dependency
Inversion Principle (DIP) through the use of abstraction and dependency injection. It
begins with defining an abstraction: the Notifier class acts as an abstract base class,
including an abstract send method intended for implementation by any subclass. This
setup ensures that all specific notifier types conform to a shared interface.

Following this, concrete implementations are introduced: EmailNotifier and


SMSNotifier extend the Notifier abstraction, each providing a distinct implementation of
the send method suited to its respective notification medium, whether email or SMS.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 83 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
The NotificationService class, as a high-level module, relies on the Notifier
abstraction instead of any specific implementation. By injecting the notifier, the
NotificationService remains agnostic to the specific type of notification being used.

In practice, instances of EmailNotifier and SMSNotifier are created and passed to


the NotificationService. This setup highlights how the service can seamlessly operate
with different notifier implementations without requiring modifications, thereby
demonstrating both the flexibility and reusability of the code.

By depending on the Notifier abstraction, the NotificationService remains


unaffected by changes in specific notifier types. This promotes flexibility, as adding new
notifier types or modifying existing ones is straightforward since the service interacts
through a stable abstraction. Additionally, the code's maintainability is improved because
changes in notifier implementations do not necessitate updates to the
NotificationService, keeping the code clean and manageable. The NotificationService's
versatility is further enhanced because it can work with any implementation of Notifier,
making it reusable across various scenarios.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 84 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF-CHECK 2.1-5

Multiple Choice

1. What is the main goal of the Dependency Inversion Principle (DIP)?


a) High-level modules should depend directly on low-level modules
b) Low-level modules should depend on high-level modules
c) Both high-level and low-level modules should depend on abstractions
d) Modules should not depend on each other at all

2. Which of the following best describes a violation of DIP?


a) A high-level module directly depends on a low-level module
b) Both high-level and low-level modules depend on abstractions
c) A low-level module implements an interface
d) High-level modules use dependency injection

3. How does DIP improve system flexibility?


a) By tightly coupling high-level and low-level modules
b) By allowing high-level modules to depend on concrete implementations
c) By enabling changes to low-level modules without affecting high-level ones
d) By restricting the use of interfaces and abstractions

4. What is the role of abstractions in DIP?


a) Abstractions define specific implementation details for low-level modules
b) Abstractions remove the need for high-level modules altogether
c) Abstractions provide a common interface that high-level and low-level modules
depend on
d) Abstractions should be directly implemented by high-level modules

5. What is dependency injection in the context of DIP?


a) A method of hard-coding dependencies in a module
b) A technique of passing dependencies (such as low-level modules) to high-level
modules
c) A process where low-level modules depend on high-level modules
d) A method of avoiding the use of interfaces or abstractions

6. Which of the following is a benefit of applying DIP?


a) Increased coupling between high-level and low-level modules
b) Low-level modules can change without affecting high-level modules
c) All modules are tightly coupled, making the system harder to modify
d) High-level modules depend directly on low-level module implementations

7. In DIP, how should low-level modules interact with high-level modules?


a) Low-level modules should directly reference high-level modules
b) Low-level modules should implement abstractions that are used by high-level
modules
c) Low-level modules should be modified based on the needs of high-level
modules

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 85 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
d) High-level modules should modify low-level modules when necessary

8. Which practice ensures adherence to the Dependency Inversion Principle?


a) Using constructors or setters to inject dependencies
b) Hard-coding dependencies into high-level modules
c) Making high-level modules depend on concrete classes
d) Avoiding the use of interfaces or abstractions

9. How does DIP promote maintainability in software design?


a) By tightly coupling all parts of the system
b) By allowing changes in low-level modules without affecting high-level ones
c) By eliminating the need for dependency injection
d) By forcing high-level modules to know about specific low-level implementations.

10. Which of the following is an example of applying DIP?


a) A service class directly creates and manages a database connection
b) A high-level module interacts with an abstract interface rather than a specific
implementation
c) A class directly calls methods on a concrete implementation of another class
d) Low-level modules dictate the behavior of high-level modules

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 86 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 2.1-5

Multiple Choice

1. c

2. a

3. c

4. c

5. b

6. b

7. b

8. a

9. b

10. b

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 87 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
TASKS SHEET 2.1-5
Title: Implementing the Dependency Inversion Principle (DIP) in Python.
Performance Objective:
The trainee will design and implement a Python system that adheres to the
Dependency Inversion Principle (DIP), ensuring high-level modules depend on
abstractions and not on low-level implementations. This will promote a flexible and
decoupled design.
Supplies/Materials:
Python installed.
IDE installed.
Understanding of Python classes, interfaces (abstract base classes), and dependency
injection.
Equipment:
Computer with Python and IDE installed
Steps/Procedure:
1. Identify the High-Level and Low-Level Modules:
 Define a real-world scenario, such as a notification system or payment
processing system.
 Identify the high-level modules (e.g., NotificationService, PaymentService)
that perform core tasks.
 Identify the low-level modules (e.g., EmailNotifier, PayPalProcessor) that
implement specific functionality.
2. Define Abstractions for Dependency Inversion:
 Create an abstraction (interface or abstract base class) for the low-level
modules (e.g., Notifier or PaymentProcessor).
 Ensure that the high-level module (e.g., NotificationService) depends on the
abstraction, not the concrete implementation.
3. Implement Low-Level Modules:
 Develop low-level modules (e.g., EmailNotifier, SMSNotifier) that conform to
the abstraction defined in the previous step.
 These modules should implement the methods defined by the abstraction
but should not directly depend on the high-level module.
4. Use Dependency Injection:
 Inject the low-level modules into the high-level module using constructors or
setters.
 For example, pass the EmailNotifier object into the NotificationService
through the constructor or a setter method.
5. Test the System:
 Write tests to verify that the high-level module can operate with different
low-level modules through abstraction.
 Confirm that the system remains flexible by swapping different
implementations (e.g., replace EmailNotifier with SMSNotifier without
modifying the high-level module).
6. Refactor if Necessary:
 Review the system to ensure there are no direct dependencies between
high-level and low-level modules.
 Refactor any direct dependencies to conform to DIP by ensuring all
interactions are done through abstractions.
7. Document the Design:
 Write documentation explaining the high-level and low-level modules, how
abstractions are used, and how the system adheres to DIP.
 Include examples showing how different low-level modules can be swapped
without modifying high-level modules.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 88 of
Analysis and Design for
Developed by: 176
Python Applications
Assessment Method:
Revision #
Code review and testing to ensure the system adheres to the Dependency Inversion
Principle. The system should be flexible enough to allow low-level modules to be
replaced without modifying the high-level modules, using abstraction and dependency
injection.
PERFORMANCE CRITERIA CHECKLIST 2.1-5
Did I? Yes No
1. Identify high-level and low-level modules in the system?
2. Define abstractions (interfaces or abstract classes) for low-level
modules?
3. Ensure high-level modules depend on abstractions, not concrete
classes?
4. Implement low-level modules that conform to the abstraction?
5. Use dependency injection to pass low-level modules to high-level
modules?
6. Test the system to ensure flexibility when replacing low-level modules?
7. Refactor any direct dependencies between high-level and low-level
modules?
8. Document how DIP is applied and show how modules can be

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 89 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
swapped?
Implementing the Dependency Inversion Principle (DIP) in Python
Comments/Suggestions:
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________

Trainer: _____________________________ Date: ______________________

INFORMATION SHEET 2.1-6


CODE REVIEW AND STATIC ANALYSIS TOOLS

Learning Objectives:
After reading this INFORMATION SHEET, you should be able to:

1. Understand the importance of code reviews and static analysis in maintaining


code quality.

2. Learn how to use static analysis tools like PyLint, Flake8, and MyPy to enforce
coding standards and identify issues.

3. Implement a structured code review process to ensure adherence to SOLID


principles.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 90 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Code reviews and static analysis tools play a pivotal role in ensuring the quality
and reliability of software during development. Code reviews, a manual process where
peers evaluate each other's code, help catch potential bugs, design flaws, and violations
of best practices early. This process encourages collaborative learning and knowledge
sharing within development teams, ensuring that the code is not only functional but also
adheres to agreed-upon standards. By fostering a culture of constructive feedback, code
reviews help improve code readability, maintainability, and scalability. They also serve as
a safety net, reducing the likelihood of introducing errors that could lead to performance
bottlenecks or security vulnerabilities.

On the other hand, static analysis tools, also called linters, automate the detection
of code issues by analyzing the source code without executing it. Linting refers to this
process of using a linter to examine code for potential errors, coding style violations, and
type inconsistencies. These tools, such as PyLint, Flake8, and MyPy in Python, provide
immediate feedback and help enforce coding standards by identifying problems early in
the development process. By integrating static analysis into the development workflow,
developers can address issues before they become more complex, leading to a more
efficient development cycle. Combined, code reviews and static analysis tools ensure
that code quality is consistently maintained, making the software more robust, easier to
maintain, and less prone to defects in the long term.

Importance of Code Reviews and Static Analysis

Code reviews and static analysis play a crucial role in software development, offering
a wide range of benefits:

 Improved Code Quality and Security: Detect and fix bugs, vulnerabilities, and
code smells before they reach production, ensuring more secure and reliable
code.

 Reduced Testing and Maintenance Costs: By catching issues early, these


techniques minimize the need for rework, debugging, and troubleshooting, cutting
down overall project costs and time.

 Enhanced Code Performance and Functionality: Ensure the code runs


efficiently and meets performance benchmarks, improving the overall system's
functionality.

 Collaboration Among Developers: Code reviews foster a collaborative


environment, where developers can share knowledge and ensure adherence to
coding standards and best practices.

 Increased Confidence and Stakeholder Satisfaction: When code meets


expectations, project requirements, and standards, stakeholders feel more
confident about the project's progress.

 Feedback and Optimization: These tools provide valuable feedback and


suggestions, helping to optimize, refactor, and improve code structure, design,
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 91 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
and logic for long-term maintainability.

Code reviews and static analysis ensure that the software meets the highest
standards of quality and efficiency.

Key Concepts

Code Quality refers to how well-written, maintainable, and efficient a codebase is.
High-quality code adheres to established coding standards, minimizing errors, bugs, and
security vulnerabilities. It also ensures the code can be easily understood, tested, and
scaled by other developers. Maintaining high code quality results in fewer issues during
production, smoother updates, and overall easier maintenance in the long term. Code
quality often encompasses several factors, such as readability, modularity, efficiency,
and adherence to best practices like the SOLID principles.

Code Consistency focuses on maintaining a uniform style and structure across


the entire codebase. Consistent code follows the same conventions, formatting, and logic
patterns, making it easier for multiple developers to collaborate on the project. By
standardizing the naming conventions, indentation, and file organization, consistency
enhances readability and reduces cognitive load when navigating the code. Tools like
PyLint and Flake8 help enforce code consistency by ensuring that all parts of a project
adhere to common guidelines, making the codebase more predictable and easier to work
with over time.

Tools Overview

In software development, maintaining high code quality is essential for building


robust, scalable, and maintainable applications. Python offers several tools that help
developers enforce coding standards and detect potential issues early in the
development process. Three of the most widely used tools are PyLint, Flake8, and MyPy.
Each serves a unique purpose in code quality enforcement but complements the overall
development workflow.

1. PyLint

PyLint is a comprehensive code analysis tool that checks for programming errors,
enforces coding standards, and offers suggestions for code refactoring. It assesses your
Python code based on the PEP 8 style guide, flags bad practices, and identifies issues
like missing docstrings, redundant imports, and variable name inconsistencies.
Additionally, PyLint can help enforce SOLID principles by highlighting violations of
coding principles such as the Single Responsibility Principle (SRP) or the
Open/Closed Principle (OCP). This makes it particularly valuable for ensuring
maintainable and scalable code.

2. Flake8

Flake8 is another popular tool that checks the style guide compliance of Python
code, with a primary focus on the PEP 8 standard. It integrates well with other static
analysis tools, including PyFlakes and McCabe (a tool for checking code complexity).
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 92 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Flake8 helps ensure that the code is clean, readable, and free of lint errors, while also
helping detect issues that might go unnoticed in larger projects, like overly complex
functions or unused variables.

3. MyPy

While PyLint and Flake8 primarily focus on style and code quality, MyPy
introduces static type checking into Python. Python is a dynamically typed language, but
MyPy allows developers to include optional type annotations in their code. By analyzing
these annotations, MyPy ensures that the types match up correctly and helps prevent
type-related runtime errors. This early error detection improves code reliability and
makes the system easier to scale by reducing bugs caused by incorrect type
assumptions.

Incorporating tools such as PyLint, Flake8, and MyPy into your Python
development workflow is crucial for upholding best practices and maintaining high code
quality. These tools collectively aid in identifying potential issues early, ensuring that your
code adheres to established standards and is both clean and maintainable. By
leveraging these static analysis tools, you will enhance your ability to produce robust and
error-free software, reinforcing essential coding competencies.

SELF-CHECK 2.1-6

Multiple Choice

1. What is the main purpose of code reviews in software development?


a) To execute code and detect runtime errors
b) To evaluate code for potential bugs, design flaws, and violations of best
practices
c) To automatically refactor code based on style
d) To compile and link code before execution

2. Which of the following best describes the role of static analysis tools?
a) They run code and check for runtime errors
b) They analyze code without executing it to detect potential issues and coding
style violations

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 93 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
c) They only focus on checking documentation and comments
d) They are used for debugging code after deployment

3. Which tool focuses on ensuring code adheres to the PEP 8 style guide and
checks for errors like missing docstrings?
a) MyPy
b) PyLint
c) PyFlakes
d) McCabe

4. How does MyPy enhance code quality in Python projects?


a) By performing automatic type casting
b) By introducing static type checking to detect type-related issues before runtime
c) By enforcing code complexity limits
d) By optimizing code performance at runtime

5. What benefit do code reviews provide to development teams?


a) They allow developers to completely automate code changes
b) They encourage collaborative learning and ensure adherence to coding
standards
c) They help developers avoid using static analysis tools
d) They reduce the need for software testing

6. What is one of the primary advantages of integrating static analysis tools


into the development workflow?
a) They eliminate the need for human code reviews
b) They help detect issues before execution, reducing the likelihood of bugs and
code style violations
c) They automatically execute the code and test for functionality
d) They focus solely on runtime performance optimization

7. Which of the following tools is primarily focused on code complexity and


unused variables?
a) PyLint
b) MyPy
c) Flake8
d) McCabe

8. What is the key concept of "code quality" in software development?


a) Ensuring that code uses the fastest algorithms
b) Writing code that adheres to coding standards, is maintainable, and minimizes
bugs
c) Ensuring that code runs with minimal memory usage
d) Making sure that code is written in the shortest possible way

9. How do code reviews and static analysis contribute to reduced testing and
maintenance costs?
a) They allow developers to eliminate all manual testing efforts
b) By catching issues early, they minimize the need for rework, debugging, and
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 94 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
troubleshooting
c) By focusing on runtime errors, they reduce the amount of testing needed
d) They completely remove the need for automated testing tools

10. Which of the following is a key focus of Flake8 in Python development?


a) Checking for runtime errors in Python code
b) Enforcing the use of static type checking
c) Verifying code style compliance based on PEP 8
d) Automatically optimizing the performance of Python applications

ANSWER KEY 2.1-6

Multiple Choice

1. b

2. b

3. b

4. b

5. b

6. b

7. c
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 95 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
8. b

9. b

10. c

LEARNING EXPERIENCE
Learning Outcome 3:
Learning Activities Special Instructions
1. Read Information Sheet No. 3.1-1
2. Answer Self-Check 3.1-1 Compare answers with the answer key
3.1-1. You are required to get all answers
correct. If not, read the information sheets
again to answer all questions correctly.
3. Read Information Sheet No. 3.1-2
4. Answer Self-Check 3.1-2 Compare answers with the answer key
3.1-2. You are required to get all answers
correct. If not, read the information sheets
again to answer all questions correctly.

5. Perform Task Sheet No. 3.1-2 Evaluate your own work using
the Performance Criteria.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 96 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Present your work to your trainer for
evaluation and recording.
3. Read Information Sheet No. 3.1-3
4. Answer Self-Check 3.1-3 Compare answers with the answer key
3.1-3. You are required to get all answers
correct. If not, read the information sheets
again to answer all questions correctly.
After doing all activities of this LO,
you are ready to proceed to the next
LO

INFORMATION SHEET 3.1-1

TECHNIQUES FOR GATHERING AND DOCUMENTING SYSTEM


REQUIREMENTS
Learning Objectives:

After reading this INFORMATION SHEET, you should be able to:

1. Understand and apply various techniques for gathering system requirements from
stakeholders.
2. Identify stakeholder needs through interviews, questionnaires, and observations.
3. Learn how to properly document system requirements using tools such as use
cases, user stories, and requirement specifications.

Techniques For Gathering Requirements


Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 97 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Gathering accurate and comprehensive system requirements is essential for developing
effective software solutions. The following techniques are commonly used to collect
requirements:
1. Interviews
Conducting one-on-one or group interviews with stakeholders to gather detailed insights
into their needs and expectations.
 When to Use: Useful in projects where in-depth understanding is required. Best
suited for scenarios where stakeholders can provide detailed information on
system requirements.
 Example: Interviewing department heads to determine the specific functionalities
required in a new software system.

2. Focus Groups
Bringing together a group of stakeholders to discuss their needs, expectations, and
concerns about the system.
 When to Use: Effective when you want to gather diverse perspectives and foster
discussion among stakeholders.
 Example: Organizing a focus group with end-users from different departments to
identify common system requirements.

3. Surveys and Questionnaires


Distributing structured questionnaires to a large group of stakeholders to collect
quantitative and qualitative data.
 When to Use: Ideal for gathering data from a large audience in a standardized
format.
 Example: Sending out a survey to all employees to assess their preferences and
needs for a new internal communication tool.

4. Observation:
Observing stakeholders as they interact with current systems or processes to identify
pain points and areas for improvement.
 When to Use: Best used when you want to understand the actual workflow and
issues faced by users without relying solely on their verbal feedback.
 Example: Observing warehouse staff during their daily operations to identify
inefficiencies that could be addressed by a new inventory management system.

Documenting Requirements

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 98 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Effective documentation ensures that requirements are clearly communicated and
understood. Key documentation techniques include:
a. Use Case Diagrams:
Visual representations of the interactions between users (actors) and the system,
depicting the various use cases (functions) the system will support.
 Purpose: Helps to clearly define the scope of the system and the different
functionalities it must support.
 Example: Creating a use case diagram for an e-commerce platform that shows
how customers interact with the system to browse products, place orders, and
make payments.
b. Requirement Specifications:
A detailed document that outlines all functional and non-functional requirements of the
system.
 Purpose: Serves as a formal agreement between stakeholders and developers on
what the system must achieve.
 Example: Writing a requirement specification for a customer relationship
management (CRM) system, detailing the required features like contact
management, lead tracking, and reporting.
c. User Stories:
Short, simple descriptions of a feature told from the perspective of the user who desires
the new capability.
 Purpose: Helps in capturing specific user needs in a format that is easy to
understand and implement.
 Example: A user story for an online banking system: "As a customer, I want to be
able to transfer money between my accounts so that I can manage my finances
easily.”
Identifying Stakeholder Needs
Understanding and documenting stakeholder needs is crucial for delivering a system that
meets their expectations. Techniques for identifying needs include:
a. Recognizing Stakeholder Interests
Understanding the varying interests, expectations, and concerns of different stakeholder
groups.
 Purpose: Ensures that the system meets the needs of all users, from end-users to
managers and executives.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 99 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
 Example: Identifying that a sales department needs real-time access to customer
data, while the finance department requires detailed reporting capabilities.
b. Recording Stakeholder Requirements
Documenting the specific needs and requirements gathered during the various elicitation
activities.
 Purpose: Ensures that all stakeholder requirements are captured accurately and
comprehensively.
 Example: Compiling a list of system features based on feedback from interviews
and surveys conducted with stakeholders.

SELF CHECK 3.1-1

Multiple Choice
Directions: Read and understand the questions and circle the letter of the correct answer.
1. Which technique involves conducting one-on-one or group conversations to
gather detailed insights into stakeholder needs?
a. Observation
b. Interviews
c. Focus Groups
d. Surveys
2. What is a key benefit of using focus groups to gather system requirements?
a. It allows for individual stakeholder input.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 100 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
b. It gathers standardized data from a large audience.
c. It fosters diverse perspectives and discussion among stakeholders.
d. It observes stakeholder interactions with the current system.
3. When is it best to use surveys or questionnaires in the requirement
gathering process?
a. When you need detailed one-on-one feedback.
b. When observing stakeholders in their work environment.
c. When gathering data from a large audience in a standardized format.
d. When discussing needs in a group setting.
4. Which technique involves watching stakeholders perform their daily tasks
to identify potential improvements?
a. Interviews
b. Observation
c. Surveys
d. Focus Groups
5. Which of the following is an example of when to use observation?
a. Interviewing department heads about software features.
b. Sending out a survey to employees about their communication preferences.
c. Watching warehouse staff during daily operations to spot inefficiencies.
d. Conducting a group meeting with end-users to gather requirements.
6. Which technique uses visual representations to show interactions between
users and the system?
a. Use Case Diagrams
b. Requirement Specifications
c. User Stories
d. Interviews
7. What is the purpose of requirement specifications?
a. To provide short, simple descriptions of system features.
b. To gather detailed insights from stakeholders.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 101 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
c. To outline all functional and non-functional requirements of the system.
d. To depict interactions between users and the system.
8. In which document would you find a formal agreement on what the system
must achieve between stakeholders and developers?
a. Use Case Diagram
b. Observation Notes
c. Requirement Specification
d. User Stories
9. Which documentation technique helps capture specific user needs in a
simple and easy-to-understand format?
a. Use Case Diagram
b. Requirement Specification
c. User Stories
d. Focus Groups
10. Which of the following is an example of a user story?
a. A diagram showing how customers browse and purchase products.
b. "As a customer, I want to transfer money between accounts so that I can
manage my finances easily."
c. A document outlining system features like contact management and lead
tracking.
d. A list of interview questions for department heads.
11. What does recognizing stakeholder interests involve?
a. Gathering standardized feedback from a large group of stakeholders.
b. Understanding the varying interests, expectations, and concerns of different
stakeholder groups.
c. Identifying inefficiencies in a work environment through observation.
d. Recording all gathered system requirements into one document.
12. Why is it important to record stakeholder requirements?
a. To ensure all stakeholder requirements are accurately captured and
comprehensively documented.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 102 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
b. To interview stakeholders for their in-depth input.
c. To observe the current system in use and identify potential improvements.
d. To create a visual representation of user interactions with the system.
13. Which example best illustrates recognizing stakeholder interests?
a. A focus group session identifying shared concerns across departments.
b. Real-time access to customer data for the sales department and detailed
reporting for the finance department.
c. Sending out a survey to employees for feedback on a communication tool.
d. Observing warehouse staff to identify inefficiencies.
14. What is the best way to document stakeholder needs after gathering
requirements through interviews and surveys?
a. Compile a list of system features based on the feedback gathered.
b. Create a use case diagram to show how users interact with the system.
c. Conduct a focus group session to get diverse perspectives.
d. Observe the stakeholders interacting with their current system.
15. Which technique helps ensure that all users’ needs are captured and
addressed in the final system?
a. Recording Stakeholder Requirements
b. Conducting Surveys
c. Using Use Case Diagrams
d. Holding Focus Groups

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 103 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 3.1-1

Multiple Choice

1. b

2. c

3. c

4. b

5. c

6. a

7. c

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 104 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
8. c

9. c

10. b

11. b

12. a

13. b

14. a

15. a

INFORMATION SHEET 3.1-2

MODELLING TECHNIQUES

Learning Objectives:

After reading this INFORMATION SHEET, you should be able to:

Learning Objectives:
1. Understand different modeling techniques used in system design and
development.

2. Utilize modeling techniques such as flowcharts, data flow diagrams (DFDs), and
entity-relationship diagrams (ERDs) to represent system requirements visually.

3. Apply appropriate modeling tools to capture system processes, data structures,


and workflow accurately.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 105 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Introduction to Modeling Techniques

Importance of Modeling in System Development:

 Clarity and Communication: Modeling techniques play a crucial role in system


development by providing clear, visual representations of complex processes,
structures, and workflows. These models serve as a bridge between
stakeholders and developers, ensuring that everyone involved has a shared
understanding of the system requirements.

 Error Reduction: By visualizing the system before it is built, potential errors or


gaps in the design can be identified early, reducing the risk of costly revisions
during later stages of development.

 Documentation: Models serve as important documentation that can be


referenced throughout the system's lifecycle, ensuring consistency and aiding in
maintenance and future upgrades.

Common Modeling Techniques:

1. Flowcharts

Flowcharts are diagrams that represent the flow of control in a system using symbols and
arrows to depict processes, decisions, inputs, and outputs.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 106 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Symbol Symbol Name Description
Flow lines are used to
connect symbols used in
Flow Lines
flowchart and indicate
direction of flow.

This is used to represent


Terminal start and end of the
flowchart

It represents information
Input/Output which the system reads as
input or output.

Any process is
represented by the symbol.
Processing
For Example, Arithmetic
operation, data movement
This symbol is used to
check any condition or
Decision take decision for which
there are two answers. Yes
(True) or No (False).

It is used to connect or join


Connector
flow lines.

Flowcharts are commonly used to map out the logical flow of a program or process,
making them ideal for representing algorithms, system operations, or user workflows.

Flowchart Example – Medical Service

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 107 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
This is a hospital flowchart example that shows how clinical cases shall be processed.
This flowchart uses decision shapes intensively in representing alternative flows.

2. Data Flow Diagrams (DFDs):

DFDs depict how data moves through a system, showing the input, processing, and
output of data within different parts of the system.

Levels: DFDs are typically created in multiple levels, starting with a high-level overview
(Level 0) and then drilling down into more detail in subsequent levels.
Symbol Symbol Name Description

Flow lines are used to


connect symbols used
External Entity in flowchart and
indicate direction of
flow.

This is used to
Process represent start and
end of the flowchart

It represents
information which the
Data Store Document No. AB-ICT0601914251302
Date system reads as input
Conducting Object-Oriented Developed: Issued by: or Page
output.108 of
Analysis and Design for
Developed by: 176
Python Applications
Any process is
Revision #
represented by the
Data Flow symbol. For Example,
Arithmetic operation,
data movement
DFDs are particularly useful in identifying how data is handled, where it is stored, and
how it interacts with various system components

Levels in Data Flow Diagram (DFD)

DFDs can be divided into different levels, which provide varying degrees of detail about
the system. The following are the four levels of DFDs:

 Level 0 DFD
 Level 1 DFD
 Level 2 DFD
 Level 3 DF

Level 0 Data Flow Diagram (DFD)

Level 0 is the highest-level Data Flow Diagram (DFD), which provides an overview
of the entire system. It shows the major processes, data flows, and data stores in the
system, without providing any details about the internal workings of these processes.

It is also known as a context diagram. It’s designed to be an abstraction view, showing


the system as a single process with its relationship to external entities. It represents the
entire system as a single bubble with input and output data indicated by
incoming/outgoing arrows.

1-Level Data Flow Diagram (DFD)

1-Level provides a more detailed view of the system by breaking down the major
processes identified in the level 0 Data Flow Diagram (DFD) into sub-processes. Each
sub-process is depicted as a separate process on the level 1 Data Flow Diagram (DFD).
The data flows and data stores associated with each sub-process are also shown.

In 1-level Data Flow Diagram (DFD), the context diagram is decomposed into
multiple bubbles/processes. In this level, we highlight the main functions of the system
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 109 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
and breakdown the high-level process of 0-level Data Flow Diagram (DFD) into
subprocesses.

2-Level Data Flow Diagram (DFD)

2-Level provides an even more detailed view of the system by breaking down the
sub-processes identified in the level 1 Data Flow Diagram (DFD) into further sub-
processes. Each sub-process is depicted as a separate process on the level 2 DFD. The
data flows and data stores associated with each sub-process are also shown.

2-Level Data Flow Diagram (DFD) goes one step deeper into parts of 1-level DFD.
It can be used to plan or record the specific/necessary detail about the system’s
functioning.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 110 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
3-Level Data Flow Diagram (DFD)

3-Level is the most detailed level of Data Flow Diagram (DFDs), which provides a
detailed view of the processes, data flows, and data stores in the system. This level is
typically used for complex systems, where a high level of detail is required to understand
the system. Each process on the level 3 DFD is depicted with a detailed description of its
input, processing, and output. The data flows and data stores associated with each
process are also shown.

3. Entity-Relationship Diagrams (ERDs):

ERDs are used to model the data structures within a system, showing entities (such as
tables in a database), their attributes, and the relationships between them.

Components:

 Entities represent objects or concepts,


 Attributes describe characteristics of the entities,
 and Relationships define how entities are connected.

Physical Data Model

ERDs are essential for database design, helping to ensure that the data is organized efficiently
and that relationships between data elements are well-understood.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 111 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Relationship lines in crow’s foot
notation have two indicators to describe
the cardinality and the modality of the
relationship. Cardinality tells you the
maximum number of times that an
instance of an entity can be associated
with instances of the other entity. Modality
tells you the minimum number of times
that the instance can be associated with
instances of the other entity.

4. Unified Modeling Language (UML) Diagrams:

UML is a standardized visual language used to model object-oriented systems. UML


diagrams can represent a variety of aspects, including class structures, object
interactions, and system behaviors. UML diagrams are widely used in software
engineering to design and document the architecture of object-oriented systems.

Types: Common UML diagrams include Class Diagrams, Sequence Diagrams, and Use
Case Diagrams.

A. Class Diagram

In object-oriented programming (OOP), a class is a blueprint or template for creating


objects. Objects are instances of classes, and each class defines a set of attributes (data
members) and methods (functions or procedures) that the objects created from that class
will possess.

UML Class Notation

Class notation is a graphical representation used to depict classes and their


relationships in object-oriented modeling.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 112 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Class Name:

The name of the class is typically written in the top compartment of the class box
and is centered and bold.

Attributes:

Attributes, also known as properties or fields, represent the data members of the
class. They are listed in the second compartment of the class box and often include the
visibility (e.g., public, private) and the data type of each attribute.

Methods:

Methods, also known as functions or operations, represent the behavior or


functionality of the class. They are listed in the third compartment of the class box and
include the visibility (e.g., public, private), return type, and parameters of each method.

Visibility Notation:

Visibility notations indicate the access level of attributes and methods. Common
visibility notations include:

+ for public visible to all classes

- for private visible only within the class

# for protected visible to subclasses


for package or visible to classes in the same
~
default visibility package

Parameter Directionality

In class diagrams, parameter directionality refers to the indication of the flow of


information between classes through method parameters. It helps to specify whether a
parameter is an input, an output, or both. This information is crucial for understanding
how data is passed between objects during method calls.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 113 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
 In (Input):

 An input parameter is a parameter passed from the calling object (client) to


the called object (server) during a method invocation.
 It is representAed by an arrow pointing towards the receiving class (the
class that owns the method).

 Out (Output):

 An output parameter is a parameter passed from the called object (server)


back to the calling object (client) after the method execution.
 It is represented by an arrow pointing away from the receiving class.

 InOut (Input and Output):

 An InOut parameter serves as both input and output. It carries information


from the calling object to the called object and vice versa.
 It is represented by an arrow pointing towards and away from the receiving
class.

Relationships between classes

1. Association

An association represents a bi-directional relationship between two classes. It


indicates that instances of one class are connected to instances of another class.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 114 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
2. Directed Association

A directed association in a UML class diagram represents a relationship between two


classes where the association has a direction, indicating that one class is associated with
another in a specific way.

3. Aggregation

Aggregation is a specialized form of association that represents a “whole-part”


relationship. It denotes a stronger relationship where one class (the whole) contains or is
composed of another class (the part). In this kind of relationship, the child class can exist
independently of its parent class.

4. Composition

Composition is a stronger form of aggregation, indicating a more significant


ownership or dependency relationship. In composition, the part class cannot exist
independently of the whole class.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 115 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
5. Generalization(Inheritance)

Inheritance represents an “is-a” relationship between classes, where one class (the
subclass or child) inherits the properties and behaviors of another class (the superclass
or parent).

6. Realization (Interface Implementation)

Realization indicates that a class implements the features of an interface. It is often used
in cases where a class realizes the operations defined by an interface.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 116 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
7. Dependency Relationship

A dependency exists between two classes when one class relies on another, but the
relationship is not as strong as association or inheritance. It represents a more loosely
coupled connection between classes.

8. Usage(Dependency) Relationship

A usage dependency relationship in a UML class diagram indicates that one class (the
client) utilizes or depends on another class (the supplier) to perform certain tasks or
access certain functionality. The client class relies on the services provided by the
supplier class but does not own or create instances of it.

Example of a Class Diagram

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 117 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ATMs are deceptively simple: although customers only need to press a few buttons to
receive cash, there are many layers of security that a safe and effective ATM must pass
through to prevent fraud and provide value for banking customers. The various human
and inanimate parts of an ATM system are illustrated by this easy-to-read diagram—
every class has its title, and the attributes.

B. Sequence Diagram

A sequence diagram simply depicts the interaction between the objects in a


sequential order i.e. the order in which these interactions occur.

Sequence Diagram Notation

Actor: An actor in a UML diagram represents a type of role where it interacts with the
system and its objects. It is important to note here that an actor is always outside the
scope of the system we aim to model using the UML diagram.

We use actors to depict various roles including human users and


other external subjects.

Lifeline: A lifeline is a named element which depicts an individual participant in a


sequence diagram. So basically, each instance in a sequence diagram is represented by
a lifeline.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 118 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
We display a lifeline in a rectangle called head with its name and type. The head is located on top of a
vertical dashed line

Messages: Communication between objects is depicted using messages. The


messages appear in a sequential order on the lifeline. Messages can be broadly
classified into the following categories:

a. Synchronous messages

A synchronous message waits for a reply before the interaction can move forward.
The sender waits until the receiver has completed the processing of the message.

b. Asynchronous Messages

An asynchronous message does not wait for a reply from the receiver. The
interaction moves forward irrespective of the receiver processing the previous message
or not.

c. Delete Message

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 119 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
We use a Delete Message to delete an object. When an object is deallocated
memory or is destroyed within the system we use the Delete Message symbol.

d. Self Message

Certain scenarios might arise where the object needs to send a message to itself.
Such messages are called Self Messages and are represented with a U-shaped arrow.

e. Reply Message

Reply messages are used to show the message being sent from the receiver to
the sender. We represent a return/reply message using an open arrowhead with a dotted
line.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 120 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
f. Found Message

A Found message is used to represent a scenario where an unknown source


sends the message. It is represented using an arrow directed towards a lifeline from an
end point.

g. Lost Message

A Lost message is used to represent a scenario where the recipient is not known
to the system. It is represented using an arrow directed towards an end point from a
lifeline.

h. Guards

To model conditions we use guards in UML. They are used when we need to
restrict the flow of messages on the pretext of a condition being met.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 121 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Example of a Sequence Diagram

Here there are 3 instances of objects:

 Customer
 Web Portal
 Database Server of the company

The diagram is a Login Functionality, has the message and replies to messages with
sequence numbering, and the lifeline of each object.

C. Use Case Diagram

A Use Case Diagram is a type of Unified Modeling Language (UML) diagram that
represents the interaction between actors (users or external systems) and a system
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 122 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
under consideration to accomplish specific goals. It provides a high-level view of the
system’s functionality by illustrating the various ways users can interact with it.

Use Case Diagram Notations

Actors: are external entities that interact with the


system. These can include users, other systems, or
hardware devices. In the context of a Use Case
Diagram, actors initiate use cases and receive the
outcomes. Proper identification and understanding of
actors are crucial for accurately modeling system
behavior.

System Boundary: The system boundary is a visual


representation of the scope or limits of the system you are
modeling. It defines what is inside the system and what is
outside.

Use Case Diagram Relationships

1. Association Relationship

The Association Relationship represents a communication or interaction between an


actor and a use case. It is depicted by a line connecting the actor to the use case. This
relationship signifies that the actor is involved in the functionality described by the use
case.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 123 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
2. Include Relationship

The Include Relationship indicates that a use case includes the functionality of
another use case. It is denoted by a dashed arrow pointing from the including use case
to the included use case. This relationship promotes modular and reusable design.

3. Extend Relationship

The Extend Relationship illustrates that a use case can be extended by another use
case under specific conditions. It is represented by a dashed arrow with the keyword
“extend.” This relationship is useful for handling optional or exceptional behavior.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 124 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
4. Generalization Relationship

The Generalization Relationship establishes an “is-a” connection between two use


cases, indicating that one use case is a specialized version of another. It is represented
by an arrow pointing from the specialized use case to the general use case.

Utilizing Modeling Techniques

Selecting the Appropriate Model:

System Analysis Stage


During the early stages of system analysis, use high-level models like
Flowcharts and Level 0 DFDs to capture the overall flow and structure of the system.

Detailed Design Stage


As the system design becomes more detailed, switch to ERDs for data
modeling and Level 1-2 DFDs to explore specific data flows. UML diagrams can be used
to model object-oriented systems in greater depth.

Implementation Stage
Models like Class Diagrams and Sequence Diagrams in UML are
particularly useful during the implementation stage to guide developers in coding and
ensure consistency with the system design.

Tools for Modeling:

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 125 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Software Tools: Various tools are available to create models, such as Microsoft
Visio, Lucidchart, Draw.io, and more specialized software like IBM Rational Rose for
UML diagrams.

Best Practices: Ensure models are kept up to date as the system evolves and
involve stakeholders in reviewing models to confirm that they accurately reflect their
requirements.

SELF CHECK 3.1-2

Part 1: True or False


Directions: Read and understand the questions and put T if it is True and F if it is False.
_____1. Modeling techniques are not important for documenting system requirements.

_____2. Flowcharts use symbols and arrows to represent processes, decisions, inputs,
and outputs.

_____3. A Data Flow Diagram (DFD) at Level 0 provides detailed information about the
internal workings of processes.

_____4. Entity-Relationship Diagrams (ERDs) are used to model the data structures
within a system, including entities, attributes, and relationships.

_____5. Unified Modeling Language (UML) diagrams are used solely for database
design and do not apply to object-oriented systems.

_____6. In a UML Class Diagram, the visibility notation "+" represents public access.

_____7. A Sequence Diagram shows the interaction between objects in a sequential


order.

_____8. The 'Include' relationship in a Use Case Diagram indicates that a use case is
extended by another use case.

_____9. Aggregation in UML represents a “whole-part” relationship where the child class
can exist independently of its parent class.

_____10. DFDs are particularly useful during the implementation stage to guide
developers in coding and ensure consistency with the system design.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 126 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 3.1-2

True or False

1. F (Modeling techniques are crucial for documenting system requirements as they


provide a structured and visual representation of the system.)

2. T (Flowcharts utilize symbols and arrows to depict various elements of a process,


including decisions, inputs, and outputs.)

3. F (A DFD at Level 0 provides a high-level overview of the system, not detailed


information. Detailed internal workings are shown in lower levels of DFDs.)

4. T (ERDs are used to represent data structures, showing entities, their attributes,
and the relationships between them.)

5. F (UML diagrams are used for various aspects of object-oriented design, not just
database design.)

6. T (In UML, the "+" symbol denotes public visibility for attributes and methods in a
class diagram.)

7. T (Sequence Diagrams illustrate the sequence of messages exchanged between


objects over time.)

8. F (The 'Include' relationship indicates that a use case contains the behavior of
another use case, not that it is extended.)

9. T (Aggregation represents a "whole-part" relationship where the part can exist


independently of the whole.)

10. T (DFDs help guide the implementation process by showing how data flows
through the system and how it is processed.)
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 127 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
TASK SHEET 3.1-2

Title: Modelling Techniques

Performance Objective: Utilize these techniques to model system processes,


workflows, and data structures effectively.

Supplies: Computer with Python installed

Equipment: Computer with Python installed

Steps/Procedure:
Task 1: Flowchart
1. Start: Begin the process.
2. User Login: Input step where the user logs into the system.
3. Check Availability: A decision point to verify if the desired time
slot/service is available.
4. If Yes, proceed to the next step.
5. If No, show an error message and allow the user to select a new time
slot/service.
6. Enter Booking Details: Input step where the user provides their
booking details (date, time, service).
7. Payment Process: Processing step to handle the payment (credit card
or other methods).
8. Confirmation: Decision point to check if payment is successful.
9. If Yes, show booking confirmation.
10. If No, show an error message and allow retry.
11. Send Confirmation Email: Output step to send a confirmation email to
the user.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 128 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
12. End: The process ends with the booking confirmation.

Task 2: Develop a Level 0 Data Flow Diagram (DFD)


External Entities:
 Student: The person borrowing and returning books.
 Librarian: The person managing book check-ins and check-outs.

Processes:
 Search Book: Allows students to search for available books.
 Borrow Book: Records when a student borrows a book.
 Return Book: Updates the system when a book is returned.
 Manage Books: Librarian adds or removes books from the
system.
Data Stores:
 Book Inventory: Stores information on available and borrowed
books.
 Student Records: Stores student borrowing history.
Flow Description:
1. User provides credentials to the Login process, which checks the User
Database.
2. Once logged in, User sends a booking request with time and service
details to the Check Availability process, which retrieves data from the
Service Data store.
3. If available, User sends payment details to the Payment Processing
process, which interacts with the Payment Gateway.
4. Upon successful payment, the Booking process records the booking in
the Booking Database and notifies the Service Provider.
5. Finally, the Send Confirmation process sends the booking confirmation
to the User.

Assessment Method:
Demonstration with Oral Questioning

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 129 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Performance Criteria Checklist 3.1-2

Criteria Yes No
Flowchart
1. Process clearly defined
2. Use of appropriate flowchart symbols
3. Flowchart starts and ends clearly
4. All steps of the process are included
5. Decision points accurately represented
6. Correct use of flow lines
7. Process flow follows a logical sequence
8. Input and output steps clearly identified
9. Error handling steps included
10. Flowchart is labeled clearly
Level 0 DFD
1. External entities are correctly identified
2.
3. Processes are clearly defined and
labeled
4. Data stores are accurately represented
5. Data flow between entities, processes,
and stores is clear
6. Correct symbols are used for entities,
processes, and data stores
7. Logical flow of data is followed
8. Input/output interactions between system
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 130 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
components are clear
9. Error handling is included in the data
flow
10. DFD includes all critical system
interactions
11. Level 0 DFD is properly labeled and
organized
Comments/Suggestions:
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________

Trainer: _____________________________ Date: ______________________

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 131 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
INFORMATION SHEET 3.1-3

PRINCIPLES OF GENERALIZATION AND SPECIALIZATION

Learning Objectives:

After reading this INFORMATION SHEET, you should be able to:

1. Understand the principles of generalization and specialization in system design


and object-oriented programming.

2. Apply generalization to create reusable system components, reducing


redundancy and improving system flexibility.

3. Use specialization to define specific attributes or behaviors for subclasses,


enhancing system organization and functionality.

Introduction to Generalization and Specialization

In object-oriented programming (OOP) and system design, generalization and


specialization are fundamental principles that help in organizing and simplifying complex
systems. These principles lead to the creation of class hierarchies—a structured way to
define relationships between classes by grouping shared characteristics and
differentiating unique ones.

1. Generalization

Generalization refers to the process of extracting shared characteristics (attributes or


methods) from multiple specific entities and combining them into a more general class or
component.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 132 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
How it works: A general class, often referred to as a base class or parent class,
serves as a template for other, more specific classes.

In this example, the Animal class represents a generalized entity with common
attributes like name and age. All animals share these basic features, making it a
reusable component.

Advantages of Generalization:

 Code Reusability: Shared functionality only needs to be written once in the


parent class.

 Efficiency: Common attributes or methods don't need to be redefined in every


child class, reducing duplication.

2. Specialization

Specialization refers to creating more specific classes by extending the generalized


class. These specialized classes, or subclasses, inherit attributes and methods from the
general class but also define their own unique characteristics.

How it works: A specialized class, often called a child class or subclass, inherits
from the generalized class and overrides or extends its behavior as needed.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 133 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
In this example, Dog and Cat are specialized subclasses of the Animal class. They
each have their own version of the make_sound() method while still inheriting common
attributes like name and age from the Animal class.

Advantages of Specialization:

 Specific Functionality: Allows the creation of specialized behaviors without


altering the base class.

 Improved System Organization: Complex systems can be organized more


clearly through subclassing, making it easier to manage and maintain.

 Flexibility: The subclass can add new attributes or methods or override


inherited ones to fit its specific needs.

3. Applying Generalization and Specialization in System Design

In system design, the principles of generalization and specialization are essential for
building flexible, maintainable, and scalable solutions. Here’s how these principles can
be applied:

Generalization for Reusability:

In real-world scenarios, generalization allows the reuse of code by creating a


general class for components that share common functionality. For example, a software
application might have a generalized User class that stores common information like
username and password, while specific user types (e.g., Admin, Guest) inherit from User
but add specialized behaviors.

Specialization for Flexibility:

Specialization can be used to extend functionality by adding new or unique


behaviors in the subclass without modifying the general class. For instance, a Vehicle
class may have subclasses like Car, Truck, and Motorcycle, each with distinct
characteristics, but still sharing common properties like speed and fuel capacity.

By applying generalization and specialization, software architects and developers


can create hierarchical class structures that are easier to maintain, more efficient, and
can evolve with system requirements.

Steps to Implement These Principles:

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 134 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
1. Identify Common Characteristics:

Begin by looking for shared features across different entities in the system. These
characteristics can be attributes (such as name and age) or methods (such as eat() or
sleep()), which will form the basis of your generalized class.

2. Abstract General Behavior:

Encapsulate these shared attributes or methods into a generalized class that can
be inherited by other, more specialized components. This abstraction allows for
reusability, as the generalized behavior does not need to be duplicated across different
components.

3. Define Specific Characteristics:

For each subclass or component, determine which specific attributes or methods


distinguish it from the generalized class. These specialized features are added to the
subclass to provide unique behavior, such as a bark() method for the Dog class.

4. Promote Reusability:

Apply generalization and specialization principles to ensure that you reduce


redundancy, making your system easier to maintain, modify, and extend as requirements
change. By having well-defined class hierarchies, future modifications can be made with
minimal impact on the system's overall structure.

Purpose of Generalization and Specialization:

 Improved Code Reusability: Through generalization, developers can avoid


writing duplicate code, while specialization allows for the flexible extension of
functionalities.

 Simplified Maintenance: Since generalized classes manage shared behavior,


updates made to the generalized class automatically apply to all subclasses.

 Enhanced System Organization: These principles help structure the system


logically, making it easier to navigate and understand, especially when the system
grows in complexity.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 135 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF CHECK 3.1-3

Part 1: Multiple Choice


Directions: Read and understand the questions and circle the letter of the correct answer.
1. What is generalization in object-oriented programming?

a. Creating specific classes for unique behaviors

b. Extracting shared characteristics from specific entities into a more general


class

c. Adding attributes and methods only to subclasses

d. Removing methods from a parent class

2. Which of the following is an advantage of generalization?

a. Increased code duplication

b. Reduced reusability of code

c. Simplified code maintenance

d. Inability to share common attributes

3. What does specialization allow a subclass to do?

a. Completely remove attributes from the parent class

b. Override or extend inherited attributes and methods

c. Create new classes without inheriting from the parent class

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 136 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
d. Share only attributes but not methods

4. In which situation would you apply generalization in system design?

a. When you need to create new behaviors specific to one class

b. To reuse common functionality across multiple subclasses

c. When you need to avoid inheritance entirely

d. To limit subclass flexibility in behavior

5. How does specialization improve system organization?

a. By grouping similar classes together without using inheritance

b. By allowing specific subclasses to have unique behaviors while maintaining


shared features

c. By eliminating shared attributes from subclasses

d. By reducing the need for subclasses in the system

6. Which of the following is true about generalized classes?

a. They store specific attributes unique to each subclass

b. They allow subclasses to inherit shared behavior without duplication

c. They cannot be inherited by other classes

d. They are used to remove all methods from the system

7. What is one of the main purposes of using specialization?

a. To create complex, unorganized code structures

b. To reduce the need for code reusability

c. To define specific behaviors for subclasses while keeping shared


functionality

d. To prevent subclasses from having unique attributes

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 137 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
8. Which principle would be used to create a class hierarchy with shared and
unique characteristics?

a. Generalization only

b. Specialization only

c. Both generalization and specialization

d. Neither generalization nor specialization

9. Which method best promotes reusability in system design?

a. Creating a new class for every behavior

b. Using generalization to encapsulate shared behavior in a parent class

c. Avoiding inheritance between classes

d. Defining unique characteristics in every class

10. What is the relationship between generalization and code maintenance?

a. Generalization complicates code updates across subclasses

b. Generalization simplifies updates since shared behavior is managed in one


class

c. Generalization requires separate updates for each subclass

d. Generalization only works for small systems and is not scalable

Part 2: Short Essay

1. Explain how generalization helps improve code reusability and system efficiency
in object-oriented programming. Provide a specific example if necessary.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 138 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
2. Describe how specialization enables flexibility in system design. Use an example
if necessary.

ANSWER KEY 3.1-3

Multiple Choice

1. b

2. c

3. b

4. b

5. b

6. b

7. c

8. c

9. b

10. b

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 139 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
LEARNING EXPERIENCE
Learning Outcome 4

Learning Activities Special Instructions


1. Read Information Sheet No. 4.1-1
2. Answer Self-Check 4.1-1 Compare answers with the answer key
4.1-1. You are required to get all answers
correct. If not, read the information sheets
again to answer all questions correctly.

4. Read Information Sheet No. 2.1-2


5. Answer Self-Check 4.1-2 Compare answers with the answer key
4.1-2. You are required to get all answers
correct. If not, read the information sheets
again to answer all questions correctly.

7. Read Information Sheet No. 4.1-3


8. Answer Self-Check 4.1-3 Compare answers with the answer key
4.1-3. You are required to get all answers
correct. If not, read the information sheets
again to answer all questions correctly.

9. Read Information Sheet No. 4.1-4


10. Answer Self-Check 4.1-4 Compare answers with the answer key
4.1-4. You are required to get all answers
correct. If not, read the information sheets
again to answer all questions correctly.
After doing all activities of this LO,
you are ready to proceed to the next
LO.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 140 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
INFORMATION SHEET 4.1-1
TRANSLATING SYSTEM REQUIREMENTS AND ANALYSIS
MODELS INTO DESIGN SPECIFICATIONS

Learning Objectives:
After reading this INFORMATION SHEET, you should be able to:

1. Understand how system requirements and analysis models are converted into
detailed design specifications.

2. Apply best practices in translating functional and non-functional requirements


into design components.

3. Develop system design specifications that align with user and stakeholder
needs, ensuring proper system functionality.

Understanding System Requirements

System requirements refer to everything needed for the system to work well in
the real world, such as the necessary hardware, software, and network elements. These
requirements outline how different parts of the system—like computers, programs, and
communication tools—interact to ensure smooth performance. Key examples include
processing power, memory, compatibility with operating systems, network capabilities,
and security measures. System Requirements encompass both functional and non-
functional needs, ensuring that the system operates smoothly and meets user
expectations.

To confirm that these requirements are met, validation is done through reviews
with stakeholders and tests. These tests make sure all system parts work together and
that the system matches the goals set at the start of the project. This includes checking
how the system behaves and performing user acceptance testing to ensure it meets
users' needs.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 141 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Functional Requirements

Functional requirements specify what the system should do. These are the
essential operations and behaviors that the system must perform. They include:

1. Features and Functions: Specific tasks the system should accomplish.

2. User Interactions: How users will interact with the system.

3. Data Handling: How the system processes, stores, and retrieves data.

4. Business Rules: Specific rules and logic the system must adhere to.

For example, a functional requirement for an e-commerce website might be that


users can add items to a shopping cart and proceed to checkout.

Non-Functional Requirements

Non-functional requirements define how the system should perform. These


are the quality attributes that ensure the system’s efficiency and usability. They include:

1. Performance: Speed, response time, and throughput.

2. Security: Measures to protect data and ensure privacy.

3. Usability: Ease of use and user experience.

4. Reliability: System uptime and error rates.

5. Scalability: Ability to handle growth in users or data volume.

For example, a non-functional requirement for the same e-commerce website might
be that the system should handle up to 10,000 concurrent users without performance
degradation.

Defining system requirements is crucial for the success of any project. They provide
a clear roadmap for developers, ensuring that the final product meets the needs and
expectations of users.

Analysis Models

An Analysis Model is a way to understand and describe how a system should


work. Think of it as a blueprint or a detailed plan that helps everyone involved in a
project understand what the system needs to do and how it should behave. The main
goal of an analysis model is to capture all the requirements and details about the system.
This includes what the system should do (functional requirements) and how it should
perform (non-functional requirements).

When developing a system, it’s crucial to use analysis models like Use Case
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 142 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Diagrams and Data Flow Diagrams (DFDs) to understand how the system will function
and interact. These models not only capture system requirements but also serve as
foundational inputs for creating detailed design documents. By translating the insights
from these models—such as user interactions, data flows, and system processes—into
technical specifications, developers can define the system's architecture, components,
and interfaces with precision.

 Use Case Diagram


Identifies the interactions between users (actors) and the system. These
interactions guide the creation of class diagrams, outlining system structure,
attributes, and methods.

 Data Flow Diagram (DFD)


Maps out how data moves through the system, informing the design of database
schemas and algorithms to ensure efficient data processing and storage.

Transforming Analysis Models into Design

Insights gained from Use Case Diagrams and DFDs translate directly into design
specifications, ensuring that both functional and non-functional requirements are met.

 Use Case Diagrams to Class Diagrams


A Use Case Diagram highlights interactions between users and the system,
which are then translated into Class Diagrams. For example, a "Place Order" use
case maps to classes like "Order," "Product," and "Customer."

 Data Flow Diagrams to Database Design


A DFD shows how data moves, informing the design of database tables like
"Orders," "Customers," and "Inventory," with relationships and constraints.

 Algorithms and User Interfaces


Use Case Diagrams and DFDs guide the development of algorithms and user
interfaces. For instance, a "Place Order" use case defines how a checkout page
should look, while a DFD informs algorithms that verify product availability.

Step-by-Step Process for Design:

1. Review Analysis Models:

Begin by reviewing the Use Case Diagrams (which outline what the system
should do) and Data Flow Diagrams (DFDs) (which show how data moves within
the system).

These diagrams are crucial because they give a clear picture of the
system’s functionality and the interactions between different components.

2. Identify Key Components:

Break the system down into key components or modules based on the
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 143 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
use cases and DFDs. Each component should handle a specific function within
the system.

For example, A login module manages user authentication, while another


module might handle payments or inventory management.

3. Define Technical Specifications:

For each component, define the necessary technical specifications. This


includes:

o Database Design: What tables, fields, and relationships are needed?

o Data Structures: The types of data each component will use and manage.

o Algorithms: The processes, rules, and calculations that must be


performed.

o Interfaces: How each component interacts with other parts of the system.

Make sure to account for both functional requirements (e.g., login functionality)
and non-functional requirements (e.g., performance and security needs).

4. Create Detailed Design Documents:

Detailed design documents should provide clear and precise instructions for
developers. These documents typically include:

o Class Diagrams: Depict the structure of the system, outlining classes and
their relationships (e.g., User, Product, Order).

o Sequence Diagrams: Describe how different components interact over


time to complete a process, such as a user login or order processing.

o Database Design: Detailed information about tables, fields, relationships,


and constraints.

o User Interface Design: Details about how users will interact with the
system, including the layout of forms, buttons, and input fields.

5. Validate the Design:

The design should be reviewed and validated with stakeholders to ensure it


meets their needs and is feasible for developers to implement.

Gather feedback and make necessary adjustments before finalizing the


design to avoid rework during the development phase.

Detailed Design Documents (DDD)

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 144 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
A Detailed Design Document provides a detailed design of the software system.
It includes specific, detailed descriptions of the data structures, algorithms, interfaces,
and other elements of the system, as well as pseudocode or other representations of the
code that will be written. Here are examples of what a Detailed Design Document might
include:

1. Architecture Design Document (ADD): The Architecture Design Document


outlines the overall structure of the system. For instance, it might include a
diagram showing how a web application’s servers, databases, APIs, and user
interfaces interact. This helps in understanding how different components work
together to form the complete system.

2. Database Design Document: This document details the organization of the


database. It includes descriptions of tables, fields, and relationships between
data entities. An example could be an Entity-Relationship Diagram (ERD) that
shows how customer data links to orders and inventory in an e-commerce
system.

3. Class Diagram: The Class Diagram depicts the objects or classes in the
system, including their attributes and methods. For example, a class diagram for
a user authentication system might show classes like User, Admin, and
Session, detailing their interactions and responsibilities.

4. Data Flow Diagram (DFD): The Data Flow Diagram illustrates the flow of data
through the system. For example, a DFD might depict how a user’s payment
information moves from the shopping cart to the payment gateway, showing
how different processes handle and transfer data.

5. Component Design Document: This document describes the responsibilities


and interactions of individual system components. For instance, a document
might explain the “Login Module,” detailing its input/output data, user
authentication logic, and security protocols.

6. UI/UX Design Specification: The UI/UX Design Specification provides detailed


designs of the user interface and user experience. An example could be a
wireframe for a mobile app interface, illustrating user interactions such as
registration, login, and browsing products.

7. Interface Design Document (IDD): The Interface Design Document specifies


how different system components or external systems communicate. For
example, it might include REST API documentation for a weather forecasting
service, detailing endpoints, input parameters, and expected responses.

8. Detailed Class Specifications: This document offers a detailed description of


each class, including its attributes and methods. For example, a specification for
a Customer class in an e-commerce system might define attributes like Name
and Email and methods like AddToCart().

Best Practices for Design Specification


Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 145 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Ensuring that your design specifications are clear, complete, and feasible is
crucial for the success of any project. Here are some best practices to achieve this:

1. Clarity in Design

To achieve clarity in design, it is essential to ensure that every specification is


detailed enough to be actionable by developers. For instance, instead of a vague
statement like “The system should allow users to log in,” a more precise
specification would be: “The login module must include a form that validates the
user’s credentials with a database and initiates a session upon successful
validation.” This level of detail helps developers understand exactly what needs to
be implemented.

2. Completeness of Documentation

Completeness of documentation involves including all necessary


components of the system, such as database structure, system modules, and
external interfaces. For example, when documenting a login module, it is important
to specify the database tables used, the encryption method for passwords, and the
process flow. This ensures that all aspects of the system are covered, and nothing
is overlooked.

3. Feasibility Checks

Feasibility checks are crucial to ensure that the design can be implemented
with current technology and resources. This involves conducting validation reviews
with stakeholders to ensure that the design aligns with business goals and is
practical to implement. By performing these checks, potential issues can be
identified and addressed early in the development process.

Ensuring Alignment with Stakeholders

Maintaining stakeholder alignment throughout the design phase is crucial for


achieving a successful project outcome. This requires both regular validation and
integrating feedback to ensure the design stays on course.

 Validation Techniques

To verify that the design meets both technical and business needs, periodic
design reviews with stakeholders can be conducted. These reviews ensure that the
design specifications consistently reflect the original system requirements. This iterative
validation process helps maintain alignment with stakeholder expectations.

 Feedback Loops

Actively incorporating feedback from stakeholders during the design phase helps
refine the design to better suit user needs. Using prototypes or mockups to gather
feedback allows for adjustments and improvements, ensuring the final product not only
aligns with initial expectations but also meets evolving requirements.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 146 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF-CHECK 4.1-1

Multiple Choice:

1. What are system requirements?


a) A detailed list of programming languages used in the system
b) All necessary hardware, software, and network elements needed for a system
to function well
c) A set of instructions for software developers to follow during testing
d) A compilation of user feedback and software reviews

2. Which of the following is an example of a functional requirement?


a) The system should support up to 5,000 concurrent users
b) Users can add items to their shopping cart and proceed to checkout
c) The system must respond within 2 seconds for every user interaction
d) The system should maintain an uptime of 99.9%

3. What do non-functional requirements focus on?


a) Specific functions and features the system must perform
b) User interactions and business rules
c) The performance, security, usability, and reliability of the system
d) Data handling and business logic rules

4. What does a Data Flow Diagram (DFD) represent?


a) How users interact with the system
b) The flow of data through the system, showing processes and data storage
c) The user interfaces and layout of forms
d) The sequence of steps required for the system’s installation

5. How are use case diagrams used in system design?


a) They identify hardware requirements
b) They map out how data is processed in a system
c) They outline interactions between users and the system, guiding class
diagrams
d) They determine the file structure for the system
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 147 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
6. Which of the following is a non-functional requirement?
a) The system should allow users to reset their password
b) The system must authenticate users before granting access
c) The system should handle up to 10,000 concurrent users without performance
degradation
d) The system should allow users to search the product catalog

7. What is the main purpose of validation in system requirements?


a) To ensure system requirements are consistent with user expectations and
project goals
b) To replace functional requirements with non-functional ones
c) To automate data collection for future system versions
d) To assess the profitability of the system after deployment

8. Which of the following helps in transforming analysis models into design


specifications?
a) Use Case Diagrams
b) Feasibility studies
c) User stories
d) Business analysis reports

9. What is a Detailed Design Document (DDD)?


a) A document summarizing the stakeholders' feedback
b) A description of the project timeline
c) A document that provides detailed descriptions of data structures, algorithms,
and system architecture
d) A report on the financial impact of system changes

10. What is an Architecture Design Document (ADD)?


a) A document outlining software bugs found during testing
b) A high-level view of how different components (e.g., servers, databases, APIs)
interact in the system
c) A report outlining user feedback from early product testing
d) A summary of the coding standards used during development

11. What is the purpose of a Class Diagram?


a) To describe user interactions with the system
b) To outline the objects or classes in a system, their attributes, and their
relationships
c) To identify performance bottlenecks
d) To list software development tools

12. Which is a key factor in ensuring clarity in design specifications?


a) Providing vague system requirements
b) Avoiding technical details to simplify design
c) Including detailed and actionable specifications that developers can follow
d) Omitting non-functional requirements for simplicity

13. Why is code consistency important in system design?


Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 148 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
a) It ensures that developers can use different styles to write code
b) It makes it easier for multiple developers to collaborate by maintaining uniform
style and structure
c) It reduces the need for documenting system specifications
d) It helps avoid user feedback during the validation phase

14. What is the goal of conducting validation reviews with stakeholders during
the design phase?
a) To finalize the budget for the project
b) To ensure the design meets both technical and business needs
c) To gather information on competitor products
d) To check if all coding languages have been used correctly

15. What is a best practice for achieving completeness in documentation?


a) Focusing only on user interface design
b) Including all necessary components, such as database structure, system
modules, and interfaces
c) Ensuring that the design focuses only on non-functional requirements
d) Skipping validation with stakeholders to avoid delays

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 149 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 4.1-1

Multiple Choice :

1. b

2. b

3. c

4. b

5. c

6. c

7. a

8. a

9. c

10. b

11. b

12. c

13. b

14. b

15. b

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 150 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
INFORMATION SHEET 4.1-2
APPLYING DESIGN PRINCIPLES FOR MODULARITY AND
MAINTAINABILITY

Learning Objectives:
After reading this INFORMATION SHEET, you should be able to:

1. Understand and apply design principles such as SOLID to ensure modularity,


flexibility, and maintainability of system components.

2. Learn the importance of modularity in system design and how it improves


reusability and scalability.

3. Use design patterns to enhance system structure, ensuring long-term


maintenance and adaptability.

Modularity in System Design

Modularity involves breaking a system into smaller, manageable modules, each


responsible for a specific piece of functionality. This approach allows for independent
development, testing, and maintenance of each module, enhancing the system’s
flexibility and manageability. Here are the several key benefits of Modularity:

 Reusability: Modules can be reused across different systems or projects. For


example, a user authentication module developed for one application can be
repurposed into another without modification.

 Scalability: Modularity facilitates scaling or upgrading individual modules without


affecting the entire system. For instance, a module can be scaled independently
to handle increased load.

 Maintainability: Modularity simplifies updates and debugging by localizing


changes to specific modules. This reduces the risk of introducing bugs into other
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 151 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
parts of the system.

For example, consider a web application with distinct modules:

 User Management Module: Handles user registration, login, profile


management, and authentication, interacting with a user database.

 Payment Processing Module: Manages payment transactions, including credit


card processing and refunds, interfacing with external payment gateways.

 Product Catalog Module: Oversees product listings, updates, and inventory


management, working with a product database.

Each module can be developed and maintained independently. For instance,


updating payment processing logic to support a new method only affects the Payment
Processing Module, while debugging issues in the User Management Module does not
impact other modules.

To apply modularity in system design, follow these steps:

1. Identify Functional Areas: Break the system into distinct functional areas or
features, each corresponding to a module.

2. Define Module Interfaces: Detail the interfaces for each module, specifying
interactions with other modules and external systems, including input and output
data.

3. Develop Modules Independently: Develop each module as a standalone unit,


ensuring adherence to its defined interface, which facilitates parallel development
and testing.

4. Integrate Modules: Combine modules into the overall system, verifying


communication through their interfaces and conducting integration testing.

5. Maintain and Update Modules: Update and maintain each module


independently, ensuring that the module’s interface remains consistent to avoid
integration issues.

By implementing modularity, systems become more flexible, manageable, and


adaptable to evolving requirements. This design approach enhances the development
process and overall system quality.

With a solid understanding of modularity and its benefits, we can now explore how
design principles like SOLID further enhance modularity and maintainability. These
principles provide guidelines to refine modular design, ensuring that each module is
robust and adaptable.

SOLID Principles in Design


Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 152 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
To ensure your system is both robust and adaptable, adhering to the SOLID
principles is essential. These principles provide guidelines for creating software that is
easy to manage and extend. Let’s explore each principle in detail:

Single Responsibility Principle (SRP)

What It Means: Each module or class in your software should have only one job or task.

Why It’s Important: When a class or module has a single responsibility, it’s easier to
update and less likely to cause issues in other parts of your system.

Example: For instance, a UserService class should solely handle user-related tasks like
registration and login, not payment processing. This separation ensures that changes to
payment handling won’t impact user operations.

Open-Closed Principle (OCP)

What It Means: Your software should be designed so that new features can be added
without altering existing code.

Why It’s Important: This principle helps in maintaining system stability. By extending
existing code instead of modifying it, you avoid introducing bugs to existing
functionalities.

Example: Consider adding new report types to your system. Instead of modifying the
current report classes, you should extend them with new classes that handle the new
report types.

Liskov Substitution Principle (LSP)

What It Means: Subclasses should be able to replace their parent classes without
affecting the correctness of the program.

Why It’s Important: Ensuring that subclasses can be used interchangeably with their
parent classes maintains consistency and reliability in your system.

Example: If you have a Rectangle class and create a Square class that inherits from it,
the Square should work wherever a Rectangle is expected, without breaking
functionality.

Interface Segregation Principle (ISP)

What It Means: Clients should not be forced to use interfaces they don’t need.

Why It’s Important: This principle helps keep your classes focused and prevents them
from being cluttered with unnecessary methods.

Example: A Printable interface should only include methods relevant to printing, not
unrelated methods like those for saving files. This ensures that classes implementing
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 153 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Printable are not burdened with unnecessary functionality.

Dependency Inversion Principle (DIP)

What It Means: High-level modules should not depend on low-level modules. Instead,
both should depend on abstractions (interfaces).

Why It’s Important: This principle enhances flexibility and makes the system easier to
modify. By depending on abstractions, you can change low-level implementations
without affecting the high-level modules.

Example: Rather than a PaymentProcessor class depending directly on a specific


CreditCard class, it should depend on an abstract PaymentMethod interface. This allows
you to swap out different payment methods without altering the payment processing
logic.s

By incorporating these SOLID principles, your software design will become more
modular, maintainable, and adaptable to changes over time.

Design Patterns for Maintainability

A design pattern provides a solution to a common problem encountered in


software design. It is not a finished design ready for direct implementation but rather a
template or description for addressing a specific issue that can be adapted to various
contexts.

Design Patterns don’t go directly into our code, they first go into our brain. Once
we have loaded our brain with a good working knowledge of patterns, we can start to
apply them to our new designs and rework our old code when we find it degrading into
an inflexible mess.

Common Patterns

1. The Singleton Pattern

The Singleton pattern ensures a class has only one instance and provides a
global point of access to it. This is useful when exactly one object is needed to

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 154 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
coordinate actions across the system.

The singleton design pattern solves problems by allowing it to:

 Ensure that a class only has one instance

 Easily access the sole instance of a class

 Control its instantiation

 Restrict the number of instances

 Access a global variable

Common Uses:

 The abstract factory, factory method, builder, and prototype patterns can use
singletons.

 Facade objects are often singletons because only one facade object is required.

 State objects are often singletons.

 Singletons are often preferred to global variables because:

 They do not pollute the global namespace (or, in languages with nested
namespaces, their containing namespace) with unnecessary variables.

 They permit lazy allocation and initialization, whereas global variables in many
languages will always consume resources.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 155 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
2. The Factory Pattern

The Factory pattern defines an interface for creating an object, but lets
subclasses decide which class to instantiate. Factory method lets a class defer
instantiation to subclasses.

As with every factory, the Factory Method Pattern gives us a way to encapsulate
the Instantiations of concrete types. Looking at the class diagram above, we can see that
the abstract creator class gives you an interface with a method for creating objects, also
known as the factory method. Any other methods implemented in the abstract creator are
written to operate on products produced by the factory method. Only subclasses actually
implement the factory method and create products.

The Factory Method Pattern lets subclasses decide which class to instantiate.
Because the creator class is written without the knowledge of the actual product that will
be created, we say "decide" not because the pattern allows subclasses themselves to
decide, but rather because the decision actually comes down to which subclass is used
to create the product.

3. The Observer Pattern

The pattern that keeps our objects in the known when something they care about
happens, is the Observer pattern. It is one of the most commonly used design patterns
and also incredibly useful. The Observer pattern defines a one-to-many dependency
between objects s+o that when one object changes state, all of its dependents are
notified and updated automatically.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 156 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
The Subject and the Observer define the one-to-many relationship. We have one
subject, who notifies many observers when something in the subject changes. The
observers are dependent on the subject when the subject’s state changes, the observers
are notified.

4. The Command Pattern

The Command pattern encapsulates a request as an object, thereby letting us


parameterize other objects with different requests, queues, or log requests, and support
undoable operations. We know that a command object encapsulates a request by
binding together a set of actions on a special receiver. To achieve this, it packages the
action and receiver into an object that exposes just one method execute(). When
called, execute() causes the actions to be invoked on the receiver. From the outside, no
other object really knows what action gets performed on what receiver, they just know if
they call the execute method, their request will be serviced.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 157 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Common Uses:

 GUI buttons and menu items


 Macro recording
 Mobile code
 Multi-level undo
 Networking
 Parallel processing
 Progress bars
 Thread pools

5. The Decorative Pattern

The decorator pattern attaches additional responsibilities to an object dynamically.


Decorators provide a flexible alternative to sub-classing for extending functionality.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 158 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
The Decorator pattern is a design pattern that allows behavior to be added to an
individual object, dynamically, without affecting the behavior of other objects from the
same class. The decorator pattern is often useful for adhering to the Single
Responsibility Principle, as it allows functionality to be divided between classes with
unique areas of concern. Decorator use can be more efficient than subclassing because
an object's behavior can be augmented without defining an entirely new object.

What Problems Can It Solve?

 Responsibilities should be added to (and removed from) an object dynamically at


run-time.
 A flexible alternative to subclassing for extending functionality should be provided.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 159 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF-CHECK 4.1-2

Identification:

1. The principle of breaking a system into smaller, manageable modules, each


responsible for a specific functionality.

2. A key benefit of modularity that allows modules to be used in other projects


without modification.

3. A benefit of modularity that allows modules to scale independently without


affecting other system parts.

4. A benefit of modularity that simplifies debugging and updates by isolating changes


to specific modules.

5. The module in a web application responsible for managing user authentication,


registration, and profile updates.

6. The process of combining independently developed modules into the overall


system, ensuring they communicate through their interfaces.

7. The SOLID principle that states each module or class should have only one
responsibility.

8. The SOLID principle that ensures high-level modules do not depend on low-level
modules but on abstractions like interfaces.

9. The design pattern that ensures only one instance of a class is created and
provides global access to it.

10. The design pattern that defines a one-to-many dependency between objects,
ensuring that all dependent objects are notified when one object changes state.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 160 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 4.1-2

Identification:

1. Modularity

2. Reusability

3. Scalability

4. Maintainability

5. User Management Module

6. Integration

7. Single Responsibility Principle (SRP)

8. Dependency Inversion Principle (DIP)

9. Singleton Pattern

10. Observer Pattern

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 161 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
INFORMATION SHEET 4.1-3
DEVELOPING ARCHITECTURAL DESIGN BASED ON
SPECIFICATIONS

Learning Objectives:
After reading this INFORMATION SHEET, you should be able to:

1. Understand the process of creating architectural designs from system design


specifications.

2. Learn how to define system architecture that meets both functional and non-
functional requirements.

3. Apply architectural design techniques to ensure system scalability, security, and


performance.

System Architecture

Systems Architecture is a fundamental concept in technology and engineering


that refers to the high-level design and structure of complex systems. It serves as a
blueprint or framework that defines how various components, subsystems, and modules
within a system interact with each other to achieve specific objectives.

One key aspect of software architecture is layered architecture, which helps


create a conceptual model for system development. This approach breaks down the
system into manageable subsystems, each with specific functionality and responsibilities.
These subsystems communicate with each other, aligning the entire system to perform
its intended tasks.

Systems architecture is the backbone of any software or enterprise architecture,


enabling the efficient functioning of the entire system while accommodating the ever-
evolving technology landscape.

Key Components of Systems Architecture

In systems architecture, it's crucial to understand the key components that form
the backbone of any efficient and well-structured system. Let's explore ten essential
components that define the landscape of software architecture.

 Hardware Infrastructure: The physical machinery, servers, and equipment that


support the system's operations.

 Software Stack: A set of software layers that includes the operating system,
middleware, and application software.

 Network Configuration: The arrangement of network components, such as


routers, switches, and firewalls, ensuring seamless communication.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 162 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
 Data Storage: The place where data is stored, whether in relational or non-
relational databases.

 Web User Interface (UI): Web UI is the user-facing part of the system where
users interact with the application.

 Security Measures: Strategies and tools implemented to safeguard the system


from threats and breaches.

 Scalability Solutions: Mechanisms for adapting the system to handle increased


loads and traffic.

 Integration Protocols: Standards and protocols integrate various system


components seamlessly.

 Monitoring and Logging: Tools and practices to track system performance and
identify issues.

 Backup and Recovery: Procedures and tools in place to ensure data backup and
system recovery in case of failures.

Building a Robust System Architecture

Designing a solid system architecture is essential for creating an efficient and


scalable system. Here’s a streamlined approach to developing a system architecture that
works:

1. Break Down the System into Components

Start by identifying the key parts of your system. Each part, or component, plays a
crucial role in the system’s overall functionality. For instance, in an online store:
o User Interface (UI): The front-end where customers browse and shop.

o Payment Gateway: Manages transactions and processes payments.

o Product Database: Stores detailed information about products.

o Order Management System: Tracks and manages customer orders and


inventory.

Think of these components like the rooms in a house: each room has a specific
function, like the kitchen for cooking or the living room for relaxing. Each system
component has a distinct role, contributing to the system’s overall operation.

2. Define How Components Communicate

Next, determine how these components will interact with each other through
interfaces. Interfaces are like bridges that allow different parts of the system to
exchange information. For example:
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 163 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
o User Interface to Payment Gateway: The UI sends transaction details to
the payment gateway using an API (Application Programming Interface).
This ensures secure and accurate communication between the two
components.

Imagine this as a kitchen door through which dishes are passed to the dining room.
The door (interface) ensures that the dishes (data) are transferred smoothly and
securely.

3. Create a System Structure Overview

Develop a high-level diagram that illustrates how all the components fit together. This
visual representation helps you see the entire system at a glance. For instance:

o Structure Diagram: Create a diagram showing how the user interface


connects to the payment gateway, product database, and order
management system. This diagram helps you understand how each
component interacts within the system.

It’s like a blueprint for a house that shows the layout and connections between rooms,
helping you visualize how everything fits together.

4. Align Architecture with System Goals

Ensure that your architecture meets both functional and non-functional


requirements. This means making sure the system can handle its intended tasks and
maintain performance under various conditions. For example:

o Scalability: If your online store expects high traffic, design your


architecture to handle a large number of users without issues.

o Security: Ensure that the payment gateway processes transactions


securely to protect sensitive information.

Think of this like preparing your house for a big party. You need enough space
and resources to accommodate all your guests comfortably. Similarly, your system
architecture should be capable of handling expected loads and ensuring security.

Architectural Design Best Practices

When designing a system's architecture, best practices ensure the system


remains reliable, efficient, and secure. To build a reliable and effective system, it's
essential to follow key best practices in architectural design:

1. Scalability ensures that the system can grow to accommodate more users or
data without performance issues. For example, designing a restaurant with the
flexibility to add more tables as customer numbers increase helps in managing
growth seamlessly. Scalability is crucial for keeping the system functional and
responsive as demand rises.
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 164 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
2. Modularity involves breaking the system into separate, manageable
components that can be independently updated or replaced. Imagine a modular
kitchen where appliances can be upgraded without redesigning the entire
space. This approach simplifies maintenance and allows for easier updates, as
changes to one part do not affect the entire system.

3. Performance ensures that the system operates efficiently and quickly. For
instance, designing a car to accelerate smoothly and without lag reflects good
performance. Efficient performance is vital for delivering a smooth user
experience and meeting user expectations.

4. Security protects the system from unauthorized access and potential threats.
Just as you would install locks and alarms to safeguard your home,
implementing robust security measures helps protect the system from cyber
threats. Strong security is essential for maintaining data safety and user trust.

Developing Architecture from Specifications

When developing system architecture from specifications, the goal is to translate


detailed instructions into a clear, functional design. Here’s a step-by-step approach:

1. Translate Specifications into Design

Begin by examining the specifications document, which outlines all system


requirements. Break down these requirements into a structured design. For instance, if
the specifications call for an e-commerce platform, start by identifying key features like
user authentication, product listings, and payment processing.

2. Focus on Business and Technical Needs

Address both the business needs (what the client envisions) and the technical details
(how the system will operate). Ensure the design aligns with the client's goals and
incorporates necessary technical elements, such as database structure and user
interface layout. This dual focus ensures the architecture supports the intended
functionality and meets user expectations.

3. Create a Detailed Yet Flexible Blueprint

Develop a detailed architectural blueprint that guides developers but remains


adaptable. Include diagrams, component descriptions, and interactions. The design
should be specific enough to provide clear instructions but flexible enough to
accommodate future changes or adjustments. This balance ensures that the system can
evolve as requirements shift.

By translating specifications into a comprehensive and adaptable architecture, you


create a solid foundation for developing a system that meets both the client’s vision and
technical requirements effectively.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 165 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF-CHECK 4.1-3

Multiple Choice

1. What is Systems Architecture primarily concerned with?


a) The programming languages used in software development
b) The high-level design and structure of complex systems
c) The marketing strategies for software products
d) The color scheme of the system's user interface

2. What is one of the key advantages of layered architecture in system


design?
a) It eliminates the need for hardware infrastructure
b) It breaks down the system into manageable subsystems
c) It removes the need for testing subsystems
d) It increases the system's complexity unnecessarily

3. Which of the following is an example of hardware infrastructure in a


system architecture?
a) Relational databases
b) Middleware software
c) Servers and physical equipment
d) User interfaces

4. What is the primary function of network configuration in system


architecture?
a) To determine the color of the UI
b) To ensure seamless communication between components
c) To store and retrieve data from databases
d) To process payment transactions

5. Why is modularity important in system architecture?


a) It allows for the entire system to be replaced at once
b) It enables separate components to be independently updated or replaced
c) It forces developers to use the same programming language
d) It prevents any interaction between system components

6. Which component in system architecture handles user interactions with


the application?
a) Data Storage
b) Web User Interface (UI)
c) Network Configuration
d) Backup and Recovery

7. Which of the following ensures that a system can handle increased loads
and traffic?
a) Security Measures
b) Scalability Solutions
c) Data Storage Solutions
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 166 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
d) Monitoring and Logging

8. What does a system structure overview diagram illustrate?


a) The budget and timeline for system development
b) How different components of the system interact and fit together
c) The details of the software license agreements
d) The code required for each subsystem

9. Why is scalability considered a best practice in system design?


a) It allows a system to handle growth in users or data without performance
issues
b) It focuses on preventing security breaches in a system
c) It requires the use of the latest programming languages
d) It eliminates the need for testing after development

10. What is the role of performance in system architecture?


a) To ensure that the system operates efficiently and meets user expectations
b) To provide a backup plan in case of a system failure
c) To outline the project's scope and timeline
d) To manage the user authentication process

11. What is the purpose of defining how components communicate in system


architecture?
a) To identify the hardware requirements of each component
b) To ensure data is exchanged smoothly between different parts of the system
c) To decide on the user interface design for each component
d) To define the system's budget

12. Which of the following is an example of a security measure in system


architecture?
a) Backup and Recovery Solutions
b) Middleware Software
c) Firewalls and encryption protocols
d) User interface design standards

13. What is a key benefit of monitoring and logging in system architecture?


a) They simplify user interface design
b) They ensure high-speed internet access
c) They help track system performance and identify potential issues
d) They eliminate the need for data storage

14. What does the process of translating system specifications into design
involve?
a) Focusing only on technical needs and ignoring business goals
b) Creating a detailed design that balances technical and business
requirements
c) Eliminating the need for architectural design documents
d) Defining the code structure for the project before starting development

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 167 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
15. Why is backup and recovery a critical component in system architecture?
a) To reduce system complexity
b) To protect the system from data loss or system failures
c) To improve the system's user interface
d) To eliminate the need for hardware infrastructure

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 168 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 4.1-3
Multiple Choice

1. b

2. b

3. c

4. b

5. b

6. b

7. b

8. b

9. a

10. a

11. b

12. c

13. c

14. b

15. b

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 169 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
INFORMATION SHEET 4.1-4
DEVELOPING SYSTEM DESIGN IN ACCORDANCE WITH
REQUIREMENTS

Learning Objectives:
After reading this INFORMATION SHEET, you should be able to:

1. Ensure that the system design adheres strictly to the system requirements as
outlined by stakeholders.

2. Develop a system design that is fully aligned with both functional and non-
functional requirements.

3. Learn to verify and validate the system design against system requirements,
ensuring that every component satisfies its intended purpose.

System Design and Requirements Alignment

When developing a system design, it's crucial to ensure that every element
aligns with the requirements specified by stakeholders. This process involves translating
the detailed requirements into a practical design that meets their needs. Here’s a step-
by-step approach to achieve this:

1. Understand the Requirements: Start by thoroughly reviewing the system


requirements provided by stakeholders. These requirements outline what the
system needs to do, including functional aspects (like features and capabilities)
and non-functional aspects (such as performance and security).

2. Translate Requirements into Design: Break down the requirements into design
components. For instance, if a requirement specifies high security for user data,
your design should include robust encryption methods and secure access
controls.

3. Design Implementation: As you develop the system, ensure each design


decision—whether about architecture, components, or functionality—directly
reflects these requirements. This ensures that every part of the system contributes
to meeting the specified needs.

4. Review and Validate: Continuously compare your design against the


requirements. Conduct regular reviews to confirm that the design aligns with what
was asked for. This is similar to following a detailed recipe where each ingredient
and step must match to achieve the desired result.

5. Adapt and Refine: Be prepared to adjust your design based on feedback or


changes in requirements. Ensure your design is flexible enough to incorporate
changes without deviating from the core requirements.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 170 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
Functional and Non-Functional Requirements

As we have discussed in the previous module, understanding the distinction between


functional and non-functional requirements is crucial for developing a system that not
only meets user needs but also performs efficiently. When designing a system, it's
essential to distinguish between these two types of requirements to ensure the system
performs effectively and efficiently.

 Functional Requirements: These describe what the system should do. They
include specific functionalities or features that the system must have. For
example, if you’re designing a banking application, a functional requirement might
be that the system should process transactions securely.

 Non-Functional Requirements: These focus on how the system should perform.


They cover aspects such as performance, reliability, and scalability. For instance,
a non-functional requirement for the banking application might be that it should
handle a high volume of transactions quickly without any slowdowns.

Process Overview

1. Identify Functional Requirements: Review the project specifications to


determine what the system must accomplish. This involves understanding the key
features and capabilities that need to be implemented.

2. Determine Non-Functional Requirements: Assess the performance criteria and


constraints. This includes defining how well the system should perform under
various conditions, such as handling many users or ensuring data security.

3. Integrate Requirements into Design: Ensure that both functional and non-
functional requirements are reflected in your design decisions. This means
building features that fulfill functional needs and incorporating mechanisms that
address performance and scalability.

4. Verify and Validate Design: Regularly review your design to ensure it meets both
types of requirements. Testing the system against these criteria helps confirm that
the design works as intended and performs effectively.

By understanding and addressing both functional and non-functional requirements,


you ensure that your system not only delivers the required features but also performs
reliably and efficiently. Integrating these requirements into your design and rigorously
validating them will result in a system that meets stakeholder expectations and stands up
to real-world challenges

Verifying System Design

Distinguishing between functional and non-functional requirements is essential for


designing systems that meet user needs and perform efficiently. With this understanding,
it’s crucial to ensure that your system design aligns with these requirements and
functions correctly. Here’s a structured approach to verifying your system design:
Date Document No. AB-ICT0601914251302
Conducting Object-Oriented Developed: Issued by:
Page 171 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
1. Review Design Against Requirements: Begin by thoroughly examining your
design documents and comparing them with the initial requirements provided by
stakeholders. This step is akin to inspecting a newly built house against its
architectural blueprint. Ensure that every feature, function, and performance
criterion specified in the requirements is accurately reflected in the design. For
instance, if the requirements specify a secure user login feature, verify that this
feature is present and operates as intended.

2. Conduct Testing: To validate the system design, perform a comprehensive range


of tests:

o Functional Testing: Confirm that all features operate as expected. For


example, test the login functionality with various scenarios, including both
correct and incorrect passwords.

o Performance Testing: Assess how the system handles load and scales
under stress. This includes stress testing to observe system performance
under heavy usage.

o Security Testing: Ensure that the system is secure from potential threats.
This involves testing for vulnerabilities such as SQL injection or cross-site
scripting.

3. Gather Feedback: Collect insights from stakeholders and end-users to confirm


that the design meets their needs and expectations. Conduct user testing
sessions to evaluate usability and functionality. For example, gather feedback on
the login feature’s user experience and identify any areas for improvement.

4. Refine and Adjust: Based on the review, testing, and feedback, make necessary
adjustments to the design. This could involve tweaking features, enhancing
performance, or addressing any identified issues. For example, if users report that
the login process is slow, optimize the code to improve performance.

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 172 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
SELF-CHECK 4.1-4

Multiple Choice

1. What is the first step in aligning system design with requirements?


a) Start developing the user interface
b) Review and understand the system requirements provided by stakeholders
c) Begin testing the system for performance
d) Finalize the database design

2. How should functional requirements be reflected in the system design?


a) By implementing features and functionalities that fulfill user needs
b) By ensuring the system can handle high loads
c) By optimizing the performance for security purposes
d) By creating backup and recovery solutions

3. What is an example of a non-functional requirement in a system?


a) The system must allow users to reset their passwords
b) The system should maintain uptime of 99.9%
c) Users must be able to create and manage profiles
d) The system should include a user-friendly help section

4. What is the purpose of regularly reviewing the system design during


development?
a) To redesign the entire system from scratch
b) To ensure the design aligns with both functional and non-functional
requirements
c) To only check if the system meets performance goals
d) To gather feedback on the color scheme of the user interface

5. What is a crucial step when translating requirements into system design?


a) Testing the design for user satisfaction
b) Breaking down the requirements into specific design components
c) Implementing the system’s backup solution
d) Removing non-functional requirements from the design

6. Which of the following is a key aspect of functional testing?


a) Ensuring the system can process a large number of transactions
b) Validating that all features perform as expected
c) Testing the system’s ability to recover from data loss
d) Confirming that the system maintains security protocols

7. What should be included in the design when a requirement specifies high


security for user data?
a) Optimization for fast load times
b) Robust encryption methods and secure access controls
c) A user-friendly login interface
d) Testing procedures for scalability

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 173 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
8. Why is feedback from stakeholders important during system design?
a) It ensures that the design reflects only non-functional requirements
b) It provides insight into how well the system aligns with user needs and
expectations
c) It replaces the need for functional testing
d) It reduces the overall cost of the system

9. How should non-functional requirements be addressed in the system


design?
a) By focusing only on the functional aspects of the system
b) By incorporating mechanisms that ensure performance and scalability
c) By delegating them to the testing phase
d) By using them solely for documenting the project timeline

10. What is the goal of refining and adjusting the system design based on
testing and feedback?
a) To change the project’s original scope
b) To optimize and improve system performance, features, and usability
c) To eliminate functional requirements
d) To speed up the development process

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 174 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #
ANSWER KEY 4.1-4

Multiple Choice

1. b

2. a

3. b

4. b

5. b

6. b

7. b

8. b

9. b

10. b

Date Document No. AB-ICT0601914251302


Conducting Object-Oriented Developed: Issued by:
Page 175 of
Analysis and Design for
Developed by: 176
Python Applications
Revision #

You might also like