by hackernewsguy · 13y ago · 0 comments
E.g. for the pet example: Avoid hard-coding the class name all over the place, so that if you do end up having to add a Pet superclass and add Cat's in the future, you don't need to make changes more than one or two places.
Writing loosely coupled and reusable code is good practice anyway, and also makes testing easier, but if you practice YAGNI it becomes extra essential: You know your code almost certainly will need to change in the future, so you should structure your code accordingly to make extension and refactoring easy.