OOP Explained: What Abstraction Really Means and How It Differs from Encapsulation
A DEV Community article breaks down abstraction in object-oriented programming, defining it as exposing 'what' a system does while hiding 'how' it does it. The author distinguishes abstraction from encapsulation, noting that encapsulation protects state while abstraction simplifies complexity by reducing a problem to a cleaner interaction model. Code examples in C# illustrate how an INotificador interface lets callers send messages without knowing whether the underlying mechanism is SMTP email or a REST-based SMS API. The article also warns against 'leaky abstraction', an anti-pattern where implementation details bleed into the public contract, such as an interface method throwing a provider-specific exception. A game combat analogy reinforces the concept, showing how a single 'Attack' action can hide complex damage calculations like critical hit chance and elemental multipliers behind a simple method call.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in