OO design process: refinement problem definition

zhaozj2021-02-16  44

OO design process: Refining the key definition is direct payment

Allen Holub written editor, JavaWorld 2000 September

Content: Verification and refinement Do not ignore obvious errors listening to references about the author

This month I will continue to refine the question guide for educational software on Bank Of Allen last month.

When the problem is defined, I usually make a next step to build a vocabulary. In general, for those who are familiar with this field will immediately understand the meaning of the terminology, therefore do not need to be defined, but for terms with fuzzy meanings, or in a limited range in the current problems, this requires special purpose Define it.

In the problem manual, it is not appropriate to Gotcha. One word cannot refer to two different things, while two different words cannot refer to one thing. To do this, you must first establish a vocabulary. There is no need to define terms in the field of this problem. For example, if you are an accounting problem, you do not need to define credit or interest rates. However, the current problem is about cultivating, so terms such as credit need to be precisely defined.

The vocabulary is also helpful to our main goals, it can determine the abstraction of key issues. Avoid words and concepts in the vocabulary often appear in the body of the problem manual. For example, the passbook introduces the term transaction. (The concept of trading is important, although I didn't immediately realize this.)

It is also very helpful to join the implementation details in the vocabulary. It provides a place to record these details. In terms of itself, although it is not the problem of the problem. Those things that usually have a functional demand specification are often placed in implementation details.

The following is my first vocabulary and implementation details.

Glossary

The amount of money currently in the account is currently in the account. Bank parent loans deposit your account by banks instead of yourself. Deposit will put money in bank; increase your balance. Interest is a credit for your credit as you have been put on the bank. The interest is calculated daily, and the account is placed in the account ("principal") by putting the credit in the fixed ratio of the current account balance. If the interest rate is 10% / month, the balance is multiplied by (.10 / 30) to get daily interest. The passbook occurs on the job record and summary information of the transaction on an account. Children must get a passbook from banks. Take money from banks; reduce your balance. This part is not part of the problem manual for details. It's just a list I think of, I put it with the question manual.

When the program is running for the first time, the parent can set the password for themselves. From then on, you must know the password with parents. Parents can change the password at any time. Changing interest rate can take effect immediately, but it does not affect the previous balance. (The passbook is not necessarily (but) reflects the new interest rate, the interest rate is used for the deposit of interest rate changes, and even before that day.) The child must apply to the bank. Every time you give the children, you should update it. Parents must have measures to back up or banks. This can be a description of a simple file copy or more detailed description.

Verify and refine the problem manual If you are satisfied with your own reasonable question manual, then the next step is designed. I am grateful to my wife DJ, she is a programmer and is an expert in this area - mother. She discovered a variety of small grammar problems (I must admit that the original statement you just read is what I revised), and she found a serious flaw that I didn't realize. "You can't calculate interest like that" she pointed out. If you only calculate the monthly interest in accordance with the number of days in one month, the calculation of interest is too complicated. At the end of the month, you will get a big number than you will settle more interest than you. What you need here is the name of the month below 5%, which will provide you with a 5% effective interest rate. Ok. Back to the body.

In the current problem, two areas have appeared: cultivating, of course, finance from a small range of perspectives. I thought that I have a lot of money to understand, but I am obvious that I am wrong. So, I stopped the design, picked up the book until I fully understand the knowledge of this area and continue to design. This problem should appear earlier, if I don't omit the second step that the design must be omitted: After you are very familiar with the field of the problem (first phase) and before starting modeling (third phase), You must talk to our customers to find what they need. I don't need this, because I am already an expert in this area - as a father. I was wrong. If I talk to this expert with this, some people who have not entered the design of the design (for example, my wife), I may do it on the first part of the interest problem.

Don't ignore obvious errors, there are many other examples, but the most important thing is that I call "bathroom effect." This word is from "Dr. Dobb's Journal" (not published) Part of the beginning of the article. "Suppose we build a house like we do software." (We all lived in a house like Winchester mystery House). In short, to the end of the article, the last buyers went to the house for the first time (after the house was completely made). The buyers looked around with confused expressions. "Where is the bathroom?"

"Bathroom?" The subcontractor said, "There is no bathroom in the instructions. Now, add them to spend a lot of money; we have to cast the cement, knock open the wall. Why is we not covered in the backyard of the house?"

"What is the meaning of it is not in the explanation?" The buyer said to the Baba, "Who will be stupid to design a house without a bathroom?"

But in software design is often the problem. The user does not often mention what he needs, and these things are very basic for problems. Not the user "conceal me" as many programmers said. This is because the designer does not understand the correct problem in the field involved in the problem.

Don't nod to nod - listen when talking, listen! Don't interrupted. Remember everything that appears in the talks (that is not shallower), and accurate records are very important in every sentence in this area. I have participated in many conferences, and users have said a few hours, no one record. Subsequently, when the user leaves, no one can remember what is discussed. There is a bad tendency in a part of the programmer, which does not add to the user. It is known that the programmer distort the user's description to the programmer to think that the problem is like a description. They will renote some things, translating those areas involved into a more familiar statement, otherwise, they will have distortion and change. Often, remember that programmers' misunderstandings about the problem, rather than experts in this area's actual description.

Finally, remember that most users have a long history of self-righteous computer people, those people think that they know more than users. (Because the people are not in the direction, the city said to the farmer. "Are you not very smart, is it?" The farmer replied, "Maybe, but I have no lost.") The question is that many users have gone. If the programmer is not listening carefully, why will there be an obstacle in the conversation? You will have to break this series of obstacles.

In general, the main problem with the problem manual is at all in the details of the detail belong to it. Usually, in the fields involved in the problem, the problem manual is not a scientific term. You have to refer to the textbook or dictionary for this goal. But here, the answer is "Yes" because the difference in fixed interest rates and effective interest rates is that they are not part of the actual problem (this is raising). Experts in our field are parents or accountants. We don't develop a system that is used for bank or establish a module that tries to use to real bank. This is just the software written for the children, not a key banking system, so we can't take some experts on how to calculate interest. Interest calculation is an important part of the problem definition, so in fact it belongs to the problem manual. The problem of the problem is important to put on your hand. We don't want to solve the "bank" in a child's software. On the other hand, we don't want to miss any important details. If a general reader (assuming that they are experts in this area) require some information to understand the statement of the problem, then they belong to them. If these materials are important part of this field, we will not add it. In the current situation, if I really write a banking system, I certainly won't be guilty of defining the "effective interest rate". Because I can ask experts from experts in this area. (Due to the same reason, the designer must have enough understanding of the fields involved in the problem and this area. You can't design a accounting application unless you understand some knowledge of accounting - at least a smart line.)

So I find a fool financial book, I find out the name interest, and modify the definition of interest as:

Interest is a credit for your credit as you have been saving money in bank. Interest is added to the balance of daily. Like the real bank, the interest bank is calculated according to the month. Despite this, the interest earned every day must be registered on the passbook. The problem here is based on daily interests and monthly calculated interests produce different results. For example, if you start with $ 100 in the bank, the interest rate is 10%, according to the durability calculated every 10 days, after 10 days, you will have $ 110 on your account. On the other hand, if calculated according to the daily dietary calculations, it is calculated to calculate 10% of the interest rates to each day (1% / day), and the result is greater than the results calculated every 10 days.

Zero Least $ 100.00 Your $ 1.00 First Day Gold Interest $ 101.00 Interest $ 1.01 The Second Day This Gold Travel $ 102.01 Interest $ 1.02 Third Day This Gold Interest $ 103.03 Interest $ 1.03 Fourth Day This Gold Interest $ 104.06 Interest $ 1.04 Fifth Tianjin interest $ 105.10 Interest $ 1.05 Sixth Time Gold Interest $ 106.15 Interest $ 107.21 Leave $ 1.07 Eighth Day This Gold Interest $ 108.28 Interest $ 1.08 Ninth Day This Gold Interest $ 109.36 Interest $ 1.09 Tenth Tianjin interest $ 110.45 requires two interest rates to solve this problem: one is the kids know, the other is to use the bank.

Effective interest rate

The actual interest rate contains the results according to the reproained calculation. Assume that the name of the month is 5%, when calculating daily, the effective interest rate is 5.12%.

Nominal interest rate

The specified interest rate, removes the results according to the reproained calculation.

What is an effective interest rate, calculated according to daily repository, how is it getting 5% name monthly interest rate?

N = Nominal Interest Rate (.05) in decimal

P = periodic number of days (30 days)

E = effective interest rate expressed in decimals

formula:

E = (1 n / p) P-1 = .0512

The interest rate is 5%, according to the daily repository calculation, calculated by 5.12% per month, and the number of balances on the account after 30 days is the same.

When calculating daily, the nominal interest rate is how much, can get the effective interest rate of 5% / month?

N = Nominal interest rate expressed in decimals

P = periodic number of days (30 days)

E = Effective Interest Rate (.05) in decimal

formula:

N = p * (E 1) 1 / p -1 = .0488

Interest rate 4.88% according to daily repository calculations, calculated with 5% monthly diet, and after 30 days, the number of balances on the account is the same.

In one cycle, if only one dietary is calculated, the effective interest rate is the same as the nominal interest rate. That is, if one interest is calculated for a month, the monthly effective interest rate is the same interest rate. Simply put, the bank is announced is effective interest rate: "Your monthly money is 10%. This means that if you save $ 10 in the bank, the bank pays you $ 1 interest." Since interest is calculated according to daily repository , Calculate interest rates every day must be used in nominal interest rates (so that the interest rate calculated by the effective interest technique can be consistent with the interest rate). For example, it is assumed that it is 30 days a month, and the announcement (effective) month interest rate is 5%, and the (nominal) of the calculation is 4.88%. If you have $ 10 on your account, use the following algorithm, your account will have $ 10.50:

Double balance = 10.00;

INT days_IN_MONTH = 30;

Double

Effective_Rate = -> 05;

Double Nominal_Rate = days_in_month *

(Math.Pow (Effective_Rate 1,

1.0 / days_in_month)

-1);

for

(INT i = 0; i

BALANCE =

BALANCE BALANCE *

(nominal_rate / days_in_month));

It looks more reasonable now, let's do something that we have not completed yet. This is the theme of the next month.

Reference

Refer to the "OO Design Process" column of last month, start designing software. "Visit Winchester Mystery House to refer to the result of any design.

About the author Allen Holub works since 1979. He published articles in many magazines (Dr. Dobb's Monthly, Programmer Month, Byte, MSJ, and other magazines), and he is the editor of online magazine Javaworld. He has eight books that are appreciated, and the latest one (Taming Java Threads) tells the trap and defects of the Java thread. He has been engaged in designing and building an object-oriented software for a long time. After 8 years of C programmers, Allen gave up C steering Java program in early 1996. He has been teaching programming for Berkeley in 1982 (first C, then C and MFC, now OO design and Java programming). Allen provides Java technology and object-oriented public curriculum and specialized training. He also conducts object-oriented design consultation and commercial Java programming. Please visit Allen's website www.holub.com.

转载请注明原文地址:https://www.9cbs.com/read-27680.html

New Post(0)