0% found this document useful (0 votes)
6 views5 pages

Open/Closed Principles in Software Design

The Open/Closed Principle states that software entities should be open for extension but closed for modification, allowing for future enhancements without altering existing functionality. Refactoring is the process of restructuring code to improve its design and readability without changing its external behavior, making it easier to maintain and spot bugs. The significance of refactoring lies in simplifying code, improving maintainability, and ensuring that the original functionality remains intact.

Uploaded by

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

Open/Closed Principles in Software Design

The Open/Closed Principle states that software entities should be open for extension but closed for modification, allowing for future enhancements without altering existing functionality. Refactoring is the process of restructuring code to improve its design and readability without changing its external behavior, making it easier to maintain and spot bugs. The significance of refactoring lies in simplifying code, improving maintainability, and ensuring that the original functionality remains intact.

Uploaded by

Ajay Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Open /Closed Principles

“Software entities should be open for


extension but closed for modification.”
Open to Extension
• When we write a software component it should be open for future
extension.
• A class can be considered to be open if its functionality can be
enhanced by sub-classing it.
• Stick to the current behaviours
• Keep in mind that behaviour could always change and evolve
• We should anticipate what could change and what could be extended
But Closed for Modifications…
• A class or module is said to be closed, if it’s available for use by other
modules without modifying it.
• Basic requirements for class to be closed is it’s fields and functions
should be finalized and they cannot change.
• The implementation of any software entity should be closed for
modification.
• A class can be considered to be closed if its runtime or compiled class is
available for use as a base class which can be extended by child classes.
• If the behaviour changes , we should not change how a specific entity
work, we just need to extend it.
What is Refactoring ?
• It is the process of restructuring code , while not changing its original
functionality. The goal of refactoring is to improve internal code by
making many small changes without altering the code’s external
behaviour.

• Computer programmers and software developers refactor code to


improve the design, structure and implementation of software.
Refactoring improves code readability and reduces complexities.
Refactoring can also help Software developers find bugs or
vulnerabilities hidden in their software.
Need and Significance of Refactoring :-
• Makes the code easier to understand and read because the goal is to
simplify code and reduce complexities.
• Improves maintainability and makes it easier to spot bugs or make
further changes.
• Encourages a more in-depth understanding of code. Developers have
to think further about how their code will mix with code already in the
code base.
• Focus remains only on functionality. Not changing the code's original
functionality ensures the original project does not lose scope.

You might also like