Rajanikant Hawaldar
When you design class what are the things you keep in mind? What are your checklist?

When you design class what are the things you keep in mind? What are your checklist?

  • Manish Pandey
    Mar, 2022 6

    I have the below rules of thumb when designing a class
    1 Class adheres to the first principle of Solid - Single Responsiblity. Make sure you answer to the question: What will this class do. If your answer is having even one “and” to what the class is doing - you need to reconsider if it is a good idea providing additional responsiblity.
    2 Keep the complexity of the code in check-Methods in the class should not have higher cyclomatic complexity. Do not have a lot of branches, nested ifs,etc. Pls keep in mind that the nested logic is what truely increases complexity and makes the code Rigid and Fragile in the long run.
    3 Checking cyclic dependencies while designing application - Please make sure that all your project dependencies are flowing in one direction.
    4 Exploit polymorphism in your application using Interfaces - However, make sure of not injecting the interfaces mid way through the project. These should be thoughtfully designed and implemented. Remember the rest of SOLID principles about the uses of Polymorphism.

    • 1
  • Sagar Lad
    Aug, 2021 28

    Hi Rajni,

    Below can be possible checklist to design class :

    • Before writing any code module think about the best suitable design pattern.
    • Follow SOLID principle for writing loosely coupled classes.
    • Use Interfaces often.
    • Proper usage of identifies, try to use private as much as possible
    • Make your code less dependent with other module.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS