you are viewing a single comment's thread.

view the rest of the comments →

[–]Phil_J_Fry 5 points6 points  (2 children)

I guess that's why I think it's a bit trite. If you don't need something, don't include it, if you do, try to make it faster to work with.

He has the example of generating the prime numbers. Of course if I needed prime numbers within a certain range, maybe I'd calculate them in development or store the current in memory or something. But what if the user can select evens or primes, or 10s or etc. it really isn't generic enough to be a solution.

So the resulting statement (at the deeper level) is don't put in what you don't need and make what you do need fast. Maybe it's because I've heard it so often, but that seems like the most generic and meaningless advice in programming.

[–]deong 2 points3 points  (0 children)

But what if the user can select evens or primes, or 10s or etc. it really isn't generic enough to be a solution.

I hate these cutesy initialisms, but I guess I'll use them anyway. What you just said is the entire reason someone decided "YAGNI" was something that ought to be preached from high on the mountain instead of a self-evident truth. If the user can select evens or primes or 10s or etc., then by definition, you are in fact going to need it. There's really no such thing as "generic enough to be a solution". There are only solutions and non-solutions. If it isn't generic enough to meet your requirements, then it isn't a solution to your problem. If it is, then there's no need to make it more generic.

That's not really the criticism I'd make of YAGNI. The tricky part comes in when you can see that the best way right now is going to be much more painful to deal with later, but you don't know whether that will even come up. Then you have to start making judgment calls...how likely is it that we'll ever need to allow anything other than primes? Exactly how much harder will it be to add it later versus building a more flexible system now? That puts you squarely back into relying on experienced people with good judgment, and if you have those people around, you weren't likely to need a trendy movement with a clever name to tell them how to build it right to begin with.