KEMBAR78
Design Principles & Clean Code | PDF | Class (Computer Programming) | Method (Computer Programming)
0% found this document useful (0 votes)
18 views4 pages

Design Principles & Clean Code

Uploaded by

Oumima Kh
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)
18 views4 pages

Design Principles & Clean Code

Uploaded by

Oumima Kh
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/ 4

Design Principles & Clean Code

12 December 2024 09:29

///////////////////////////////// ///////////////////////////////////////////////////////////////
SOLID principles A set of design principles, to create well-structured, mainta
building robust object-oriented designs by improving code r
Can you explain the Single A class should have one reason to change.
Responsibility Principle (SRP) Example: A ReportGenerator class should only generate rep
with an example?
What is the Open/Closed The Open/Closed Principle states that classes should be ope
Principle, and how do you Example: Use inheritance or interfaces to add new function
apply it in Java?
Liskov Substitution objects of a superclass should be replaceable with
Principle (LSP) correctness of the program
DESIGN PATTERNS Reusable solutions for typical software design cha
how to create a singleton Private constructor
Private static instance
public static method to call the instance
• Use it when we need only one instance of a class globally
3 types of design patterns creational -> Focus on object creation
structural -> Focus on the structure and composition of cla
behavioral -> Focus on communication between objects ob
What is a design pattern? Why A design pattern is a reusable solution to common problem
are they important? writing code that is maintainable, scalable and easy to unde
What is the Factory pattern, Factory Pattern: It provides a method to create objects
and how does it work? encapsulates the object creation logic.
How it works
1. Interface for Creation: Defines a method for creating
2. Concrete Implementations: Subclasses implement thi
3. the factory interface to create objects without knowing
What is the difference Abstract Factory is a higher level of abstraction, is a factory
between Factory and Abstract dealing with one type of object
Factory?
Builder pattern Use it when constructing an object requires multiple steps
////////////////////////////////////////////////////////
ainable, and scalable software. These principles help in
readability, reusability, and flexibility.

ports, while a separate ReportPrinter class handles printing.

en for extension but closed for modification.


nality instead of modifying existing code.

h objects of a subclass without affecting the

allenges

y for example database connections

asses and objects.


bserver command
ms in software development. They provide templates for
erstand.
without specifying their exact classes. A Factory class

objects.
is method to create specific objects.
g their concrete classes.
of factories. While factory

or when the object has many optional parameters.


What is the difference Abstract Factory is a higher level of abstraction, is a factory
between Factory and Abstract dealing with one type of object
Factory?
Builder pattern Use it when constructing an object requires multiple steps
of factories. While factory

or when the object has many optional parameters.

You might also like