Originally Posted by
shaggarw
Hi folks,
I wanted to get your opinion around following situation:-
I have an object with a name nmsArray<CrossConnect>[] ,array of CrossConnect type object. CrossConnect object has some 15 attributes and corresponding getters and setters.
This array need to be passed to a private method createRoute(someObj<CrossConnect>[]), which as of now uses only 2 attributes out of 15 of the CrossConnect object for some computation.
Now I have to create an object of CrossConnect type, add that to nmsArray[] and pass it into private method createRoute(someObj<CrossConnect>[]){}.
Question is should we populate only those 2 objects in CrossConnect Object which needs to be used in createRoute(..) method, or does it make sense to populate(instatiate them) all the attributes of CrossConnect object with an idea that other attributes apart from those 2 may be used in future. Assuming there is no memory constraint with the application and no time critcality, would it be a good idea to go about instantiating all the attributes of an object irrespective of their usage pattern.
Regards!!
Well, the simple rule is that: don't create things which you won't use. Keep it simple! If there are only two attributes are being used across the program, so there is no need to define other attributes that you won't use. If you intend to use the other attributes in future, so do declare them, it won't hurt anyone!
Spring 3