C#: simple vs complex objects and memory usage -


When working with large collections, which of the following is better?

Class Simple Object Only with Field / Properties and Category SimpleObjectController which contains all method implementations is required by SimpleObject in runtime, I create a collection of simple objects, instant Instant a simple object controller and Calling on its methods, I want to work with simple objects.

or

The class "complex object" that adds simple objects and the simple object controller in the conventional OO approach is a collection of complex objects in the runtime, to iterate over them , Calling his methods as needed.

It has been suggested that the first method is better in terms of memory usage, because instead of every heavyweight code in the collection, I understand in one object that if we have these items in 1000 collections It does not mean that the same method sitting in the memory is 1000 to implement. There will be 1000 examples of data, but they will share a code example (x86 code segments and data segments?). It starts flying in the face of general o o principles and encapsulation.

You should take another approach. There is no counter-frequency cost of code: There is a copy of the code for each class , not every instance, so there is no memory benefit for the first approach and you are right, oo style, Keep tasks with these figures, so that they can be incubated; If you take the first approach, then anyone can easily manipulate simple objects by working with it instead of controlling methods.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -