The Art of Refactoring

This week I am going to over a post from the CodeGuru. The post starts by talking about the importance of refactoring, what it is and why we refactor. They define refactoring as the process of restructuring or improving the internal structure of code while keeping the functionality of the code and not changing its external behavior. The article then goes on to talk about when the pros and cons of refactoring and why sometimes it is not best to refactor.

Refactoring code can help prevent bugs but if done improperly, refactoring code can also create bugs in your code so that is why it is important to be careful when refactoring code. In the article, it talks about how it is a good habit to analyze your code before refactoring code. If after analyzing your code, you find that you have to refactor most of your code, they caution you against refactoring the program because you may end up creating more work for yourself. Instead, they recommend that it may be better to start over from scratch. Another practice they implore coders to follow is you should not refactor code if you don’t have the tests or plan to create the tests for that code. This is because, without the tests, you may not have sufficient information about whether or not your code has changed the behavior of the program. Another good practice they recommend is you should wait until you deliver the product and use the time in between tasks to refactor code. Software development can be a very time-sensitive industry so some good practices that we should have as programmers are we should be mindful of the time we have before deadlines and be able to analyze whether a task can reasonably be done in the allotted amount of time. We should also establish clear and achievable goals and refactor code in between tasks and before adding new features to the program so that we can avoid technical debt.

I chose this post to review this week because I think it is a very important topic not just in this class but in programming in general. One of the reasons why I chose this topic, in particular, is because in class we often toss the term around in class, we know what it is and how to do it, but we never really talk about how to do it well or what are some good practices that we should follow. Personally, I have been following some of these practices all along such as gauging my time before deadlines and making objectives along the way, but I also have a really bad habit of deviating from those objectives. There were so many times in my undergraduate career where right before an assignment is due, I ended up refactoring the program from start to finish or redoing the entire assignment from scratch. Now that I know good refactoring habits, I can avoid this in the future.

https://www.codeguru.com/csharp/best-practices-for-code-refactoring/

From the blog CS@Worcester – Just a Guy Passing By by Eric Nguyen and used with permission of the author. All other rights reserved by the author.

SOLID

The SOLID principle helps in reducing tight coupling, which means a group of classes are highly dependent on one another which we should avoid in our code. The opposite, which is loosely coupled classes that minimize changes in our code, helps in making code more reusable, maintainable, flexible, and stable.

This principle is an acronym of the five principles which is given here below:

  • Single Responsibility Principle: This principle states that “a class should have only one reason to change” whoch means every class should have a single responsibility or single job or single purpose. Let’s take an example of the developing software, the task is divided into different members doing different things as front end designes to design, the tester does testing and back end developer takes care of back end development part then we can say that everyone has a single job or responsibility.
  • Open/Closed Principle: This principle states that “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification” which means we should be able to extend a class behavior, without modifying it. Let’s for example, suppose developer A needs to release an update for a library or framework and developer B wants some modification or add some feature on that then developer B is allowed to extend the exiting class created by developer A vt developer B is not supposed to modify the class directly.
  • Liskov’s Substitution Principle: The principle was introduced by Barbara Liskov in 1987 and according to this principle “Derived or child classes must be substitutable for their base or parent classes”. This principle ensures that any class that is the child of a parent class should be usable in place of its parent class should be sable in place of its parent without any unexpected behavior.
  • Intterface Segregation Principle: This principle is the first principle that applies to Interfaces instead of classes in SOLID and it is similar to the single responsibility principle. It states that “do not force any client to implement an interface which is irrelevant to them“. Here your main goal is to focus on avoiding fat interface and give preference to many small client-specific interfaces. You should prefer many client interfaces rather than one general interface and each interface should have a specific responsibility.
  • Dependency Inversion Principle: Before we discuss this topic keep in mind that Dependency Inversion and Dependency Injection both are different concepts. Most people get confused about it and consider both are the same. Now two key points are here to keep in mind about this principle.
  • High-level modules/classes should not depend on low-level modules/classes. Both should depend upon abstractions.
  • Abstractions should not depend upon details. Details should depend upon abstractions.

