Clean Code


Reading this article from freecodecamp.org, I really enjoyed this quote at the start of the article “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” – Martin Fowler

This is the type of quote I like to take to heart, as I think readable code is very important not only for others but for your future self. Besides this quote, the article had a few great suggestions that I will start incorporating into my coding practice. I especially liked this advice about writing functions “Functions should be small, really small. They should rarely be 20 lines long.” As this is one that doesn’t seem as obvious to me as other suggestions like choosing good names and using constants instead of hard coded numbers. This is a suggestion that i definitely haven’t always implemented into my code, and it is great advice to limit your functions like this. It basically says that a function should only perform one task, and if it is much longer than 20 lines chances it performs more than one. I like this suggestion because I think it will help simplify my code.

When looking at this article https://www.techtarget.com/searchsoftwarequality/tip/Understanding-code-smells-and-how-refactoring-can-help. It made some great suggestions on things to avoid and how to alter them. I particularly liked this advice about “pushing down” your code “Push down: Method code that lives within a superclass but is only used by a few of the subclasses is pushed down to those respective subclasses.” I like this because I feel like I have an issue with this problem, where I have a tendency to do the opposite. I feel that this will help de-clutter my code and make it more immediately understandable.

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *