Goldplating is orthogonal to creating quality, extendable code. You should always think when coding, and thinking of how your code will exist in the future is part of coding for today.
Goldplating doesn’t even have to be big changes. It’s death by 1000 cuts. It’s any unused, unwanted code paths through the system. So what if you can code a method to count buttons on shirts. If nothing uses it, then what use is it anyways?
More code
Mode defects
More maintenance
Longer compile times
Bigger downloads
Larger working set
More memory required
faster processor required
All for something that nobody asked for. It’s irrelevant even if it’s done on your own time. To the security minded, it’s an exploit waiting to happen, because I’m sure those testers didn’t know to look for it to test it.
If, once you code something and you think there’s more value to be had, send an email to your team explaining the class / feature / whatever, and it’s other possibilities. Document the code and say ‘we could also do xyz’ because in the end if your idea is worth anything it’ll get put into use.
This is why I like the gist of the agile methodologies. You write tests for what needs to happen, and once your code works, you’re done. I don’t know how many times I’ve deleted cruft out of classes when refactoring because ‘I thought it was a good idea at the time’ when coding the class, but it was completely unused.
Seriously, I’m not the code I write. I don’t mind if a week later I’m rewriting something that I alerted someone we’ll need to change. Thing is, as smart as I am I’m only right 1/2 the time, and the client is happy enough with things being the way they wanted, and with everything being delivered predictably.
Not goldplating is also better for estimating, and for training your client. If you give them what they ask for, they get better at asking for the right functionality upfront, and you have better estimates.
Otherwise you should implement hashcodes, serialization, object equals, value equality, icomparable, iequitable, and everything else under the sun for every class you ever write to cover it being used anywhere.