Thursday, April 5, 2012

Encapsulation in contrast to the Open/closed Principal

Azadeh Razaghian and I started reading C# 4.0 in a Nutshell: The Definitive Reference by Joseph Albahari and Ben Albahari this evening.

Something good from the first page: Encapsulation means creating a boundary around an object, to separate its external (public) behavior from its internal (private) implementation details.

In the past I've mistaken what is encapsulation for what is the Open/closed Principal when OCP really seems to me now to be more about breaking up fat classes (into many smaller ones) in the name of making maintainable code. Encapsulation seems to be about tucking logic away behind private methods.

No comments:

Post a Comment