in reply to Re: multi-tier collections & lack of modulization/OO
in thread multi-tier collections & lack of modulization/OO
Yeah, it's stupid of the developer to do that, but you don't enforce rules on the data.
Let's say you were working on an array, and you have a function returnAverage. One optimizatio you could do, is recalculate the average as you are adding stuff to this array, keeping track of how many elements there are. You wouldn't have to add up all the #'s and divide. You could keep track of the current average, multiply by the current number of items to find the total to create your new average. This is especially true if your array is 100,000,000 elements big.
But imagine if someone directly adds data w/o updating the statistics. Then you have to add all those numbers since they didn't update the statistics. Imagine it like rebuildinga db index. By encapsulation, you can guarantee that your data is accessed in certain ways and things are done in a certain manner.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: multi-tier collections & lack of modulization/OO
by davido (Cardinal) on Dec 12, 2003 at 05:13 UTC | |
by BUU (Prior) on Dec 12, 2003 at 06:43 UTC | |
by davido (Cardinal) on Dec 12, 2003 at 06:53 UTC |