Class Design Tips

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jumbojs
    New Member
    • May 2009
    • 20

    Class Design Tips

    When I design a class, I'm thinking that the rules below apply. Am I correct in thinking this way?

    A variable should be local to the method unless it needs to exist in more than one method and live longer than the life of one method. Otherwise it should be a global variable or field.

    If a group of variables and methods work together in a class that has other methods that work with a different subset of fields, look to break the subsets into classes.

    It's probably not good to have more than five method parametes. See if you can make the parameters into another class?

    It's probably a design smell to have a lot of fields to initialize in the constructor. What is wrong with this exactly? How many is too many though? Should you take the parameters and make them a separate class?

    What are some other tips?
  • Topclassified
    New Member
    • Jun 2012
    • 1

    #2
    Thanks for the ninformation. Its help me a lot in my work.

    Comment

    Working...