DEV Community

Cover image for Developer diary #24. Refactoring
Kiolk
Kiolk

Posted on

Developer diary #24. Refactoring

I’ve spent several hours refactoring my Flutter code. Why did I do this? The key reason was the complicated existing logic. My code seemed like a spaghetti, with dependencies leaks through specific layers. The main reason why it happened was the use of new libraries, and I was focused on implementation rather than the quality of the code. In the face of new functionality, I felt real fear because I understood it would be complicated.

I decided to refactor my code by focusing on layers of responsibility. First of all, I extracted several interfaces with clear boundaries of their responsibility. I did this in parallel with existing code to avoid large refactoring when nothing working. I did this step by step. At the same time, I kept the part clear that should be variable and will play a role as a different strategies. For the creation several objects, I selected the builder pattern for clarifying creation.

As a result, I got a clear code with lower coupling and clear division by layers of responsibility. I wondered how easy It was to add new functionality. I just added a new strategy and implemented the required functions. It will be so easy to add new feature in the future. Refactoring is an important part of the development, especially, when you focus on adding new functionality. My code isn’t optimal; I think, I should do an additional round of refactoring to make it better. It should be an iterative process.

You can find me in X, GitHub, medium or LinkedIn. Thanks for your time and see you in next post.

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

Billboard image

Imagine monitoring that's actually built for developers

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay