Conversation
Notices
-
Embed this notice
Hey @ryo I've been reading through your "scams" sections, which is great, and had a question about OOP.
Are you okay with data as objects (related information being grouped together), or do you think the best approach is to flatten all of the data into a clean ERD database?
At one point I was seriously considering the functional language paradigm, but when I found out that their solution to data, was to push all the relationships and rules into the database, that didn't seem like a good solution xD (and their mantra of no mutating state, is undermined by just delegating it to a different layer of their program. It is like shutting down your coal power plant, but importing your power from another country that burns coal)
Overall though, I agree, procedural is easier to write, less error prone, and even when the final solution may need to be similar objects with various concurrent states, trying to write that first, is much more likely to fail xD
- 寮 likes this.
-
Embed this notice
@hazlin It really depends on the type of data.
If the data is fixed and unchangeable (except for editing the source code of course) (like the HP/attack/defense/speed values of a character), or changed each time you use it (like a contact form), then you can present it as objects, enums, or even variables inside of a function.
If data is changeable by the user (like a comment or a forum post), best is to use a database.
And if data is kind of changeable but not completely (like a list of URLs or a guestbook which can only be appended to), you can use a JSON file, an XML file, a CSV file, or even a plain text file, which you'd open up in the backend, put it into an array, and present it to the frontend.
And maybe make it append-only for some interaction.