Suppose a Library module needs getBookLendings. Instead of hiding library state inside an object, pass LibraryData explicitly to a stateless function. The function operates on supplied data rather than persistent state stored in itself or its module. section 2.1 section 2.3
A stateless design separates the parts that hold information from the parts that manipulate it:
- Data entities hold members but no code. section 2.4
- Code modules aggregate functions without data members; each function receives the data it operates on explicitly. section 2.3
- Unlike traditional object-oriented methods, these functions do not treat object state as an implicit argument. section 2.6
- The separation makes the data and code easier to understand independently and supports flexible changes to requirements. section 2.4 section 2.6
Passing library state explicitly
class Library { static getBookLendings(libraryData, userId, memberId) { } } Here, libraryData is visible in the function signature rather than reached through this or another hidden object member. section 2.3
Use the diagram to see code modules and data entities as separate parts of one system. section 2.1













