Learn the Open/Closed Principle.

Tools are better when you don’t need to rebuild them.

Continuing to discuss the SOLID principles, one can think of the open/closed principle in terms of using tools. The key idea is that software entities (classes, modules, functions, etc.) should be open for extension but closed for modification. That is to say, you can use the tool, you can attach things to the tool, but you cannot rebuild the tool.

Modification of software requires code reviews, unit tests, documentation, and work. Despite all that, modifications still manage to break things. On the other hand, if you can build a tool that cannot be modified and doesn’t need to be changed, you avoid those dangers. It just becomes a library you use.

Extending classes is still allowed, which allows you to customize the classes and add additional functionality. Extension of software requires the subclass to follow the original interfaces, so things that use the class will still work.

If you can build applications in this way, they start to resemble Lego building blocks. You’re not concerned with the innards. You don’t try to modify the components; instead, you use them and build more complex machines out of them. Applications built in this way react to change better and have fewer bugs.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: