Reputation: 91
In my .Net application (MVVM application) i have let's say 10 drop down lists. So i created 10 different classes(Models) containing just Name , Value pair. The reason of creating 10 different classes is just because these drop down lists are functionally independent.
What are the pros and cons (Including memory impact) of 10 different classes instead of just 1 class (Which contains Name Value Pair and Bound to View through ViewModel)
Upvotes: 1
Views: 53
Reputation: 86729
Having an extra 10 (or even 100) small classes in your application (as opposed to 1 class with a shared role) is going to have essentially no impact on performance.
That said, more classes means more code to maintain which means more work for you. If these classes are actually different then having a different class for each control is quite possibly the best decision, however if all these classes are essentially identical then personally I'd rather save myself some typing and use something like KeyValuePair<TKey, TValue> instead.
Upvotes: 1
Reputation: 498972
Having a number of different classes over a single one is hardly likely to make a difference to your application. Instantiation of simple types is very fast (billions of objects a second).
You might notice issues if you go into the many many millions of objects and then only if you are doing work when instantiating them.
Upvotes: 1