Open/closed principle

From Lojban
Jump to navigation Jump to search

According to the open/closed principle in object-oriented programming "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification", that is, such an entity can allow its behavior to be modified without altering its source code. This is especially valuable in a production environment, where changes to source code may necessitate code reviews, unit tests, and in the case of Lojban getting users into relearning the language and rewriting the corpus of texts. Code obeying the principle doesn't change when it is extended, and therefore needs no such effort.

Meyer's open/closed principle

Bertrand Meyer's idea was that once completed, the implementation of a class could only be modified to correct errors; new or changed features would require that a different class be created. That class could reuse coding from the original class through inheritance. The derived subclass might or might not have the same interface as the original class.

Meyer's definition advocates implementation inheritance. Implementation can be reused through inheritance but interface specifications need not be. The existing implementation is closed to modifications, and new implementations need not implement the existing interface.

Lojban

The publication of CLL stopped any changes to the core of the language, however, xorlo reform broke it and invalidated old usage. The overall impact to the corpus wasn't that huge, though, since the number of mistakes in the corpus exceeded the number of changes related to xorlo.

External links