Tell Don't Ask principle explained
thiCha

thiCha @thibaultchatelain

About: Lead developper

Location:
France
Joined:
Jul 13, 2020

Tell Don't Ask principle explained

Publish Date: Dec 26 '24
0 0

The basic principle of the Tell Don't Ask principle is to prefer telling an object what to do rather than asking an object for its data and acting on this data.

The idea is to put into the object the behavior related to that object.

The object that owns a data is responsible of its own logic.

The code is therefore more coherent within the codebase and within the object itself.

Last but not least, the behavior is encapsulated in the object meaning that you can work with a minimal public interface outside of the object which makes it easier to maintain and modify.

Comments 0 total

    Add comment