Data-Oriented Programming: Reduce complexity by rethinking data

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Eliminate the unavoidable complexity of object-oriented designs. The innovative data-oriented programming paradigm makes your systems less complex by making it simpler to access and manipulate data. In Data-Oriented Programming you will learn how to: • Separate code from data • Represent data with generic data structures • Manipulate data with general-purpose functions • Manage state without mutating data • Control concurrency in highly scalable systems • Write data-oriented unit tests • Specify the shape of your data • Benefit from polymorphism without objects • Debug programs without a debugger Data-Oriented Programming is a one-of-a-kind guide that introduces the data-oriented paradigm. This groundbreaking approach represents data with generic immutable data structures. It simplifies state management, eases concurrency, and does away with the common problems you’ll find in object-oriented code. The book presents powerful new ideas through conversations, code snippets, and diagrams that help you quickly grok what’s great about DOP. Best of all, the paradigm is language-agnostic—you’ll learn to write DOP code that can be implemented in JavaScript, Ruby, Python, Clojure, and also in traditional OO languages like Java or C#. About the technology Code that combines behavior and data, as is common in object-oriented designs, can introduce almost unmanageable complexity for state management. The Data-oriented programming (DOP) paradigm simplifies state management by holding application data in immutable generic data structures and then performing calculations using non-mutating general-purpose functions. Your applications are free of state-related bugs and your code is easier to understand and maintain. About the book Data-Oriented Programming teaches you to design software using the groundbreaking data-oriented paradigm. You’ll put DOP into action to design data models for business entities and implement a library management system that manages state without data mutation. The numerous diagrams, intuitive mind maps, and a unique conversational approach all help you get your head around these exciting new ideas. Every chapter has a lightbulb moment that will change the way you think about programming. What's inside • Separate code from data • Represent data with generic data structures • Manage state without mutating data • Control concurrency in highly scalable systems • Write data-oriented unit tests • Specify the shape of your data About the reader For programmers who have experience with a high-level programming language like JavaScript, Java, Python, C#, Clojure, or Ruby. About the author Yehonathan Sharvit has over twenty years of experience as a software engineer. He blogs, speaks at conferences, and leads Data-oriented programming workshops around the world.

Author(s): Yehonathan Sharvit
Edition: 1
Publisher: Manning Publications
Year: 2022

Language: English
Commentary: Vector PDF
Pages: 424
City: Shelter Island, NY
Tags: Software Engineering; Databases; Debugging; Data Structures; Concurrency; Object-Oriented Programming; Unit Testing; Data Modeling; Complexity; Programming Paradigms; Polymorphism; Data-Oriented Programming

