Code Complete Essentials | Course Excerpt #2: Encapsulation

preview_player
Показать описание
In this excerpt, Steve McConnell discusses the highly problematic differences when programming “through” vs. “to” the interface.

In modern programming languages, or currently popular programming languages, we don’t have good support for real encapsulation. Without encapsulation, abstraction breaks down. This introduces subtle semantic coupling between the client code and the implementation, which increases overall complexity.

In the words of P.J. Plauger, “It ain’t abstract if you have to look at the underlying implementation to understand what’s going on.” This is really an issue, and the industry could pay a lot more attention to the abstractions that presented in the interfaces.

Without abstraction, encapsulation breaks down.

If the interface doesn’t tell how to use the class, a natural response is to read the implementation to learn how the class works. This is “business as usual” for most software projects. We as an industry need to do a much better job of creating interfaces that other programmers can actually use.

Focus more on interfaces.

Implementation affects code quality. Interfaces affect longevity, extendibility, ability to scale up a system, etc.

Рекомендации по теме
Комментарии
Автор

CSCI 4/5448 OOAD Quiz 9:
Right answers:
If the interface doesn’t clearly say how to use a class, you’ll read the implementation, so encapsulation breaks down
Interfaces to code affect longevity, extendibility, and scalability of a system

catgirl
Автор

So, a successful framework/interface is defined through its usability!

sebastianwardana
Автор

Yes, too much programming through and not to. Well phrased. Bring back encapsulation, few languages really support it.

ianmcd
Автор

Call the author of the code, if the interface is unclear.
Communicate rather than subvert the code base.

douglasstrother