Reputation: 5165
I have a system where I have to "update certain data members of an object again and again in every "execution path"".
The thing is, depending on the type of object, at least 40-60 % of the "data members" that I update are hard coded values.
What I want is to do these hardcodings only once and then use the "hardcodings-already-done" object to update the data members that actually need on-the-fly updating.
This will make my code significantly faster, as I am doing a number of string assignments (50-100 depending on the type of object) as part of "hardcodings".
Clearly I cannot use references of "hardcodings-already-done" in an object cache because once I use that reference to build my final object, there will be a lot of "dirty fields" as I would be updating the "on-the-fly" fields. The same reference cannot be used next time (Unless I write an "erase dirty fields" routine).
Any ideas on the design. It feels like such kind of problems are routine. There is probably a well accepted pattern about this I don't know of.
Sorry, I have no code, this is basically a design question till now.
Upvotes: 0
Views: 59