Functions should be doing one thing and be on one abstraction level.
Functions should be doing one thing and be on one abstraction level. That is my main takeaway from Chapter 3 of Clean Code.
Functions or methods are the first line of structure in any program. They shape how we think about the code and how others read it.
This chapter is packed with reminders about how function design influences clarity, maintainability, and communication.
Here are the points I took from it:
✅ Keep functions small: If it barely fits on a screen, it is too big. Short functions are easier to read, understand, and change ✅ Do one thing and do it well: If you can extract a part of the function into a separate method with a meaningful name, it was doing more than one thing ✅ Stay at one level of abstraction: Do not mix low-level details like string manipulation with high-level logic ✅ Read like a top-down story: Every function should call others that are just one level of detail below ✅ Use descriptive names: A long descriptive name is better than a short cryptic one. Good naming removes the need for comments. 🤨 ✅ Keep arguments simple: Zero or one argument is ideal. Avoid boolean flags and output parameters whenever possible ✅ Avoid hidden side effects: A function should do exactly what its name says. If it changes the system state, make that obvious ✅ Separate commands and queries: Either do something or return something. –> I do not agree here. ✅ Use exceptions, not error codes ✅ Eliminate duplication ✅ First write, then refine: Clean functions do not appear on the first try. They emerge through refactoring, once the tests are green. This is a very helpful insight, and I agree 💯
#CleanCode #SoftwareDevelopment #CodeQuality #Refactoring #ProgrammingTips #RethinkCleanCode

Kommentieren und diskutieren können Sie direkt unter dem Beitrag auf LinkedIn.