Things to Avoid in Your Object Oriented Design

We have already seen SOLID Principles and also few additional design principles and best practices. Let us also see few things that should be avoided in your design. Again, most of these may be indirectly based in the SOLID Principles.

Things to avoid in your design includes, but are not limited to:

  1. Run-Time Type Identification (RTTI)

    • Design that require you to check for the actual type of the reference object should be avoided (e.g. if(type(something) = something, do something). 

  2. Cyclomatic complexity (CC)

    • It directly measures the number of linearly independent paths through a program's source code (e.g. the number of if-else-if statements in a function).

    • Note that for every path you need to add at least one additional test case to your unit test cases.

    • As a good practice, we should avoid this as much as possible or limit this to less than 10.

  3. Swiss knife syndrome

    • ‘Swiss Army Knife’ is often used to describe a collection of useful items or tools that are able to perform well in multiple scenarios.

    • The more complex a piece of code or software gets, the less value it provides, and it will be more difficult to maintain.

    • An example is the usual util class. This is the opposite of SRP.

  4. Lookup

    • Only use as a last resort as in the case of caching.  

  5. Bidirectional coupling and cyclic coupling

    • ​Create maintenance nightmares

  6. God class

    • A class that does everything should be avoided.

    • God class will need a God Man, who is the only person who can understand and modify that class.

  7. Downcast

    • Abandon downcast

References: 

Head First Design Patterns By Eric Freeman, Elisabeth Freeman, Bert Bates, Kathy Sierra

Contact

We learn together, do innovations and then document them.

Offline Contact
We connect physically only in Bengaluru currently, but most of our activities happen online. Please follow us here or in social media for more details.
WhatsApp (Primary): (+91) 7411174113
WhatsApp (Secondary): (+91) 7411174114

Business newsletter

Complete the form below, and we'll send you an e-mail every now and again with all the latest news.

About Cloudericks

Team Cloudericks is a community to learn about and master cloud computing. Current learning focus is on AWS cloud.

We believe that knowledge is useless unless you share it; the more you share, the more you learn. Visit Cloudericks.

Recent comments

Photo Stream