Ola,
I am trying to understand how DOP would work through a JavaScript dominated lens. DOP seems to only offer a handful of examples, most of which are written in OOP based languages. My lack of experience with OOP makes it hard for me to translate these examples to something I understand.
After a bit of searching, i found this javascript example: https://blog.klipse.tech/dop/2021/04/01/dop-challenges.html
In particular, the first example stands out to me:
var libraryData = {
"name": "The smallest library on earth",
"address": "Here and now",
"catalog": {
"booksByIsbn": {
"978-1779501127": {
"isbn": "978-1779501127",
"title": "Watchmen",
"publicationYear": 1987,
"authorIds": ["alan-moore",
"dave-gibbons"],
"bookItems": [
{
"id": "book-item-1",
"rackId": "rack-17",
},
{
"id": "book-item-2",
"rackId": "rack-17",
}
]
}
},
"authorsById": {
"alan-moore": {
"name": "Alan Moore",
"bookIsbns": ["978-1779501127"]
},
"dave-gibbons": {
"name": "Dave Gibbons",
"bookIsbns": ["978-1779501127"]
}
}
},
"userManagement": {
"librarians": {
"franck@gmail.com" : {
"email": "franck@gmail.com",
"encryptedPassword": "bXlwYXNzd29yZA=="
}
},
"members": {
"samantha@gmail.com": {
"email": "samantha@gmail.com",
"encryptedPassword": "c2VjcmV0",
"isBlocked": false,
}
}
}
};
From the examples on the site, it seems like you create one global object with the initial state of your program. Then you use functions to read and write to this global object, similar to a database.
Is this the right way to think of DOP? Isn't using global objects generally considered a bad practice?
All this is very confusing to me, thanks for any anwsers!