svg
Post Image
By Daniel Tanque15 de Novembro, 2023In Sem categoria

Data Structures

Data Abstraction

It’s a good idea not to expose your concrete classes to the public client/rest of the world. You want to be able to adapt and change implementation without impacting other parts. So you should always expose an abstraction so that you can change it and add to other classes and use it, but mainly hide the data behind those abstractions.

Per example look at this implementation of a Point in the Cartesian plane:

DTO

DTOs or Data Transfer Objects are the pillars of data structure in a class, it has the variables/attributes that make the object and those are private, and then we have the constructor, getters and setters that enable interaction with it.

Active Record

This is a special form of DTO, they have public (or bean-accessed) variables but they have typically navigational methods like save and find. Normally they are direct translations from database tables or other data sources.

Conclusion

Objects reveal behavior while concealing data, facilitating the seamless incorporation of new object types without altering existing behaviors. However, this design makes it challenging to introduce new behaviors to existing objects. On the other hand, data structures unveil data with minimal inherent behavior, allowing for the easy addition of new behaviors to existing structures. Yet, incorporating new data structures into existing functions becomes challenging.

svgAnsible (Inventory, Playbook & Modules)
svg
svgAnsible (Conditionals, Loops and Roles)

Leave a reply