I chose this topic because, after learning a little more about design patterns, front end, back end, I was curious to learn about SOLID principles and, also I wanted to understand more about it and how it reinforces the need for design patterns in Software.

SOLID Principle in Programming: Understand With Real Life Examples – GeeksforGeeks

From the blog CS@Worcester – Gracia's Blog (Computer Science Major) by gkitenge and used with permission of the author. All other rights reserved by the author.

Week-11

 

Hello
blog (mood-status: feeling Good), writing this blog after thanksgiving
dinner and eating well like pretty good with a plate of food alongside
hanging the family. But anyway, on writing about this week-11. To be
truthful here, I writing this because I am falling behind on blogs when
there is nothing to talk about, besides kept being busy with other
courses like HWs and projects, etc. (You get the point. Well, if you are
a student) 

I decided to go on the Syllabus to look at the course topics.

I found the subject of Modeling along with Unified Modeling Language (UML) & C4 Model.

Unified Modeling Language

Large
Companies’ applications that execute core business applications and
keep a company going can more than some code modules. It can structure
in a way that enables:

  • scalability
  • security 
  • robust execution under stressful conditions. 


Their structure is that maintenance programmers can find and fix a bug
that shows up after moving on to other projects. These programs can
design to work perfectly in many areas, and business functionality is
not the only one. A well-designed architecture benefits any program, and
not only the largest ones as singled out. It mentioned large
applications first because the structure deals with complexity, so the
benefits of the network compound as the application size grows large. 


Another use of a structure that enables code reuse was design time.
Ultimately, companies build up models of parts, each unit representing
an implementation stored in code modules. At coding time, the developer
can as promptly import the code module into the application. When
another application needs the same functionality, the designer can
quickly import its module from the library.

The C4 model

The
C4 model made by Simon Brown designates on UML and the 4+1
architectural view model. It breaks down software into smaller units for
modeling. Like the quick methodology, the C4 model requires fast,
efficient sharing and constant updates of software architecture in
software development.

The
C4 model (shown as a map). The Maps can build on a different scale. By
changing scales, like for example; The town map with streets and
buildings. Having the C4 model changes the level of a diagram to
describe software architecture. Using the abstraction-first approach, C4
conducts modeling top-down from system context to lower levels.

  • Person (Element) – users or roles of a software system
  • Software
    system (topmost level in abstractions) – the value of existing systems
    or systems under development and the interaction between those systems
  • Container
    (Element) – the internals of software systems, usually applications or
    solutions for data storage. A different concept to containers in Docker.
    It mainly refers to software that is single deployed.
  • Component (Abstraction element) – The containers of modules or a set of interfaces grouped as a functional unit.
  • Relations – dependencies or data flow between abstraction elements.

From the blog Andrew Lam’s little blog by Andrew Lam and used with permission of the author. All other rights reserved by the author.

Week-11

 

Hello
blog (mood-status: feeling Good), writing this blog after thanksgiving
dinner and eating well like pretty good with a plate of food alongside
hanging the family. But anyway, on writing about this week-11. To be
truthful here, I writing this because I am falling behind on blogs when
there is nothing to talk about, besides kept being busy with other
courses like HWs and projects, etc. (You get the point. Well, if you are
a student) 

I decided to go on the Syllabus to look at the course topics.

I found the subject of Modeling along with Unified Modeling Language (UML) & C4 Model.

Unified Modeling Language

Large
Companies’ applications that execute core business applications and
keep a company going can more than some code modules. It can structure
in a way that enables:

  • scalability
  • security 
  • robust execution under stressful conditions. 


Their structure is that maintenance programmers can find and fix a bug
that shows up after moving on to other projects. These programs can
design to work perfectly in many areas, and business functionality is
not the only one. A well-designed architecture benefits any program, and
not only the largest ones as singled out. It mentioned large
applications first because the structure deals with complexity, so the
benefits of the network compound as the application size grows large. 


