DELAPARRA
Index
Color
NL
Category: Programming paradigms

Decoupled Functions

Explained by Updated

What is Decoupled Functions?

Decoupled Functions: Behaviour lives in standalone functions that take data in and return data out, not as methods attached to that data. Decoupled functions are standalone functions that take data in and return data out, instead of being methods tied to a particular object. calculateVat($amount, $rate) works with any amount, from any source.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Decoupled Functions

How is Decoupled Functions used in practice?

Because they do not depend on hidden state, they are easy to test. You pass input and check output, with no setup of objects or mocks. They are also easy to reuse in places the original author did not foresee.

What should you keep in mind with Decoupled Functions?

This style comes from functional programming, but it fits well in any codebase. A good candidate is logic that does not really belong to one class, such as price calculations, date rules or formatting. Keeping it in small, pure functions avoids the god classes that accumulate every helper in the project.

At a glance

CategoryProgramming paradigms
Explained by
Updated

More Programming paradigms terms

All terms starting with D

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.