You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a design problem: IConnection interface's method IConnection::query is coupled with a concrete implementation (Result) that is not extensible in any meaningful way.
We need to be able to provide our own result objects. Now since IConnection::query only allows returning Result and subclassing Result is useless because of private props and final methods, we are not able to do so.
Even implementing one's own IConnection will not work because of the interface.
Currently, the only possible solution is not to use the interface and proxy the calls - for the whole Connection and Result classes. This is tedious and leads to possible bugs. Plus any code expecting IConnection, Connection or Result is unusable.
Possible solution
private --> protectedand remove the final keywords
come up with an interface for Result objects
The actual use-case
Under special circumstances I do not want any exceptions to be thrown while using Dibi for DB querying. Without relying on the calling code to be responsible for wrapping the calls with try-catch blocks.
This is currently not possible due to the aforementioned design limitation.
It would normally be very easy to just extend the Connection and Result classes and wrap the internal parent calls with try-catch blocks.
This is arguably an edge-case,
but there's more use-cases for simply being able to extend Dibi. For example #357 demonstrates one where it would be easy to come up with own solution, but it's not possible as it stands now.
The text was updated successfully, but these errors were encountered:
This is a design problem:
IConnection
interface's methodIConnection::query
is coupled with a concrete implementation (Result
) that is not extensible in any meaningful way.We need to be able to provide our own result objects. Now since
IConnection::query
only allows returningResult
and subclassing Result is useless because ofprivate
props andfinal
methods, we are not able to do so.Even implementing one's own
IConnection
will not work because of the interface.Currently, the only possible solution is not to use the interface and proxy the calls - for the whole
Connection
andResult
classes. This is tedious and leads to possible bugs. Plus any code expectingIConnection
,Connection
orResult
is unusable.Possible solution
private
-->protected
and remove thefinal
keywordsResult
objectsThe actual use-case
Under special circumstances I do not want any exceptions to be thrown while using Dibi for DB querying.
Without relying on the calling code to be responsible for wrapping the calls with try-catch blocks.
This is currently not possible due to the aforementioned design limitation.
It would normally be very easy to just extend the
Connection
andResult
classes and wrap the internal parent calls with try-catch blocks.This is arguably an edge-case,
but there's more use-cases for simply being able to extend Dibi. For example #357 demonstrates one where it would be easy to come up with own solution, but it's not possible as it stands now.
The text was updated successfully, but these errors were encountered: