Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

OBJECT ORIENTED ANALYSIS

& DESIGN
Submitted to: Mr. Zeeshan Nizamani

APRIL 17, 2024


SUBMITTED BY: SHAMAN ALI MAHAR 2K21-IT-188
ITC:505
What is refactoring?
Refactoring 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 behavior.

“Code refactoring is the process of modifying an existing code. In code refactoring, we


do not introduce any new functionality or alter the working of any software module.
Instead, we optimize the structure and implementation of the code to increase
readability and understandability. “

What is the purpose of refactoring?


Refactoring improves code by making it:

• More efficient by addressing dependencies and complexities.

• More maintainable or reusable by increasing efficiency and


readability.

• Cleaner so it is easier to read and understand.

• Easier for software developers to find and fix bugs or vulnerabilities


in the code.

What are the benefits of refactoring?


Refactoring can provide the following benefits:

• 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.

What are the challenges of refactoring?


Challenges do come with the process, however. Some of these include:

• The process will take extra time if a development team is in a rush


and refactoring is not planned for.

• Without clear objectives, refactoring can lead to delays and extra


work.

• Refactoring cannot address software flaws by itself, as it is made to


clean code and make it less complex.

Techniques to perform code refactoring


Organizations can use different refactoring techniques in different instances.
Some examples include:

• Red, green. This widely used refactoring method in Agile


development involves three steps. First, the developers determine
what needs to be developed; second, they get their project to pass
testing; and third, they refactor that code to make improvements.

• Inline. This technique focuses on simplifying code by eliminating


unnecessary elements.

• Moving features between objects. This technique creates new


classes, while moving functionality between new and old data
classes.
• Extract. This technique breaks down code into smaller pieces and
then moves those pieces to a different method. Fragmented code is
replaced with a call to the new method.

• Refactoring by abstraction. This technique reduces the amount of


duplicate code. This is done when there is a large amount of code to
be refactored.

• Compose. This technique streamlines code to reduce duplications


using multiple refactoring methods, including extraction and inline.
Why Code Refactoring is Important in Software Development?
Code refactoring is vital in software development for maintaining clarity, efficiency, and
collaborative understanding.

Let’s discuss some of the major importance or benefits of code refactoring in


software development…
1. To Keep Your Code Clean
Code refactoring simplifies, cleans, and enhances code by eliminating redundancies,
excessive variables, and complexity, facilitating easier maintenance, extension, debugging,
and comprehension of software projects.
2. To Improve the Performance of The Application
A streamlined application with minimal clutter, refreshed code, and updated components
performs faster, resulting in improved user satisfaction and experience.
3. You Save Time and Money in The Future
Clean, clear code streamlines feature implementation, saves developers' time,
and reduces upgrade delays and financial burdens caused by application
damage.
4. To Reduce the Technical Debt
The ultimate price of software isn't set at launch; without regular updates, it
risks malfunctioning and accruing technical debt, necessitating constant code
refactoring to mitigate this debt.
5. Your Code is Outdated
Keeping your code updated is crucial as outdated libraries or frameworks may
cause errors or malfunction, potentially disrupting your application's
performance and introducing bugs.
6. Makes Bugs Easier to Be Found
It’s easy to find the bugs in an application when you understand the code and
entire structure of your application. You can test the application and find the
bug if you understand how things are connected and working in an
application.
7. Improves the System Design

Regular code refactoring enhances learning, improves project understanding,


and ensures simpler, more efficient code, mitigating long-term issues and
promoting adherence to best practices for sustainable software design.

Conclusion

Code refactoring is not just about improving the code. It’s a healthy habit for
any company which should be followed to avoid any major issues or bugs in
the application. A project lives longer for years if it’s regularly updated or
refactored. Your application runs faster and it gives a better customer
experience which is important to run any kind of business. Instead of creating
a big problem for yourself in the future, it’s good to invest time in the code
refactoring process while building an application.
Write note on software design patterns.

Software design patterns are reusable solutions to common problems


encountered during software development. They provide a structured
approach to designing software systems, promoting code reuse,
maintainability, and scalability. Here are some key points about software
design patterns:

1. Problem-Solution Approach: Design patterns address specific problems in


software design and provide well-defined solutions. They encapsulate best
practices evolved over time by experienced developers.

2.Reusable Solutions: Patterns capture solutions to recurring design


problems and encapsulate them in a reusable format. This makes it easier for
developers to apply established solutions rather than reinventing the wheel
for similar issues.

3. Classification: Design patterns are typically classified into three categories:


creational, structural, and behavioral patterns. Creational patterns deal with
object creation mechanisms, structural patterns focus on object composition
and relationships, and behavioral patterns handle communication between
objects.

4. Language Agnostic: Design patterns are language-agnostic concepts.


While they are often implemented using specific programming languages, the
underlying principles can be applied across different programming paradigms
and languages.

5. Common Patterns: Some well-known design patterns include the Singleton


pattern, Factory pattern, Observer pattern, Strategy pattern, and MVC (Model-
View-Controller) pattern. Each pattern addresses a specific aspect of software
design and has its own use cases and benefits.

6. Benefits: Design patterns promote code reusability, modularization, and


maintainability. They enhance the readability and understanding of code by
providing a common vocabulary for discussing design decisions. Additionally,
patterns help in designing flexible and extensible software systems that can
accommodate future changes and enhancements with minimal impact.

7. Trade-offs: While design patterns offer many advantages, they can also
introduce complexity if used indiscriminately. Overusing patterns or applying
them in inappropriate contexts can lead to bloated code and reduced clarity.
It's important to strike a balance between applying design patterns where
necessary and keeping the codebase simple and maintainable.

8. Evolution: Software design patterns continue to evolve over time as new


paradigms, technologies, and best practices emerge in the field of software
engineering. Developers should stay updated with the latest trends and
patterns to leverage them effectively in their projects.
In summary, software design patterns provide a valuable toolkit for developers
to tackle common design problems effectively. By understanding and applying
these patterns judiciously, developers can create software systems that are
robust, scalable, and maintainable.

You might also like