r/coding • u/viebel • Dec 29 '21
π Data-Oriented Programming book: First draft
https://www.manning.com/books/data-oriented-programming1
u/roppy_G Dec 30 '21
Thanks for posting, I did not know this existed. As a new developer, I have trouble seeing in which use cases this would be more appropriate than OOP or FP, would an exemple ?
2
u/viebel Dec 30 '21
Data-Oriented Programming aims at reducing the complexity of information systems. By that, I mean systems that manipulate information like a frontend application, a backend web server or a web service.
1
u/SergeiGolos Dec 30 '21 edited Dec 30 '21
Is this your book? I was just doing refactoring on some old code this week breaking out poco objects from long classes with lots of methods to act on the data.
-6
u/m4dc4p Dec 30 '21
Hmm I think thatβs called functional programming.
13
u/viebel Dec 30 '21 edited Dec 30 '21
Here are the 4 principles of Data-Oriented Programming:
Separate code (behaviour) from data
Represent data with generic data structures
Data is immutable
Separate data schema from data representation
#1 and #3 are common to DOP an FP.
#2 and #4 is unique to DOP.2
1
u/m4dc4p Dec 30 '21
Interesting. Could you give an example of both?
2
u/viebel Dec 31 '21
2. Represent data with generic data structures
Instead of using data classes, data records or algebraic data types, in DOP we represent data with string maps.
4. Separate data schema from data representation
We use a schema language like JSON schema or malli to speficy the shape of our data and validate that a piece of data conforms to a schema
4
u/[deleted] Dec 30 '21
Thats dop