Another use of a structure that enables code reuse was design time.
Ultimately, companies build up models of parts, each unit representing
an implementation stored in code modules. At coding time, the developer
can as promptly import the code module into the application. When
another application needs the same functionality, the designer can
quickly import its module from the library.

The C4 model

The
C4 model made by Simon Brown designates on UML and the 4+1
architectural view model. It breaks down software into smaller units for
modeling. Like the quick methodology, the C4 model requires fast,
efficient sharing and constant updates of software architecture in
software development.

The
C4 model (shown as a map). The Maps can build on a different scale. By
changing scales, like for example; The town map with streets and
buildings. Having the C4 model changes the level of a diagram to
describe software architecture. Using the abstraction-first approach, C4
conducts modeling top-down from system context to lower levels.

  • Person (Element) – users or roles of a software system
  • Software
    system (topmost level in abstractions) – the value of existing systems
    or systems under development and the interaction between those systems
  • Container
    (Element) – the internals of software systems, usually applications or
    solutions for data storage. A different concept to containers in Docker.
    It mainly refers to software that is single deployed.
  • Component (Abstraction element) – The containers of modules or a set of interfaces grouped as a functional unit.
  • Relations – dependencies or data flow between abstraction elements.

From the blog Andrew Lam’s little blog by Andrew Lam and used with permission of the author. All other rights reserved by the author.

Week-11

 

Hello
blog (mood-status: feeling Good), writing this blog after thanksgiving
dinner and eating well like pretty good with a plate of food alongside
hanging the family. But anyway, on writing about this week-11. To be
truthful here, I writing this because I am falling behind on blogs when
there is nothing to talk about, besides kept being busy with other
courses like HWs and projects, etc. (You get the point. Well, if you are
a student) 

I decided to go on the Syllabus to look at the course topics.

I found the subject of Modeling along with Unified Modeling Language (UML) & C4 Model.

Unified Modeling Language

Large
Companies’ applications that execute core business applications and
keep a company going can more than some code modules. It can structure
in a way that enables:

  • scalability
  • security 
  • robust execution under stressful conditions. 


Their structure is that maintenance programmers can find and fix a bug
that shows up after moving on to other projects. These programs can
design to work perfectly in many areas, and business functionality is
not the only one. A well-designed architecture benefits any program, and
not only the largest ones as singled out. It mentioned large
applications first because the structure deals with complexity, so the
benefits of the network compound as the application size grows large. 


Another use of a structure that enables code reuse was design time.
Ultimately, companies build up models of parts, each unit representing
an implementation stored in code modules. At coding time, the developer
can as promptly import the code module into the application. When
another application needs the same functionality, the designer can
quickly import its module from the library.

The C4 model

The
C4 model made by Simon Brown designates on UML and the 4+1
architectural view model. It breaks down software into smaller units for
modeling. Like the quick methodology, the C4 model requires fast,
efficient sharing and constant updates of software architecture in
software development.

The
C4 model (shown as a map). The Maps can build on a different scale. By
changing scales, like for example; The town map with streets and
buildings. Having the C4 model changes the level of a diagram to
describe software architecture. Using the abstraction-first approach, C4
conducts modeling top-down from system context to lower levels.

  • Person (Element) – users or roles of a software system
  • Software
    system (topmost level in abstractions) – the value of existing systems
    or systems under development and the interaction between those systems
  • Container
    (Element) – the internals of software systems, usually applications or
    solutions for data storage. A different concept to containers in Docker.
    It mainly refers to software that is single deployed.
  • Component (Abstraction element) – The containers of modules or a set of interfaces grouped as a functional unit.
  • Relations – dependencies or data flow between abstraction elements.

From the blog Andrew Lam’s little blog by Andrew Lam and used with permission of the author. All other rights reserved by the author.

Week-11

 

