9 ms·
Yagni (2015)
- OliverJones 8y agoYup. There's also the cost of inventory -- of software costs tied up in feattures that are not (yet) useful. Check out this article by Joel Spolsky. https://www.joelonsoftware.com/2012/07/09/software-inventory/ https://www.joelonsoftware.com/2012/07/09/software-inventory...
- jeffreybezos 8y agoExcellent article, particularly about triaging bugs, too.
- bastawhiz 8y agoThe problem I've seen when yagni is applied is not building something now leads to a costly data migration down the road when you actually do need it. I run a site that stores audio files. For the first half of its life, it simply stored the URL of the file on S3. I could have used objects representing audio assets with metadata to store the reference, but I didn't think I'd need it. When I was building another feature that _did_ need that functionality, the migration took far longer to write, test, and run than the process of building the asset objects feature and the feature I needed them for combined. Additionally, the new system made it easier to debug customer issues. I didn't know that I actually needed this feature the whole time.
- stanleydrew 8y agoWith hindsight, all yagni justifications look either correct or stupid.
- blazespin 8y agoYeah, though this is one area experience really helps
- jt2190 8y ago> The problem I've seen when yagni is applied is not building something now leads to a costly data migration down the road when you actually do need it. I see YAGNI fail when it's used an excuse to not think about the future at all, rather than a reason to delay building parts of a system that aren't needed yet. Relative to building software, thinking about it is cheap. I usually think about: * how needs might change in the future * what would have to change in the current system in order to satisfy those future needs * how difficult changing the system to meet those future needs would be. Ultimately, I know whether the current software design can easily adapt in the future.
- derefr 8y agoTo be clear, did your debugging problem come down to the fact that the metadata for the objects was on "the other side of" the S3 URL, being held as object metadata headers in S3 that you would need to do a HEAD request to retrieve per object, rather than as e.g. columns in a local RDBMS—such that you couldn't do aggregate queries on it to figure out what a customer's files "looked like" in a statistical sense? If so, I hate to say it, but doesn't YAGNI still apply here? This was, essentially, a scaling problem: the O(N) time-cost of querying metadata for N S3 objects was too high. You still could have written code to query that metadata out the "naive" way anyway, and it would have worked for low N. But it wouldn't have worked "at scale." But there are two [point five] ways to solve a scaling problem: 1. When you need to scale, write more code, customizing your logic to make it more performant, add locality or caching, etc. (This is what you did, and the way most software engineers think.) 1.5. Anticipate the need to scale, and write code "the more performant way" in advance. (This is where the YAGNI admonishment comes from.) 2. When you need to scale, attempt to find an infrastructure-level solution that involves writing no code. This is the way ops people tend to think, since they don't write code (or at least, they trust their knowledge of infrastructure solutions better than their coding abilities.) An example of approach #2, in this case, would be something like "put Varnish between you and S3, and configure it to only cache HEAD requests (and to synthesize HEAD response cache entries from proxied GET requests, without caching the GET response itself.)" Then your existing O(N) S3-metadata-querying code would—after warming the cache—suddenly be faster; it would probably be fast enough to answer whatever sort of debugging questions you'd like. The reason people say "YAGNI" is that, often, an ops person can take your developed software as a black box, and solve its scaling problems without touching the box. And this is often the optimal way to solve these problems: you probably can't write a caching layer for your web app, inside your web-app's process, that will work half as well as Memcached. Or a logging system that will work half as well as rsyslog. Or a web server that will work half as well as Nginx. Neither can the people who develop packages for your programming language's ecosystem. The real experts in "what you need for production-scale" converge on an infrastructure component and develop that, rather than contributing to FooLang's logging implementation. And, since these scaling problems can be solved without ever touching your code, it's especially silly to try to anticipate scaling problems you might have and solve them in your code, early. The only scaling problems you should worry about at design time are the ones that can't be solved by IPCing infrastructure components together. (Such as, for example, the cost of a huge number of concurrent threads. Erlang/Akka/etc. exist because they solve a particular scaling problem that is intractable to anything but a process-architectural solution.)
- kstenerud 8y agoThe only exceptions are APIs and data serialization/storage. Your cost of change on these are huge, so better to eat some extra cost now to future proof.
- olavk 8y agoYeah, although there is a difference between planning for a specific future which may not arrive, and planning to make any future change less painful.
- mmt 8y agoI'm pretty sure the original rule recognizes no exceptions, and certainly not on something so broad as an entire category. It may be that much narrower exceptions could exist, but future-proofing sounds like it could simply be justified as a feature actually needed now, if not just good overall coding practice [1]. The danger of allowing such a broad exception is that it doesn't take a huge leap to imagine a situation where it's used as permission to do something like a custom implementation of ACID in the app backed by a NoSQL key-value store (or "sharded" MySQL, before NoSQL was a thing). [1] YAGNI isn't a standalone rule but one of many in the "XP" collection. Any one of them, out of context, in complete isolation, could just as (if not more) easily require a long list of caveats/exceptions to make sense in the general case.
- stickfigure 8y agoI would still argue you did the right thing. Sure it would be nice to always have enough domain expertise to pick the right solution in the first place, but you didn't have that knowledge at the time. This experience cost you a little pain but your system is working and you are now smarter. A developer will be presented with thousands of situations like this across her career. If she takes the YAGNI/under-engineering approach, it almost always ends up a similar story - some growing pains, some re-engineering, a lesson, and a working system. On the other hand, if she errors on the side of over-engineering, there's no bound on how far off the rails she can go. At best she ends up with some extra useless code that someone will delete later. At worst it becomes a time sink that consumes the entire budget and schedule. YAGNI forces you to always hew to the side of under-engineering. And if there really are design considerations that you know are easier to bake in early than retrofit, it's almost always possible to arrange dev stories in such a way to force those design decisions out early.
- JamesBarney 8y agoBut what if you built out all the meta data but did it wrong, then you'd have to migrate from one complex model to another which is usually more difficult then migrating from a simple one to a complex one.
- bastawhiz 8y agoI built the same thing I'd planned originally, so the point is moot. YAGNI does nothing to stop you from misunderstanding the problem. And in the case of my problem, the metadata was fresh anyway. Generating it from scratch would have the same migration cost, but all the original tooling existed so I wouldn't be building the feature from scratch. If the point is "what if the whole concept was wrong?" then sure, you got me. But the point is that I _did_ follow a YAGNI mindset and paid a considerable cost. Even if I had built the wrong thing, that doesn't negate the fact that technical debt had accumulated and prevented me from doing the thing I actually needed to do.
- JamesBarney 8y ago> YAGNI does nothing to stop you from misunderstanding the problem. A lot of times it does because you usually gain more information about your users and problem domains as time goes on. So if you build a feature when you need it a lot of times you understand the feature better than before hand. But I think we're all in agreement that if you understand a domain very well, think there is a very high chance a feature will be required, and it's a good deal more expensive to build later than now than you should build it now.
- mooreds 8y agoWhat if you'd never built the feature that needed the metadata/reference? What if you had abandoned your project? How long did you run with the much simpler, non abstract S3 location and what did getting to launch sooner buy you?
- bastawhiz 8y ago1. The new feature increased the reliability of a user onboarding function. If I hadn't built it, I likely would not have remained in business. 2. The company would go bankrupt? I don't see your point. 3. One and a half years. It didn't get me anything, because I didn't plan for the added metadata until about nine months in. If the question is "what did the nine months between when you came up with the idea and when you were forced to build it get you?" the answer is "a world of hurt." At the time, the cost of migrating was low. When my users 100xed, the cost of migrating had increased over a thousand-fold.
- snapspans 8y agoI would argue there is another important benefit than the takeaway suggested in the second sentence of [1], that is the attention to architecture choices that allow for simple or complex (costly) refactoring later can engender more forward-looking awareness in the team's culture. [1] "One approach I use when mentoring developers in this situation is to ask them to imagine the refactoring they would have to do later to introduce the capability when it's needed. Often that thought experiment is enough to convince them that it won't be significantly more expensive to add it later."
- gaius 8y agoTake this with a pinch of salt. With consultants it's YAGNI until you do need it, at which point you will be billed at their contingency rate! You don't need to go full waterfall to understand your requirements up front and make the choice not to wait until something becomes a showstopper because "YAGNI and it won't fit into this sprint anyway". Trust your experienced, in-house engineers for what you are or aren't gonna need.
- iris-digital 8y agoPrevious discussion, with lots of comments: https://news.ycombinator.com/item?id=9605733 https://news.ycombinator.com/item?id=9605733
- nvarsj 8y agoLike any generalization, it's not always true. Boss decides to add y,x,z options "just in case"? - YAGNI Engineer wants to get the datamodel correct up front to avoid costly rework and data migration in the future? - Not YAGNI Fowler fortunately states this distinction: "Yagni only applies to capabilities built into the software to support a presumptive feature, it does not apply to effort to make the software easier to modify."
- Silhouette 8y agoThat's a bit of a cop-out, though. How much software development isn't either implementing the actual features or making the software easier to modify? This one is a bit like the TDD advocacy that says you shouldn't need to do much design work up-front because you can let the tests drive the design along with everything else.* *Except for the part where you refactor your code, which by definition shouldn't be changing its behaviour and therefore can't be driven by adding tests to your test suite, where exactly the same design issues will immediately arise.
- combatentropy 8y ago> How much software development isn't either implementing the actual features or making the software easier to modify? The key is the adjective, presumptive. YAGNI is about features that aren't needed now and it's uncertain whether they ever will be.
- Silhouette 8y agoThis seems awfully close to a No True Scotsman argument. The Fowler quote was, "Yagni only applies to capabilities built into the software to support a presumptive feature, it does not apply to effort to make the software easier to modify." If we exclude features we definitely do want from consideration, so we're only talking about presumptive features, and if we exclude actually implementing those presumptive features, so we're only talking about "capabilities built into the software to support a presumptive feature", and if we then further exclude things that "make the software easier to modify", then how much development is really left for YAGNI to affect? I can't speak for anyone else, but when I write new code, it is generally either implementing some specific functionality that we want right now or improving the common foundations of the system in some way. The usual reasons for the latter would be either gaining some immediate benefit, such as improved performance or robustness, or making the code easier to modify so we can then gain some benefit. By Fowler's argument, I don't see much of a middle ground where YAGNI would mean anything, unless maybe a developer is in the habit of starting to develop code for some specific feature when there isn't actually any requirement for it yet, but why would anyone do that anyway?
- wsy 8y agoYAGNI is a sad example of the state of software engineering: our field follows rules of thumb, based on anecdotes as evidence. When will experimental validation become best practice, like in the other engineering disciplines?
- ternaryoperator 8y agoThere is a whole field of study--what was originally called software engineering--that does quantitative, empirical analysis of software development. Its practitioners are often called by managers entering into large projects that have tight quality requirements so that the optimal choices can be made in terms of tooling and techniques. (For example, large-scale automotive software, where there is far less tolerance for error than in IT.)
- wsy 8y agoDo you have some pointers to important papers of this field of study?
- ternaryoperator 8y ago[1] Article from Dr. Dobb's gives a very high-level overview of the kind of data that is available. [2] is one of the foundational books in this area. Its analysis of testing effectiveness is fascinating because it's so revealing. For example, comparing defect rates in projects that use TDD vs. non-TDD; the effectiveness of static analysis; etc. [1] http://www.drdobbs.com/225701139 http://www.drdobbs.com/225701139 [2] https://www.amazon.com/dp/0132582201/ https://www.amazon.com/dp/0132582201/
- wsy 8y agoThanks a lot!
- wsy 8y agoAfter having read a bit, I'm a bit disappointed. While the intent goes in the direction I would like to see, the actual execution does not follow scientific principles. "Consultant collects some data, derives conclusions, and writes a book" is actually again only anecdotal. You need to think about your sample before collecting the data, otherwise your outcome is biased by who gave you a consulting gig. Consequently, the work has never been published as peer-reviewed paper with experiment and/or real-world data, so that someone else could validate or reproduce results. Is that assessment correct, or did I overlook scientific papers?
- camgunz 8y agoI think coherency of implementation is a lot more important than YAGNI. For example: class Car: def honk(self): print('Honk!') Cool, now we have a car, but it only honks. But we only needed it to honk, so that's fine. class RoadTrip: def __init__(self, car, destination): self.car = car def go(self): self.car.start() self.car.drive_to(destination) Oh no, we built a car but it does nothing that a car does. Let's add this functionality. class Car: def __init__(self): self.started = False self.gps = [] self.location = cool_app.get_current_location() def honk(self): print('Honk!') def start(self): self.started = True @property def location(self): return self.gps[-1] @location.setter def location(self, new_location): self.gps.append(location) def drive_to(self, location): self.location = location Super easy. Except a different user of our library implemented this functionality already for a different reason, but in a different way. class CarEngine: def __init__(self, car): self.car = car self.started = False def start(self): if self.started: raise Exception('Already started!') self.started = True def turn_off(self): if not self.started: raise Exception('Not started!') self.started = False class CarGasTank(self, car): def __init__(self, gallons): self.car = car self.capacity = gallons self.level = gallons @property def empty(self): return self.level == 0 class MotorCar: def __init__(self, engine, gas_tank, mpg, location): self.engine = engine self.gas_tank = gas_tank self.location = location self.mpg = mpg @property def started(self): return self.engine.started def start(self): return self.engine.start() def drive_to(self, location): distance = location - self.location fuel_required = distance / self.mpg if fuel_required > self.gas_tank.gallons: raise Exception('Not enough gas!') self.gas_tank.gallons -= fuel_required self.location = location I've lost count of the number of times I've seen stuff like this. Sometimes the original implementation is in a different library that's hard to change. Sometimes other code rely on specific details of the original implementation so changing it requires changing that code too. Sometimes additions seem "out of scope" so they are actively pushed to dependencies. It might feel like this is a process problem -- like there should have been better upfront design or communication -- but these "failure cases" are actually the success cases for code. You want code to rely on your libraries. You want to consider all users of your libraries when making changes. The problem is actually YAGNI, because that mentality encourages us to churn out big, incoherent bags of functions when we should be thinking about code responsibilities and designing whole systems. You can see this in action with JavaScript most infamously. Its standard library is extremely YAGNI, and it led to whole new programming languages being built on top of it because it was so anemic. The complexity has to live somewhere, and if you don't deal with it in a coherent and orthogonal way, someone else will have to deal with it and their options will be a lot more limited than yours. Following simple mantras like DRY, YAGNI, and whatever else fits on a poster is the surest way to mess up your design. It requires thoughtfulness and experience, and there are no shortcuts.
- bgongfu 8y agoEveryone likes to pretend they can predict the future for a while, to the point where they will stop at nothing to make it conform to their predictions. Then comes the part where they will defend their choices to death, no matter how much evidence to the contrary is piling up. Once you start seeing the entire chain of consequences, it becomes easier to discipline yourself; it's a process of growing up and taking responsibility.
- keithnz 8y agoYAGNI is very useful. But :- It's mostly useful in a situation where problems that YAGNI was trying to help with are happening. Namely, when people are trying to ask for anything that is possibly needed upfront because if you change your mind later it will cost a lot more to get it. For developers it was to try and get them to think vertically through software rather than horizontally and to stop designing large layers of goop instead of focusing on working software which you build out incrementally which means a HUGE focus on composable modular software. It's also not a justification by itself. Lisa: "Lets do X" Bart: "YAGNI" There needs to be a bunch of thought about things and YAGNIs purpose is really to just challenge what it is that is going to get built. Most of the criticism of YAGNI is mostly YAGNIing something that was actually needed, or using YAGNI to compromise a software design. But that's not a fault of YAGNI, that's either because you let YAGNI hold too much power over your decision making because you felt its pressure to stop you doing something, or you just weren't capable at decision making time to work out what you really needed. YAGNI is just a focusing tool to work out what you are going to need and it's as strong or as weak as the people making the decisions.
- postfacto 8y agoIt’s been my experience that most programmers who have worked on many different projects across many different employers for many years can intuit whether something will be needed with a very high degree of accuracy.
- deleted 8y ago[deleted]
- zmmmmm 8y ago> Yagni only applies to capabilities built into the software to support a presumptive feature, it does not apply to effort to make the software easier to modify. Yagni is only a viable strategy if the code is easy to change, so expending effort on refactoring isn't a violation of yagni This is doesn't concord with my understanding of this term. My YAGNI encounters are MUCH more often around technical design decisions that will theoretically make software easier to modify down the track but in practice we have no idea if the design will look the same by then and hence whether the benefits will be realised is almost impossible to estimate. Things like "It would be better if this configuration was stored in a database table than a text file" or "these modules should be refactored implement the same interface so they can share code" etc.
- InclinedPlane 8y agoYAGNI is no excuse to design shitty systems, however. Make your systems as modular and componentized as is sensible. It'll pay off immediately as well as down the road when you inevitably need to make modifications. However, it is wise to avoid adding in too many features that you merely think are a good idea but don't actually have proof are useful in practice. One thing to be aware of is that YAGNI can often be the cry of someone who doesn't want to admit they are accumulating mountains of technical debt. And it's very possible to go effectively "technically bankrupt". Rewrites are expensive and take a long time, in order to do them properly it usually requires launching projects in parallel so that the rewrite can get done while the old stuff is still keeping the lights on, and so that the rewrite can attain the same level of operational maturity. You see this even at multi-billion dollar companies, changing architectures is a difficult process. But what happens if you are stuck with a mess of bad code and a business that is only sufficiently profitable to continue supporting the old code but couldn't afford doing a parallel rewrite? Well, then you could very easily find your company stuck riding that bad code forever. Given the dynamic nature of tech businesses, being unable to respond to market changes because you are mired in technical debt is a huge competitive disadvantage and likely to lead to a much shorter lifespan for your company. So be careful making too many short-term decisions. YAGNIs add up and up and up, you don't want to get to a point where when you do "need it" it's now effectively impossible (due to requiring an exorbitant budget to implement it).