Functions, lambdas, closures. So high order, nondeclarative, and hot.
- Code Reuse
- Implementation Hiding
- Wrap functions/closures
- Reify algorithms in method object / Strategy
- Closures and anonymous functions are very useful to model code blocks, promises etc. So It’d difficult to tear them apart.
Humans read code. Software works ok with anonymous functions but maintainability is compromised when multiple closures are invoked.
Object-oriented programming increases the value of these metrics by managing this complexity. The most effective tool available for dealing with complexity is abstraction. Many types of abstraction can be used, but encapsulation is the main form of abstraction by which complexity is managed in object-oriented programming.
This article is part of the CodeSmell Series.