3 ms·
This brings fond memories of my early stages where i became fond of the method chaining pattern. I became fascinated by it when using doctrine. However the cod
by yrgulation 4y ago
This brings fond memories of my early stages where i became fond of the method chaining pattern. I became fascinated by it when using doctrine.
However the code you pasted is horrible and easily replaced by sql. Not only does someone else need to learn your custom logic functions and dtos but they also need to read stuff like “ x.relation.relation.relation.value”. I see your point in regards to dtos “automagically” updating queries, but if you have queries laying around everywhere thats another code smell. Basically, this is solving artificial problems.
The code you pasted can be replaced by a trivial query, which should table columns be renamed (i mean whats the frequency of that anyway, potentially another code smell), it would take less to update than updating all the dtos custom functions and the sausage code.
Edit: i am not belittling you, my point is that the code above solves self inflicted issues that could be written in a basic sql query with bound params. Basically you spend twice as much to write and maintain code that is simply not necessary.
- bottlepalm 4y agoTake a single line from my example 'x.relation.relation.relation.value' The SQL would be select w.value from x join y on y.relation=x.relation join z on z.relation=y.relation join w on w.relation=z.relation 1 line for the ORM, 5 lines of SQL. Please give an example where the SQL is less than what I typed in the previous comment. In addition compiling will validate the ORM code generates valid SQL. On the other hand compiling will not validate a SQL string. 'Custom functions' are just larger versions of the anonymous functions in my example. Very easy for other developers to go to the reference and understand.