Re:Anti-if: The Missing Patterns
by specialist on Friday June 10, 2016 @12:07PM
(#11877380)
"turned them into a single array lookup."
Midway between nested conditionals and lookups is using flags and a tablesque series of conditionals. Redundant but easily understood (and therefore testable).
I first learned about this technique from Code Complete (linked in the TFA). IIRC, McConnell used the term "truth tables".
"...since the code is far less branchy."
Code construction GoF style Design Patterns just introduce another level of indirection. That's it. (Insert cliche here.)
"Design Patterns" are overused, especially in the Java world (eg J2EE/Spring, Service Providers, Strategies, DI, IoC).
The "design" part is figuring out the least complicated balance between conditional branches and call stack depth, between composition and inheritance.
Midway between nested conditionals and lookups is using flags and a tablesque series of conditionals. Redundant but easily understood (and therefore testable).
I first learned about this technique from Code Complete (linked in the TFA). IIRC, McConnell used the term "truth tables".
"...since the code is far less branchy."
Code construction GoF style Design Patterns just introduce another level of indirection. That's it. (Insert cliche here.)
"Design Patterns" are overused, especially in the Java world (eg J2EE/Spring, Service Providers, Strategies, DI, IoC).
The "design" part is figuring out the least complicated balance between conditional branches and call stack depth, between composition and inheritance.
Rant over.