Open/closed principle

The open/closed principle was coined by Bertrand Meyer [24], who stated the following:

"A software module should be open for extension but closed for modification."

Almost all Go programs import and use types from a host of other packages, some being part of the Go standard library whereas other packages are provided by third parties. Any software engineer that imports a package into their code base should always safely assume that all the types that are exported by said package adhere to a contract that is guaranteed to be immutable. In other words, a package should not be able to modify the behavior of the types that are exported by other packages. While some programming languages allow this type of modification (via ...

Get Hands-On Software Engineering with Golang now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.