Adding suggestions for cleaner code #149
Replies: 1 comment
-
Clean code is an arbitrary concept. Some people think that the code needs to be concise and have a small amount of lines of code. Others think that you need to break everything up into dozens of smaller single-responsibility functions. The truth is in between and as a result quite murky. This may be a great subject for one of the lessons, but with the opposite idea in mind to the one you propose. I'd cover it in a way that reassures that while there are strict specifications to writing code, the most important part is keeping it as big or as small as the task that it solves demands. Don't try to "optimize" it, don't try to "refactor" it. Just make it do its job exactly as needed. That would probably be the best we can teach beginners without going into software architecture and design. As for the practices, we can just make "show solution" more prominent after the practice is complete. Like, "Hey, compare how you've fared with what we had in mind!" before leaving the practice. |
Beta Was this translation helpful? Give feedback.
-
A helpful tool for people that have completed the tasks in a less than clean way would be to provide an example of the code in a clean and concise format along with reasoning if they didn't complete it in the expected and clean way, to teach good habits early on.
Beta Was this translation helpful? Give feedback.
All reactions