DEV Community

Discussion on: Encapsulate state and expose behavior when writing object-oriented code

Collapse
 
alainvanhout profile image
Alain Van Hout • Edited

Keep in mind that the ultimate goal here is to have code that does its job and is maintainable. OOP is a tool that sometimes helps with the latter, and sometimes doesn’t. As to data classes, in which ever form, these are useful when state and behaviour reflect separate concerns (which is more often so than the average OOP introductory tends to suggest).

That said, OOP teaches some great lessons on encapsulation in particular, and separation of concerns in general.