More

    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

    Recent Articles

    OAUTH – FREQUENTLY ASKED QUESTIONS FOR INTERVIEWS AND SELF EVALUATION

    Why is refresh token needed when you have access token? Access tokens are usually short-lived and refresh tokens are...

    SUMO LOGIC VIDEOS AND TUTORIALS

    Sumo Logic Basics - Part 1 of 2 (link is external) (Sep 29, 2016)Sumo Logic Basics - Part 2 of 2...

    GIT – USEFUL COMMANDS

    Discard all local changes, but save them for possible re-use later:  git stash Discarding local changes...

    DISTRIBUTED COMPUTING – RECORDED LECTURES (BITS)

    Module 1 - INTRODUCTION Recorded Lecture - 1.1 Introduction Part I – Definition

    BOOK REVIEW GUIDELINES FOR COOKBOOKS

    Whenever you add reviews for the book, please follow below rules. Write issues in an excel.Create an excel...

    Related Stories

    Leave A Reply

    Please enter your comment!
    Please enter your name here

    Stay on op - Ge the daily news in your inbox