Every abstraction adds indirection and reading overhead, and the wrong kind adds runtime cost (virtuals' vtable indirection) or code bloat (many template instantiations). The most common failure is over-abstraction: building an interface that mirrors every register field and config bit, which isn't an abstraction at all, it's the hardware with extra layers, harder to read and providing no portability benefit because it's still chip-shaped. You avoid it by keeping interfaces minimal: expose only the operations the application actually uses (set/clear/read), hide the registers, and add abstraction only where you need portability or testability, not reflexively on every peripheral. Also choose the cheap mechanism: prefer compile-time (template) polymorphism so there's no runtime cost unless you specifically need runtime swapping. The best HAL is the smallest one that lets your logic ignore the chip; anything beyond that is cost without benefit.
C++ for Embedded · Interview question
What's the downside of the HAL pattern, and how do you avoid over-abstracting?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
The HAL Pattern
Abstract a peripheral behind an interface so app logic survives an MCU swap and runs in a PC unit test, using runtime virtuals or zero-overhead compile-time polymorphism.