0% found this document useful (0 votes)
45 views22 pages

Code Restructuring

Uploaded by

ieshaaved
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)
45 views22 pages

Code Restructuring

Uploaded by

ieshaaved
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/ 22

Code Re-Structuring

(Code-Refactoring)

1
key points:
• Code restructuring,Importance of Code Restructuring in
Software Engineering,
• 3 Common Scenarios that Require Code
Restructuring(Software Growth and Complexity,Adopting
New Technologies and Frameworks,Software
Modernization Efforts),
• Techniques for Code Restructuring

2
Code Re-Structuring:
• Code restructuring is a critical process in software engineering
that includes modifying existing code to enhance its structure,
organization, and efficiency while ensuring the code retains its
intended functionality.
• Why we do?
• The restructuring process is often performed to address various
issues such as code complexity, maintenance difficulties, poor
readability, performance issues, and scalability limitations. The
process makes small, targeted changes to the codebase,
ensuring that each modification maintains the same functionality.

3
Importance of Code Restructuring in
Software Engineering
• improves its readability by applying consistent formatting,
removing redundant or necessary code, and organizing it
in a logical and cohesive manner.
• It simplifies code complexity by employing design
patterns, refactoring techniques, and appropriate
abstractions.
• the code to be updated, new features and functionality
can be added without causing widespread impact or
introducing unintended consequences.
4
Understanding of code restructuring:
• Code restructuring allows developers to reevaluate the
system’s architecture, identify areas of improvement, and
apply design patterns and principles to enhance the
overall structure. This fosters collaboration, reduces
conflicts during code integration, and improves team
productivity.

5
3 Common Scenarios that Require Code
Restructuring:
1. Software Growth and Complexity
As software systems evolve and are updated with updated features,
they grow in size and complexity. This can lead to changes and
additions to the codebase that become difficult to monitor and
comprehend.
2. Adopting New Technologies and Frameworks
When software teams adopt updated technologies, programming
languages, or frameworks, the existing codebase may not align with
the updated standards and best practices of the adopted technology
6
3. Software Modernization Efforts
• In the process of modernizing software, legacy systems
are upgraded to modern architectures. Legacy systems
may have outdated code, use obsolete technologies, and
lack modern features. Code restructuring plays a critical
role in modernization efforts by transforming the legacy
code into a modern efficient, and maintainable form.

7
4 Techniques for Code Restructuring
1. Refactoring:
• Extracting methods: Breaking down long and complex
methods into smaller, reusable units to enhance code
readability and modularity.
• Variable renaming: Choosing meaningful and
descriptive names for variables, functions, and classes to
improve code clarity.
• Simplifying complex expressions: Breaking down
complex expressions into simpler ones to improve
readability and maintainability.
8
2.Decomposition:
• Decomposition involves breaking down complex
codebases into smaller components, such as modules,
packages, classes, and interfaces. The technique
enhances code organization, maintainability, and
reusability.
• By separating concerns into distinct components,
developers can work on individual parts of the codebase
independently, reducing code dependencies and
improving collaboration among team members.
9
3. Consolidations:
• Consolidations aim to reduce code duplication and
eliminate code smells. Code duplication often leads to
maintenance issues and increases bug introduction
chances. Techniques for consolidation include extracting
common code blocks into reusable functions or libraries,
streamlining conditional statements, and removing
maintainability, and overall software quality.

10
4. Optimization
• Optimization techniques emphasize improving codebase
performance and efficiency. The process involves
analyzing and optimizing algorithms, leveraging
appropriate data structures, and implementing caching
mechanisms where applicable.

11
Migration to Object Oriented platforms
• Moving from procedural programming to object oriented
programing.
• Procedural programming.
• Object oriented Programming.

12
Procedural programming:
• Procedural programming follows a top-down approach.
• Procedural Programming divides the program into small
programs and refers to them as functions.
• Procedural programming is less secure as compare to
OOPs.
• C, BASIC, COBOL, Pascal, etc. are the examples POP
languages.

13
Object Oriented Programming
• Object-oriented programming follows a bottom-up
approach. There is no access specifier in procedural
programming. Object-oriented programming has access
specifiers like private, public, protected, etc.
• Object Oriented Programming divides the program into
small parts and refers to them as objects.
• C++, C#, Java, Python, etc. are the examples of OOP
languages.

14
Why we migrated from procedural
language to OOP:
In procedural programming we face
• Lack of Modularity.
• Limited Code Reusability
• Difficulty in Managing State
• Poor Scalability
• Limited Support for Abstraction
• Difficulty in Code Maintenance
• Reduced Flexibility
15
OOP
Modularity and Reusability:
• Advantage: OOP promotes modularity, allowing
developers to break down a system into smaller, self-
contained modules or classes. These modules can be
reused in different parts of the application or in other
projects.

16
17
Encapsulation:

• Advantage: Encapsulation hides the internal details of an


object and exposes only what is necessary. This reduces
complexity and makes it easier to understand and
maintain the code.
• Benefit: Improved code organization and maintenance.

18
Abstraction:
• Advantage: Abstraction allows developers to focus on
essential features of an object while ignoring unnecessary
details. This simplifies the development process and
enhances code readability.
• Benefit: Clearer, more concise code that aligns with real-
world entities.

19
Inheritance:
• Advantage: Inheritance enables the creation of new
classes by inheriting attributes and behaviors from
existing classes. This promotes code reuse and helps in
building a hierarchy of classes.
• Benefit: Hierarchical organization of code for improved
scalability and extensibility.

20
Polymorphism:
• Advantage: Polymorphism allows objects to be treated as
instances of their parent class, providing a level of
flexibility in designing and implementing solutions.
• Benefit: Enhanced adaptability and the ability to work with
different types of objects through a common interface.

21
Community Support and
Standardization:
• Advantage: Many widely used programming languages,
frameworks, and libraries are built on OOP principles.
• Benefit: Access to a large ecosystem of resources,
community support, and standardized practices.

22

You might also like