DevaWinner / to-do-project

This is a simple To-Do List application built using JavaScript and HTML and CSS. It allows users to create, manage, and track their tasks. The application features include adding tasks, marking tasks as completed, editing task descriptions, deleting tasks, and clearing all completed tasks.
https://devawinner.github.io/to-do-project/
MIT License
2 stars 0 forks source link

Clean code practice #8

Open DevaWinner opened 1 year ago

DevaWinner commented 1 year ago

I will be using this issue to self asses my code for best practices using the DRY, KISS and YAGNI principles.

DevaWinner commented 1 year ago

In this code snippet, I found that the logic for adding a task is duplicated. The same block of code is repeated for both the click event on addTaskButton and the keydown event on taskInput. Whereby, it doesn't pass the DRY (Don't Repeat Yourself) test. https://github.com/DevaWinner/to-do-project/blob/c16c5c284277ca4c8cd7e5e978cf03a9b5f2ff7a/src/index.js#L74-L90

To improve this code, I can extract the duplicated logic into a separate function and reuse it in both event listeners.

DevaWinner commented 1 year ago

Overall, the rest of the code adheres to KISS and YAGNI principle by providing the required functionality without introducing unnecessary complexity or speculative features.