Hello
blog (mood-status: feeling Good), writing this blog after thanksgiving
dinner and eating well like pretty good with a plate of food alongside
hanging the family. But anyway, on writing about this week-11. To be
truthful here, I writing this because I am falling behind on blogs when
there is nothing to talk about, besides kept being busy with other
courses like HWs and projects, etc. (You get the point. Well, if you are
a student) 

I decided to go on the Syllabus to look at the course topics.

I found the subject of Modeling along with Unified Modeling Language (UML) & C4 Model.

Unified Modeling Language

Large
Companies’ applications that execute core business applications and
keep a company going can more than some code modules. It can structure
in a way that enables:

  • scalability
  • security 
  • robust execution under stressful conditions. 


Their structure is that maintenance programmers can find and fix a bug
that shows up after moving on to other projects. These programs can
design to work perfectly in many areas, and business functionality is
not the only one. A well-designed architecture benefits any program, and
not only the largest ones as singled out. It mentioned large
applications first because the structure deals with complexity, so the
benefits of the network compound as the application size grows large. 


Another use of a structure that enables code reuse was design time.
Ultimately, companies build up models of parts, each unit representing
an implementation stored in code modules. At coding time, the developer
can as promptly import the code module into the application. When
another application needs the same functionality, the designer can
quickly import its module from the library.

The C4 model

The
C4 model made by Simon Brown designates on UML and the 4+1
architectural view model. It breaks down software into smaller units for
modeling. Like the quick methodology, the C4 model requires fast,
efficient sharing and constant updates of software architecture in
software development.

The
C4 model (shown as a map). The Maps can build on a different scale. By
changing scales, like for example; The town map with streets and
buildings. Having the C4 model changes the level of a diagram to
describe software architecture. Using the abstraction-first approach, C4
conducts modeling top-down from system context to lower levels.

  • Person (Element) – users or roles of a software system
  • Software
    system (topmost level in abstractions) – the value of existing systems
    or systems under development and the interaction between those systems
  • Container
    (Element) – the internals of software systems, usually applications or
    solutions for data storage. A different concept to containers in Docker.
    It mainly refers to software that is single deployed.
  • Component (Abstraction element) – The containers of modules or a set of interfaces grouped as a functional unit.
  • Relations – dependencies or data flow between abstraction elements.

From the blog Andrew Lam’s little blog by Andrew Lam and used with permission of the author. All other rights reserved by the author.

Week-11

 

Hello
blog (mood-status: feeling Good), writing this blog after thanksgiving
dinner and eating well like pretty good with a plate of food alongside
hanging the family. But anyway, on writing about this week-11. To be
truthful here, I writing this because I am falling behind on blogs when
there is nothing to talk about, besides kept being busy with other
courses like HWs and projects, etc. (You get the point. Well, if you are
a student) 

I decided to go on the Syllabus to look at the course topics.

I found the subject of Modeling along with Unified Modeling Language (UML) & C4 Model.

Unified Modeling Language

Large
Companies’ applications that execute core business applications and
keep a company going can more than some code modules. It can structure
in a way that enables:

  • scalability
  • security 
  • robust execution under stressful conditions. 


Their structure is that maintenance programmers can find and fix a bug
that shows up after moving on to other projects. These programs can
design to work perfectly in many areas, and business functionality is
not the only one. A well-designed architecture benefits any program, and
not only the largest ones as singled out. It mentioned large
applications first because the structure deals with complexity, so the
benefits of the network compound as the application size grows large. 


Another use of a structure that enables code reuse was design time.
Ultimately, companies build up models of parts, each unit representing
an implementation stored in code modules. At coding time, the developer
can as promptly import the code module into the application. When
another application needs the same functionality, the designer can
quickly import its module from the library.

The C4 model

The
C4 model made by Simon Brown designates on UML and the 4+1
architectural view model. It breaks down software into smaller units for
modeling. Like the quick methodology, the C4 model requires fast,
efficient sharing and constant updates of software architecture in
software development.

