Modeling Object-Oriented Systems
摘要
Before creating softwareObject-oriented programming, basicsclasssoftware, it is very helpful to have a representation of what the program is supposed to do. Consider a simple program that checks if a given number is a prime number. The requirement for this program is simply stated: given a positive integer, decide if it is a prime number. However, to create a program, some questions need to be answered: how will the number be given to us (through a keyboard, verbally, or in a file)? How does the program tell the user it has “decided” if the number is a prime? Is there any other information that the program should give us? These ambiguities can be avoided if we can agree on a standard template as follows: Input: A number typed in using the keyboard. Output: Print “Yes” on the screen if the number is prime; print “No” otherwise. This restatement in a simple standard format (sometimes referred to as the Input-Output model) gives us a clearer picture of what the program is required to do. We say that we have modeled the program requirements.