database design - Decoupling using stored procedures at what cost? -
I was taught to reduce the code implementation with database implementation through the use of stored procedures, For example:
decoded DAO methods (C #)
User FindByName (string value); User FindByLogin (string value); User FindByEmail (string value); User FindByFoo (string value); User FindByBar (string value); Contrast with no-so-dekopple dao methods Find user (string ) ColumnName, string value);
This is the result of writing a lot of code (though, it assumes that most of these will be cut and paste), very few stored procedures are written and kept, but also added Code for database implementation
In this case, where is the line between good and impractical design practice?
The decompressing is not as bad as you anticipate. In your example, you have the possibility of FindByName () and FindByLogin () , and no option is available.
What exactly are you demanding a good fragmentation between your compiled code and the database, do not spread the stored procedures. Ideally It should be coded in such a way that not only will there be no change in your compiled code to change the contents of stored procs, but rather the whole database system think it like this- stored work The signature is like an interface, your compiled code does not care that the type and rules of the input and output remain the same.
Of course this is an ideal scenario and this does not mean that you have to do this, it can be exaggerated for your situation and can be completely engineered. A simple fuzzy FindBy () can be perfect to meet your current and future needs. Your application for database call structure can be as granular as you want it to be. But this does not mean that your FindBy (string columnname, string value)
is essentially a good option because it's going to bind you for a particular table or visual structure (even if you actually Calling stored procedure to implement it), which you are trying to avoid being separated from your code / database.
At the end of the day, it comes down to a compromise:
- Does it meet current requirements
- Is it necessary
- Is it worth it
- Is it worth it
- This is testable < / Ul>
Comments
Post a Comment