MikeLindsay
3 months ago

If you're using TDD and your app is still in development how strict should you be about the Open/Closed Principle?

Posted 3 months ago by MikeLindsay

TLDR: - Can you be more lenient with the Open/Closed principle when building an undeployed project (with TDD) than if a working on a deployed app?

This is actually a bunch of questions:

  1. If you're working on a new undeployed project and you're using TDD and you need to add a new method to a class (e.g. even a simple extract method refactor) that implements an interface being used in your client code...can you add it if you have a good test suite and add it to the interface as well?

If you couldn't then it would mean that you get one shot to get a class with all the functionality that you needed and then you would have to Decorate the object. As the app is still being developed (let's say you were using Agile and requirements where changing) - it seems impractical?

  1. If your project was live (and for a few months) then should you resort to Decorating/Inheritance to extend the functionality and not touch the class at all as, in this case, bugs and breaking changes are serious.

Thanks in advance!

Please sign in or create an account to participate in this conversation.