4 ms·
And what happens when one of those keys changes?
by st3v3r 10y ago
And what happens when one of those keys changes?
- niftich 10y agoYou change your code. Loose coupling a nice goal to aim for, but at the end of the day, somewhere deep down inside the code, you have to tightly couple to actually get anything done. Where that transition occurs is entirely programmer's discretion.
- st3v3r 10y agoBut there's a difference between changing it once when you serialize/deserialize it, and changing it every time you try to access the key.
- sidlls 10y agoWriting the code with the assumption that a key will change is on the same level with premature optimization, in my opinion. It might be reasonable to make the assumption for some keys. In these cases a function taking the data and key as arguments and returning the value is sufficient and appropriate. Frankly, if the code base is so littered with references to that specific data and key combination it might actually indicate a poor design.
- st3v3r 10y ago"Writing the code with the assumption that a key will change is on the same level with premature optimization, in my opinion." Considering how easy it is, and how often I've had keys change on me, I have to strongly disagree. "Frankly, if the code base is so littered with references to that specific data and key combination it might actually indicate a poor design." That's kinda the point of the article.
- Retra 10y agoA single constant will fix that problem.
- Singletoned 10y agoOr even just a search and replace...