Briefle words · Code & architecture
Single level of abstraction
Also called SLAP
The guideline that every line in a function should work at the same level of detail, either big steps or small details, not a mix.
Say it to an AI
Python confirm_booking(booking) as a composed method at a single level of abstraction: validate, price_trip, charge_card, send_confirmation_email, then set status. Put the email rendering and sending in its own function using our template and mailer, no SMTP or HTML inline.
How an expert would brief the stronger version of “Confirm a booking”.
See it
Try it as a puzzle →A travel-booking API confirms a multi-leg trip once the traveller pays.
Why: B's 'confirm_booking' is all big steps; A mixes 'charge_card(...)' with 'smtp.login(MAIL_USER, MAIL_PASS)'.
Related words
Room 3 · Functions & structure
Learn “Single level of abstraction” in a five-minute lesson