The last book Tony says:
"It seems it does not seem to improve the coupling relationship between different levels of code, look at previous cases, all calls are for the database layer through C # RunProc achieved, as if it itself acts as a barrier role, why the increase a useless layer delete_dept (1) do?
Your question very well. I will be more detailed answers to your questions.
Simply put, delete_dept semantics is more abstract than RunProc, not so much detail, so much easier packaging changes.
First, we from the user point of view, the local function or method when Runproc, that a more simple.
Yes, the function is a client, the function of the customer is its caller. We look at a function designed to good, critical look at the code on the client need not know the details are hidden.
Or in code as an example, when a client code, such as button_click () calls within
RunProc ("delete_dept", 1) we do require users to know that information RunProc:
1. This is a method of calling a stored procedure
2. The stored procedure name is delete_dept
3. This is the sector number is 1
Use code delete_dept (1) customer does not need to know to understand the information within RunProc 1,2. Of course, three or need to know.
Some of us detail, contrast of the two semantics:
|delete_dept (1)||I want to delete a department id = 1.|
|RunProc ("delete_dept", 1)||(Under the current database connection), call a stored procedure called delete_dept, parameters 1|
We all did our customers, for example, did the decoration of the host family, all know and decoration company, said, "Well, do not give me the details so much, I care about whether the results I wanted." Right?
Experience the following two semantics use delete_dept (1), and the use of RunProc ("delete_dept", 1) compared to which one gives you the customer more easily?
Thus, semantic analysis point of view, delete_dept (1) only said what, RunProc is how to do that. This is the difference in the level.
Secondly, we see changes in how the two packages. To know that the biggest problem is the software to adapt to change. A change in customer demand, the best of circumstances, we hope to resolve in one place, not everywhere changes.
So, what to delete a department change? I read the order, we find reference to several possible changes
1. Stored procedure name is inappropriate, needs changes
2. Need to consider more error handling
3. Require the user to give more parameters, such as allow users to enter their own names of the departments to verify.
In order to facilitate analysis, we assume that the program has three areas need to call delete departments. Pseudo code as follows:
RunProc ('delete_proc', id);
Due to space limitations, we can only give a small example of this: Please think a little less, these calls (such as button-click) may be found in a lot of unit.
Us to compare the two cases under the change in demand will result in the number of functions need to be updated:
|Changes point||Changes point|
To see that number, how well you and unknowingly. But when you replace the 3 100 times, perhaps not thought of.
|Changes point||Changes point|
That is, three changes occur simultaneously, the former need to modify the 103 function, which is 301 times. If only the first two took place, then the former 2 and the latter 200 - This is the difference - when the call to increase, we consider the problem must be entering a new perspective: in the case of less is called, the code almost no relations; When you call a lot, we must pinch pennies.
100 call is not what it is. Our checkError way I figure is the 1900 multiple calls, multiple calls to check the permissions are 990, not to mention the more basic functions.
The first two cases, the embodiment of our highest ideals has been a - a customer needs change, as long as the changes in one area can be completed. One such change is only to see the name of the see. Use delete_dept (1), than RunProc need to know the details better, therefore, when the details of the change occurs, the former easier to package changes.
However, some people will say, the third point is the situation changes a lot ah. Regardless of your package with the ah?
First of all, no matter how many references are only two points difference between a modification, it can be considered equivalent. Second, the package can be sealed only to the situation we are considering, not all cases. Zhezhongqingkuang Xia, the function due to the additional parameters, semantic changes have taken place, is not Jiaozuo delete_dept not necessarily a, this time Huanyaofengzhuang, Jiu reluctance of. Even the best packaging can not solve all the problems, we need to do is change the package as far as possible, and not all changes in packaging - which is never impossible.