These constructs can often be replaced by polymorphism. This will give you shorter and less brittle code.
More Related Contents:
- Singletons: good design or a crutch? [closed]
- Anemic Domain Model: Pros/Cons
- Fluent Interfaces – Method Chaining
- What is dependency injection?
- What is a magic number, and why is it bad? [closed]
- What is the “Execute Around” idiom?
- Why should hash functions use a prime number modulus?
- What is the difference between currying and partial application?
- What is Type-safe?
- Solving “Who owns the Zebra” programmatically?
- Try to describe polymorphism as easy as you can [closed]
- Pass by reference or pass by value? [closed]
- Making a system call that returns the stdout output as a string
- Acronyms in CamelCase [closed]
- When is it okay to check if a file exists?
- What is eager loading?
- Private vs. Public members in practice (how important is encapsulation?) [closed]
- Why is writing a closed TCP socket worse than reading one?
- How to deal with constructor over-injection in .NET
- How to calculate distance from a point to a line segment, on a sphere?
- Followup: Finding an accurate “distance” between colors
- What’s the term for the part of the URL after the question mark?
- Hash Code and Checksum – what’s the difference?
- Is bit shifting O(1) or O(n)?
- Why is the knapsack problem pseudo-polynomial?
- Code Golf: Conway’s Game of Life
- Monostate vs. Singleton
- Why would a language NOT use Short-circuit evaluation?
- Finding closest match in collection of numbers [closed]
- Is there a known implementation of an indexed linked list?