Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 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?). Commented May 22, 2023 at 14:23
  • 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. Commented May 22, 2023 at 15:25
  • 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 Commented May 22, 2023 at 15:33