The
C4 model (shown as a map). The Maps can build on a different scale. By
changing scales, like for example; The town map with streets and
buildings. Having the C4 model changes the level of a diagram to
describe software architecture. Using the abstraction-first approach, C4
conducts modeling top-down from system context to lower levels.

  • Person (Element) – users or roles of a software system
  • Software
    system (topmost level in abstractions) – the value of existing systems
    or systems under development and the interaction between those systems
  • Container
    (Element) – the internals of software systems, usually applications or
    solutions for data storage. A different concept to containers in Docker.
    It mainly refers to software that is single deployed.
  • Component (Abstraction element) – The containers of modules or a set of interfaces grouped as a functional unit.
  • Relations – dependencies or data flow between abstraction elements.

From the blog Andrew Lam’s little blog by Andrew Lam and used with permission of the author. All other rights reserved by the author.

Week-11

 

Hello
blog (mood-status: feeling Good), writing this blog after thanksgiving
dinner and eating well like pretty good with a plate of food alongside
hanging the family. But anyway, on writing about this week-11. To be
truthful here, I writing this because I am falling behind on blogs when
there is nothing to talk about, besides kept being busy with other
courses like HWs and projects, etc. (You get the point. Well, if you are
a student) 

I decided to go on the Syllabus to look at the course topics.

I found the subject of Modeling along with Unified Modeling Language (UML) & C4 Model.

Unified Modeling Language

Large
Companies’ applications that execute core business applications and
keep a company going can more than some code modules. It can structure
in a way that enables:

  • scalability
  • security 
  • robust execution under stressful conditions. 


Their structure is that maintenance programmers can find and fix a bug
that shows up after moving on to other projects. These programs can
design to work perfectly in many areas, and business functionality is
not the only one. A well-designed architecture benefits any program, and
not only the largest ones as singled out. It mentioned large
applications first because the structure deals with complexity, so the
benefits of the network compound as the application size grows large. 


Another use of a structure that enables code reuse was design time.
Ultimately, companies build up models of parts, each unit representing
an implementation stored in code modules. At coding time, the developer
can as promptly import the code module into the application. When
another application needs the same functionality, the designer can
quickly import its module from the library.

The C4 model

The
C4 model made by Simon Brown designates on UML and the 4+1
architectural view model. It breaks down software into smaller units for
modeling. Like the quick methodology, the C4 model requires fast,
efficient sharing and constant updates of software architecture in
software development.

The
C4 model (shown as a map). The Maps can build on a different scale. By
changing scales, like for example; The town map with streets and
buildings. Having the C4 model changes the level of a diagram to
describe software architecture. Using the abstraction-first approach, C4
conducts modeling top-down from system context to lower levels.

  • Person (Element) – users or roles of a software system
  • Software
    system (topmost level in abstractions) – the value of existing systems
    or systems under development and the interaction between those systems
  • Container
    (Element) – the internals of software systems, usually applications or
    solutions for data storage. A different concept to containers in Docker.
    It mainly refers to software that is single deployed.
  • Component (Abstraction element) – The containers of modules or a set of interfaces grouped as a functional unit.
  • Relations – dependencies or data flow between abstraction elements.

From the blog Andrew Lam’s little blog by Andrew Lam and used with permission of the author. All other rights reserved by the author.

Week-11

 

Hello
blog (mood-status: feeling Good), writing this blog after thanksgiving
dinner and eating well like pretty good with a plate of food alongside
hanging the family. But anyway, on writing about this week-11. To be
truthful here, I writing this because I am falling behind on blogs when
there is nothing to talk about, besides kept being busy with other
courses like HWs and projects, etc. (You get the point. Well, if you are
a student) 

I decided to go on the Syllabus to look at the course topics.

I found the subject of Modeling along with Unified Modeling Language (UML) & C4 Model.

Unified Modeling Language

Large
Companies’ applications that execute core business applications and
keep a company going can more than some code modules. It can structure
in a way that enables:

  • scalability
  • security 
  • robust execution under stressful conditions. 


