home/ atoms/ software-abstraction-principle

Abstraction hides implementation details so programmers focus on what code does, not how

In software, abstraction means encapsulating complexity behind an interface. When you call line(0,0,100,100), you do not need to know how Processing calculates which pixels to illuminate — you only need to know the parameters and their effect. This principle applies at every scale: functions abstract code blocks, classes abstract data+behaviour, libraries abstract entire subsystems. Good abstraction reduces cognitive load and enables composition of complex systems from simple building blocks. The analogy is a car’s steering wheel abstracting the mechanical complexity of the steering system.

Examples

// Using abstraction: caller doesn’t know how ellipse() rasterises ellipse(50, 50, 30, 30);

// Writing abstraction: implementation hidden behind function void drawStar(float x, float y, float r) { … }

Assessment

Explain why the driver of a car does not need to know about pistons to steer; then describe how this principle applies when writing a particle class in Processing.

“The idea of abstraction is essential to writing software. In Processing, drawing functions such as line(), ellipse(), and fill() obscure the complexity of their actions so that the author can focus on results rather than implementation.”
corpus · processing-handbook-no-login-mirror-pdf-reas-and-fry · chunk 43