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.

Sentry mobile image

Improving mobile performance, from slow screens to app start time

Based on our experience working with thousands of mobile developer teams, we developed a mobile monitoring maturity curve.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay