Discovering design patterns with my todo list project

There are times when giving up seems to be your best choice but you know you won't. The project you're working is going nowhere and your head doesn't have any more energy to come up with an idea that can make you call it a day. You refuse to start piling up failures with this project. "No" you tell yourself, "there must be a way through" and somehow, somewhere deep inside your brain the aha moment is born.

My personal deadline to finish my todo list project was close and my code was a cohesive network of bugs that reflected my poor project design decisions. I was working with vanilla Javascript at that moment, no libraries, no tutorials, just me and my bugs. My main struggle was not being able to build a system of sessions, lists and tasks with ids that avoids duplication and misplacement. Code wasn't the problem, language proficiency level for this project wasn't a problem, but not getting how sessions, lists and tasks could work together.

I heard about design patterns from a former workmate in the videogame industry. They sounded cryptic, sophisticated and useful but I didn't have a chance to actually meet them until my todo list project begged me to check them out. This (website)[https://refactoring.guru/] had all I needed plus a lot of extra information I read through afterwards. So, I coded a powerful combo of composite and factory design patterns that quickly turn my chaotic develpment process into javascript harmony.

The end of the story includes inheritance and the uncommonly used javascript classes. Why javascript classes instead of factory functions? Well, at that time C++ still had great influence on my coding style. True, I could've taken time to learn them but in the end I was more than a novice with C++ so I wanted to keep playing with more familiar syntax 'till I felt more fluent with Javascript.

Here's my story happy ending.


329 Words

2024-10-08