3 ms·
This seems to be an argument for or against simplicity. DAOs are just one pretty useful way to abstract database access. In the beginning they are almost always
by prepend 9y ago
This seems to be an argument for or against simplicity. DAOs are just one pretty useful way to abstract database access. In the beginning they are almost always too much for what you need as far as data access, but provide a consistent way to access persisted data. You don’t need them, but they are a safeguard against the future where it gets more complex and you don’t want to refactor a bunch of code.
There’s also multiple ways to implement and having a DAO that spits out transfer objects or value objects that aren’t connected to the db is perfectly fine and nice and OOP.
In some situations with complex data structures that require lots of transactions the DAO becomes more important.
In the end, Im not sure what the article complains about. Author shows a simple example as being bad, but doesn’t show an example where it’s needed. And the negative isn’t substantial.
If anything it gets you thinking more like the database system and that could be a pain if you switch off of relational or between systems that represent data differently.
- Finnucane 9y ago>In the end, Im not sure what the article complains about. It seems that the way an ORM abstracts talking to the database is not the way he would like it to happen. So he makes his own custom abstractions that involve sending raw sql strings instead. That's better?
- scarface74 9y agoI am always concerned when I see developers think they are their problem is it's own special snowflake that they need to write something custom to handle cross cutting concerns like configuration, database access, logging, security, etc. It makes it harder to ramp people up when you aren't using a popular package (preferably open source with an agreeable license) and there is usually only that one person in the company that understand it's weird quirks instead of being able to Google for a solution to a problem.
- Finnucane 9y agoI think is why a system like SQLAlchemy in Python is nice--if you really need to build something up from lower-level parts, you can, while still staying in the framework.