Their structure is that maintenance programmers can find and fix a bug
that shows up after moving on to other projects. These programs can
design to work perfectly in many areas, and business functionality is
not the only one. A well-designed architecture benefits any program, and
not only the largest ones as singled out. It mentioned large
applications first because the structure deals with complexity, so the
benefits of the network compound as the application size grows large. 


Another use of a structure that enables code reuse was design time.
Ultimately, companies build up models of parts, each unit representing
an implementation stored in code modules. At coding time, the developer
can as promptly import the code module into the application. When
another application needs the same functionality, the designer can
quickly import its module from the library.

The C4 model

The
C4 model made by Simon Brown designates on UML and the 4+1
architectural view model. It breaks down software into smaller units for
modeling. Like the quick methodology, the C4 model requires fast,
efficient sharing and constant updates of software architecture in
software development.

The
C4 model (shown as a map). The Maps can build on a different scale. By
changing scales, like for example; The town map with streets and
buildings. Having the C4 model changes the level of a diagram to
describe software architecture. Using the abstraction-first approach, C4
conducts modeling top-down from system context to lower levels.

  • Person (Element) – users or roles of a software system
  • Software
    system (topmost level in abstractions) – the value of existing systems
    or systems under development and the interaction between those systems
  • Container
    (Element) – the internals of software systems, usually applications or
    solutions for data storage. A different concept to containers in Docker.
    It mainly refers to software that is single deployed.
  • Component (Abstraction element) – The containers of modules or a set of interfaces grouped as a functional unit.
  • Relations – dependencies or data flow between abstraction elements.

From the blog Andrew Lam’s little blog by Andrew Lam and used with permission of the author. All other rights reserved by the author.

Week-11

 

Hello
blog (mood-status: feeling Good), writing this blog after thanksgiving
dinner and eating well like pretty good with a plate of food alongside
hanging the family. But anyway, on writing about this week-11. To be
truthful here, I writing this because I am falling behind on blogs when
there is nothing to talk about, besides kept being busy with other
courses like HWs and projects, etc. (You get the point. Well, if you are
a student) 

I decided to go on the Syllabus to look at the course topics.

I found the subject of Modeling along with Unified Modeling Language (UML) & C4 Model.

Unified Modeling Language

Large
Companies’ applications that execute core business applications and
keep a company going can more than some code modules. It can structure
in a way that enables:

  • scalability
  • security 
  • robust execution under stressful conditions. 


Their structure is that maintenance programmers can find and fix a bug
that shows up after moving on to other projects. These programs can
design to work perfectly in many areas, and business functionality is
not the only one. A well-designed architecture benefits any program, and
not only the largest ones as singled out. It mentioned large
applications first because the structure deals with complexity, so the
benefits of the network compound as the application size grows large. 


Another use of a structure that enables code reuse was design time.
Ultimately, companies build up models of parts, each unit representing
an implementation stored in code modules. At coding time, the developer
can as promptly import the code module into the application. When
another application needs the same functionality, the designer can
quickly import its module from the library.

The C4 model

The
C4 model made by Simon Brown designates on UML and the 4+1
architectural view model. It breaks down software into smaller units for
modeling. Like the quick methodology, the C4 model requires fast,
efficient sharing and constant updates of software architecture in
software development.

The
C4 model (shown as a map). The Maps can build on a different scale. By
changing scales, like for example; The town map with streets and
buildings. Having the C4 model changes the level of a diagram to
describe software architecture. Using the abstraction-first approach, C4
conducts modeling top-down from system context to lower levels.

  • Person (Element) – users or roles of a software system
  • Software
    system (topmost level in abstractions) – the value of existing systems
    or systems under development and the interaction between those systems
  • Container
    (Element) – the internals of software systems, usually applications or
    solutions for data storage. A different concept to containers in Docker.
    It mainly refers to software that is single deployed.
  • Component (Abstraction element) – The containers of modules or a set of interfaces grouped as a functional unit.
  • Relations – dependencies or data flow between abstraction elements.

From the blog Andrew Lam’s little blog by Andrew Lam and used with permission of the author. All other rights reserved by the author.