Data-Oriented Programming
brief contents
contents
forewords
preface
acknowledgments
about this book
Who should read this book?
How this book is organized: A road map
About the code
liveBook discussion forum
about the author
about the cover illustration
dramatis personae
Part 1—Flexibility
1 Complexity of object- oriented programming
1.1 OOP design: Classic or classical?
1.1.1 The design phase
1.1.2 UML 101
1.1.3 Explaining each piece of the class diagram
1.1.4 The implementation phase
1.2 Sources of complexity
1.2.1 Many relations between classes
1.2.2 Unpredictable code behavior
1.2.3 Not trivial data serialization
1.2.4 Complex class hierarchies
Summary
2 Separation between code and data
2.1 The two parts of a DOP system
2.2 Data entities
2.3 Code modules
2.4 DOP systems are easy to understand
2.5 DOP systems are flexible
Summary
3 Basic data manipulation
3.1 Designing a data model
3.2 Representing records as maps
3.3 Manipulating data with generic functions
3.4 Calculating search results
3.5 Handling records of different types
Summary
4 State management
4.1 Multiple versions of the system data
4.2 Structural sharing
4.3 Implementing structural sharing
4.4 Data safety
4.5 The commit phase of a mutation
4.6 Ensuring system state integrity
4.7 Restoring previous states
Summary
5 Basic concurrency control
5.1 Optimistic concurrency control
5.2 Reconciliation between concurrent mutations
5.3 Reducing collections
5.4 Structural difference
5.5 Implementing the reconciliation algorithm
Summary
6 Unit tests
6.1 The simplicity of data-oriented test cases
6.2 Unit tests for data manipulation code
6.2.1 The tree of function calls
6.2.2 Unit tests for functions down the tree
6.2.3 Unit tests for nodes in the tree
6.3 Unit tests for queries
6.4 Unit tests for mutations
Moving forward
Summary
Part 2—Scalability
7 Basic data validation
7.1 Data validation in DOP
7.2 JSON Schema in a nutshell
7.3 Schema flexibility and strictness
7.4 Schema composition
7.5 Details about data validation failures
Summary
8 Advanced concurrency control
8.1 The complexity of locks
8.2 Thread-safe counter with atoms
8.3 Thread-safe cache with atoms
8.4 State management with atoms
Summary
9 Persistent data structures
9.1 The need for persistent data structures
9.2 The efficiency of persistent data structures
9.3 Persistent data structures libraries
9.3.1 Persistent data structures in Java
9.3.2 Persistent data structures in JavaScript
9.4 Persistent data structures in action
9.4.1 Writing queries with persistent data structures
9.4.2 Writing mutations with persistent data structures
9.4.3 Serialization and deserialization
9.4.4 Structural diff
Summary
10 Database operations
10.1 Fetching data from the database
10.2 Storing data in the database
10.3 Simple data manipulation
10.4 Advanced data manipulation
Summary
11 Web services
11.1 Another feature request
11.2 Building the insides like the outsides
11.3 Representing a client request as a map
11.4 Representing a server response as a map
11.5 Passing information forward
11.6 Search result enrichment in action
Delivering on time
Summary
Part 3—Maintainability
12 Advanced data validation
12.1 Function arguments validation
12.2 Return value validation
12.3 Advanced data validation
12.4 Automatic generation of data model diagrams
12.5 Automatic generation of schema-based unit tests
12.6 A new gift
Summary
13 Polymorphism
13.1 The essence of polymorphism
13.2 Multimethods with single dispatch
13.3 Multimethods with multiple dispatch
13.4 Multimethods with dynamic dispatch
13.5 Integrating multimethods in a production system
Summary
14 Advanced data manipulation
14.1 Updating a value in a map with eloquence
14.2 Manipulating nested data
14.3 Using the best tool for the job
14.4 Unwinding at ease
Summary
15 Debugging
15.1 Determinism in programming
15.2 Reproducibility with numbers and strings
15.3 Reproducibility with any data
15.4 Unit tests
15.5 Dealing with external data sources
Farewell
Summary
Appendix A—Principles of data-oriented programming
A.1 Principle #1: Separate code from data
A.1.1 Illustration of Principle #1
A.1.2 Benefits of Principle #1
A.1.3 Cost for Principle #1
A.1.4 Summary of Principle #1
A.2 Principle #2: Represent data with generic data structures
A.2.1 Illustration of Principle #2
A.2.2 Benefits of Principle #2
A.2.3 Cost for Principle #2
A.2.4 Summary of Principle #2
A.3 Principle #3: Data is immutable
A.3.1 Illustration of Principle #3
A.3.2 Benefits of Principle #3
A.3.3 Cost for Principle #3
A.3.4 Summary of Principle #3
A.4 Principle #4: Separate data schema from data representation
A.4.1 Illustration of Principle #4
A.4.2 Benefits of Principle #4
A.4.3 Cost for Principle #4
A.4.4 Summary of Principle #4
Conclusion
Appendix B—Generic data access in statically-typed languages
B.1 Dynamic getters for string maps
B.1.1 Accessing non-nested map fields with dynamic getters
B.1.2 Accessing nested map fields with dynamic getters
B.2 Value getters for maps
B.2.1 Accessing non-nested map fields with value getters
B.2.2 Accessing nested map fields with value getters
B.3 Typed getters for maps
B.3.1 Accessing non-nested map fields with typed getters
B.3.2 Accessing nested map fields with typed getters
B.4 Generic access to class members
B.4.1 Generic access to non-nested class members
B.4.2 Generic access to nested class members
B.4.3 Automatic JSON serialization of objects
Summary
Appendix C—Data-oriented programming: A link in the chain of programming paradigms
C.1 Time line
C.1.1 1958: Lisp
C.1.2 1981: Values and objects
C.1.3 2000: Ideal hash trees
C.1.4 2006: Out of the Tar Pit
C.1.5 2007: Clojure
C.1.6 2009: Immutability for all
C.2 DOP principles as best practices
C.2.1 Principle #1: Separate code from data
C.2.2 Principle #2: Represent data with generic data structures
C.2.3 Principle #3: Data is immutable
C.2.4 Principle #4: Separate data schema from data representation
C.3 DOP and other data-related paradigms
C.3.1 Data-oriented design
C.3.2 Data-driven programming
C.3.3 Data-oriented programming (DOP)
Summary
Appendix D—Lodash reference
index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W