Removing Structural Duplication and Refactoring Hidden Loops

Talk
Thu 10:30 - 11:05
You don't need a laptop
Atlas 2
Autotesting & Design

Summary

 

Removing Structural Duplication

 

Structural duplication is a type of code similarity that is difficult to identify. A common example is the similarity in exception handling:

try{

     doSomething()

} catch (Exception1 exc1){

     // treat exception1

} catch (Exception2 exc2){

    // treat exception2

}

try{

    doSomethingElse()

} catch(Exception1 exc1){

    // treat exception1

} catch(Exception3 exc3){

    // treat exception3

}

The structural duplication is obvious – the code has the same structure but calls different things. Refactoring it can prove challenging.

In this session, I will show you how to remove structural duplication from your code and some of the benefits that can result from it.

 

Refactoring Hidden Loops

This session introduces you to the hidden loops smell and shows an example of refactoring it away.

The hidden loops smell manifests as an operation that is duplicated in various forms in code. The typical example I encounter is a series of if statements:

if(…) doSomething()

if(…) doSomethingElse()

You will learn how to identify hidden loops and how to refactor them to a much shorter version that generalizes the solution and allows flexibility.

 

Who is it for?

AlbertArchitect
 
CarolCTO
 
ChrisCraftsman
Programmer
CristinaTechnical
Co-Founder
DianaDevOps
 
MeganManager
 
TamaraTeam
Leader
TudorTechnical
Consultant

Leave a Reply

Your email address will not be published.

*