`Huh?` to `Aha!`: A Refactoring Story


Gopal S Akshintala
Salesforce, Senior Software Engineer

Gopal S Akshintala is currently a Senior Software Engineer at Salesforce, working on Scaling Backend Systems for Revenue Cloud. (https://overfullstack.github.io/about-me)

He is a passionate developer and loves being an Influencer & Mentor in the dev community through his Blog-posts, Tech-Talks (https://overfullstack.ga/my-talks), and Social-media.

He started as an Android Developer and switched to the server-side as a Full-Stack Developer (Backend - Kotlin, Java Frontend - React Js). Wearing multiple hats, aided him to perceive Patterns, Solutions, and Trade-offs.

He is a practitioner of Domain-Driven Design (DDD) and Clean Architecture. A massive fan of Test-Driven Development (TDD). He believes Expressive Code is fun and profitable, which enthused him towards Functional Programming. He’s a language geek, currently fluent in Kotlin, Java, and dabbling with Scala and Javascript.

In addition to his Software Engineering experience, he gains more experiences per year by open-source collaborations & contributions, active participation in the Dev discussions, and Speaking at User Groups and Conferences. He loves being on Stage, as a Singer (http://bit.ly/agssc) and a Tech-Speaker (https://overfullstack.ga/my-talks) and writes about Nature & Life (http://bit.ly/agslotw).


"Entropy is the price of a Structure". But sometimes, the price turns too high to pay. Is your codebase turning untestable, unreadable, and unmaintainable? Does your costs to add new features aren't meeting the ROIs. It's time to ask your manager to fund Refactoring!

In this demo-driven talk, using a real-world service, we shall identity some common reasons for a codebase to rot and how to weed them out using principles from Clean Architecture and Functional Programming, along with achieving 95% test coverage and ~50% reduction in Cognitive complexity (https://www.sonarsource.com/docs/CognitiveComplexity.pdf).

Audience & Take-aways

This applies to software developers at all levels. I use Java to demonstrate the code snippets, but this talk is about Software Design and Testing and is agnostic of programming language. The major take-aways for the audience are:

- Pragmatically apply the principles of Clean-Architecture and Functional programming in real-world refactoring. 

- How to completely eliminate Exceptions from your code using ADTs (Algebraic Data Types). 

- How to replace Shared Global mutable state on your Shared Code with Data Transformations. 

- How separating out What-to-do from How-to-do can bring in a lot of flexibility to your code-base.

- How following all of the above organically boost your Testability without falling into any anti-patterns of testing. 

Let's talk about Complexity and how to objectively measure the reduction we brought with our refactoring.