Writing clean functions
Functions form the first line of organization in your code. It is thus pretty damned important they are well written if one wants to achieve a clean and maintainable codebase.
While at a first glance writing functions is easy, many factors that should be considered come into play. Everyone can write functions, few people actually do it well.
How big should a function be? A screenfull, 20 lines? If a function should only do one thing, how can one count the number of things a function does?
During this presentation you will learn why well designed functions are so important to Object Orientated Design, maintainability of your code and good programming in general. You'll learn how to distinguish between good and bad functions, and how to refactor the later into the former.
This presentation is aimed at developers. It is suitable both for people new to the field and those with many years of experience.
Examples are mainly in PHP and Java, though the presentation also applies to other OOP languages. All examples are trivial, so knowledge of these languages is not required, while of course a plus.
The topics covered include:
- Function size
- Function complexity
- The importance of small obvious functions
- Finding all classes in your design
- Function naming
- Function arguments
- Side effects
- Levels of abstraction