0% found this document useful (0 votes)
5 views7 pages

Software Engineering

Software engineer file notes for MCA

Uploaded by

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

Software Engineering

Software engineer file notes for MCA

Uploaded by

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

QUESTION

Explain the principles of software design?

ANSWER

Principles of Software Design


The principles of software design provide guidelines to create robust,
maintainable, efficient, and scalable software systems. These principles
help developers write clean, organized, and high-quality code.

Software Design is also a process to plan or convert the software


requirements into a step that are needed to be carried out to develop a
software system. There are several principles that are used to organize
and arrange the structural components of Software design. Software
Designs in which these principles are applied affect the content and the
working process of the software from the beginning.
Below are the key principles of software design:

1. DRY (Don’t Repeat Yourself)

Concept: Avoid duplicating code or functionality. Each piece of


knowledge or logic in a system should have a single,
unambiguous representation.

Benefit: Reduces redundancy, improves maintainability, and


ensures consistency.

Example:

Use functions or classes to avoid repeating the same logic in


multiple places.

def calculate_area(length, width):

return length * width

area1 = calculate_area(10, 5)

area2 = calculate_area(8, 3)

2. KISS (Keep It Simple, Stupid)

Concept: Design software systems as simply as possible.


Avoid unnecessary complexity.

Benefit: Easier to understand, maintain, and debug.

Example: Prefer straightforward code over complex,


hard-to-follow solutions.

# Complex way:
if not (user is None and len(user.name) == 0):

print("Valid User")

# Simple way:

if user and user.name:

print("Valid User")

3. SOLID Principles
These are a set of five principles for object-oriented design:

S – Single Responsibility Principle (SRP)

A class should have only one reason to change. Each class should
handle only one specific task or functionality.

Example: Separate User and EmailService classes.

O – Open/Closed Principle (OCP)

A class should be open for extension but closed for modification.

Example: Use interfaces or abstract classes for adding new features


without altering existing code.

L – Liskov Substitution Principle (LSP)

Subtypes must be substitutable for their base types without affecting the
behavior of the program.

Example: If Bird is a parent class, a Penguin should be usable wherever


Bird is expected.

I – Interface Segregation Principle (ISP)

Do not force a class to implement interfaces it does not use.


Example: Divide large interfaces into smaller, specific ones.

D – Dependency Inversion Principle (DIP)

High-level modules should not depend on low-level modules. Both


should depend on abstractions.

Example: Depend on interfaces, not on concrete implementations.

4. Encapsulation

Concept: Bundle data (variables) and methods that operate on


the data into a single unit (e.g., a class). Restrict access using
access modifiers (private, protected, public).

Benefit: Enhances data security and modularity.

Example:

class Person:

def __init__(self, name, age):

self.__name = name # Private attribute

self.__age = age

def get_name(self):

return self.__name

5. Modularity

Concept: Break software into independent, self-contained


modules that can be developed, tested, and maintained
separately.
Benefit: Enhances reusability and makes debugging easier.

Example: Divide a large application into smaller modules like User


Module, Payment Module, etc.

6. Separation of Concerns (SoC)


Concept: Divide a system into distinct sections, each addressing a
separate concern or functionality.

Benefit: Improves code clarity and maintainability.

Example: Separate UI, business logic, and database layers in a web


application.

7. YAGNI (You Aren’t Gonna Need It)

Concept: Do not add functionality unless it is necessary. Avoid


premature optimization.

Benefit: Prevents wasted effort on features that may never be


used.

Example: Avoid writing extra methods or classes "just in case."

8. Law of Demeter (LoD)

Concept: A module should not know the internal details of


other modules. "Talk only to friends, not to strangers."

Benefit: Reduces dependencies between classes.

Example: Avoid chaining too many method calls.

# Violation of LoD:
person.get_address().get_city().get_zipcode()

# Better:

person.get_zipcode()

9. Design for Change

Concept: Anticipate and design for future changes by making


the system flexible and adaptable.

Benefit: Reduces the im,pact of modifications and new


requirements.

Example: Use interfaces, abstract classes, and configuration


files to handle changing requirements.

10. Reusability

Concept: Write components (functions, classes, modules) that


can be reused across multiple applications.

Benefit: Saves time and reduces duplication.

Example: Create utility libraries or functions that can be used


in multiple projects.

11. Scalability

Concept: Design software that can handle growth in data,


users, or complexity without a major redesign.

Benifit:Ensures long-term viability and performance.


Example: Use efficient algorithms and modular architecture to
support scaling.

Summary
The principles of software design—DRY, KISS, SOLID, and
others—promote clean, maintainable, and efficient software
development. By following these principles, developers can build
systems that are easier to understand, test, and scale.

You might also like