What’s the name of a particular code smell /anti-pattern where you write methods that don’t actually need yet and may never do, just because you can or because you think you may use it in the future?
Just to emphasise, I’m not asking for a descriptive phrase, I’m looking for a fairly commonly used *specific name* given to this code smell.
Thanks.
YAGNI
Edit: lmgtfy – https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it?wprov=sfla1
Thats it I think, thx
Writing code because you might need it is sometimes called “speculative programming“, or “Speculative Generality“. Both are not to be confused with a the CPU’s “speculative execution”.
The cure is of course the better-known YAGNI principle: You Aren’t Going to Need It.
NB in that essay, Fowler calls the specific code smell a “presumptive feature”.
I and my any-property-you-want fluent data query system feel attacked.
I do all this work on providing methods for filtering on any of the 30 fields in a way that you can keep saying .ById(123).ByState(States.Active).Before(Date).After(Date)…. and in the end, we use two (get active account for id and get all accounts archived between dates).
I call it the Consultant Conundrum. Outsource your dev for what the boss says is a “simple 2 day project”. 2 months later get more Speculative Programming than actual useful code. Fire the Consultant. Spend another 2 weeks refactoring the code that the Consultant was supposed to deliver in working order.
Why do consultants do this? I guess to up the billable hours on the project, not expecting any FTE developer to know the difference.
Any idea on how to deal with this? I have a dev that does this and always anticipates we’ll need this for a feature he eventually wants to build but has to convince our app owner of its value first so he sneaks it in another semi related ticket and rationalizes it as future proofing and reducing work in the future? Is this the same thing?
C# devs
null reference exceptions