Timeline for Is it best practice for each call to a SQL Server to be in its own class, even when using dependency injection?
Current License: CC BY-SA 4.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 27, 2023 at 9:39 | history | edited | Laiv | CC BY-SA 4.0 | deleted 1 character in body |
| May 27, 2023 at 8:04 | history | edited | Laiv | CC BY-SA 4.0 | added 104 characters in body |
| May 26, 2023 at 7:24 | history | edited | Laiv | CC BY-SA 4.0 | added 4 characters in body |
| May 23, 2023 at 13:29 | history | edited | Laiv | CC BY-SA 4.0 | deleted 601 characters in body |
| May 22, 2023 at 15:33 | comment | added | Laiv | Given two solutions, the "best" one is often in the middle, because it has the better tradeoff balance. For example, you might have a single function to cover up all possible sp calls. For example public void execute(storedPName, inputs[], output) (yes, SP often use output arguments). Both inputs and outputs are optional. It's not super sophisticated (no new classes and abstractions, only parameters), not the most OOed, but ey! quite easy to maintain and test and it's likely to cover 80% of the use cases. It's ugly, but it's functional. It's simple, but it's easy to test and mock | |
| May 22, 2023 at 15:25 | comment | added | Laiv | Don't know how stored procedures are implemented in SQL Server, but Oracle's SP can be grouped in packages. Packages are mere namespaces that can be easily translated into classes on the server side. So, we often have 1 class per package. We do it this way because when the number of stored procedures is small and we don't expect new ones that often. Think in corner cases. If we have a lot of them (this is a problem per se) and we can't get rid, worth thinking in abstractions that balance complexity, maintainability and capacity to change and extend over time. | |
| May 22, 2023 at 14:23 | comment | added | J. Mini | Excellent points on how the SQL ought to be, but I'm unfortunately stuck with the stored procedures that I've got. I think you're right about how the OCP does(n't) apply here, but I will have to think more about how the stored procedures should be put inside classes (e.g. how many classes?). | |
| May 22, 2023 at 11:19 | history | edited | Laiv | CC BY-SA 4.0 | added 300 characters in body |
| May 22, 2023 at 11:03 | history | edited | Laiv | CC BY-SA 4.0 | added 300 characters in body |
| May 22, 2023 at 10:39 | history | edited | Laiv | CC BY-SA 4.0 | added 11 characters in body |
| May 22, 2023 at 10:33 | history | edited | Laiv | CC BY-SA 4.0 | added 16 characters in body |
| May 22, 2023 at 10:28 | history | answered | Laiv | CC BY-SA 4.0 |