INFORME DE GESTIÓN CONSOLIDADO EJERCICIO 2011
1. HECHOS SIGNIFICATIVOS DEL EJERCICIO 2011
1.2 Evolución operativa del ejercicio .1 Negocio Regulado
The second of the four important problem-solving strategies for a com- puter scientist is logical reasoning. In Chapter 2 we discovered the close relationship of logic and computing in part resulting from representing true or false as a single bit of computer memory. But the usefulness of logi- cal reasoning extends well beyond the obvious connection to computer hardware. In fact, logic plays a role throughout the problem-solving pro- cess of software development.
As explained in Section 4.1, the functional requirements of a good problem definition are English forms of logical statements. This is evident in the use of English constructs such as if … then that translates into the logical implies operation.
Logic, as used in functional requirements and essential at the start of software problem solving, is equally necessary at the end. Virtually all computer software depends upon some form of logical instructions
because an executing program must make choices. The program con- trolling an online website must choose when to bill a customer. The program in your digital camera chooses how long to leave the shutter open when taking a picture. The program controlling your portable music player chooses which song to play next. Each of these choices is accomplished with computer instructions that are a programmatic form of logic. Most programming languages use a so-called IF instruction for this purpose:
• IF the user has struck the Confirm Purchase button, THEN initiate billing procedures.
• IF the camera sensor detects adequate exposure, THEN close the camera shutter.
• IF a song has just finished playing, THEN begin playing the next song in the playlist.
IF instructions force a programmer to think in logical ways, to consider a computer program as a complex collection of cause-effect relationships. A cause-effect relationship consists of a logical condition (the cause) that forces the program to perform some task (the effect). Figure 4.4 contains four cause-effect relationships commonly used by computer programs. Much of the work of computer programming is identifying these kinds of cause-effect relationships and translating them into instructions.
The ability to apply general rules to particular situations is known as deductive reasoning. This kind logical reasoning was made famous in the
Cause
Effect
User name and password have been entered Check to see if user’s name and password are valid
User clicks the close button on a window Remove the closed window from the display Laptop battery charge below 10% Pop up a window warning user of low power A new e-mail message arrives from the
Internet Ring a bell to notify the user
fiction of Sir Arthur Conan Doyle regarding a master at deduction named Sherlock Holmes. Following is an excerpt from The Sign of Four [1]. In this quote, Sherlock Holmes is talking to Dr. Watson explaining how he deduced that Watson had been to the post office recently.
“It is simplicity itself,” he [Holmes] remarked, chuckling at my surprise,—“so absurdly simple that an explanation is superflu- ous; and yet it may serve to define the limits of observation and of deduction. Observation tells me that you have a little reddish mold adhering to your instep. Just opposite the Seymour Street Office they have taken up the pavement and thrown up some earth which lies in such a way that it is difficult to avoid treading in it in enter- ing. The earth is of this peculiar reddish tint which is found, as far as I know, nowhere else in the neighborhood. So much is observa- tion. The rest is deduction.”
In this example, Holmes has deduced that Watson went to the post office by using rules such as (1) walking on freshly thrown earth tends to stick to shoes and (2) eliminating all other possibilities makes the remaining one true. Holmes applied these rules to this specific case, as do modern-day forensic experts who apply laws of science.
Deduction is often used when applying a mathematical axiom, law, or theorem to a particular case. For example, when considering a right tri- angle the Pythagorean theorem states that A2 + B2 = C2, where A and B
are the lengths of the triangle legs and C is the length of the hypotenuse. From the Pythagorean theorem we can deduce the distance from oppos- ing corners of a rectangular room that is 12 feet wide and 16 feet long is 20 feet. Since 122 + 162 = 400 = 202 deduction allows us to conclude that
the distance is 20 feet.
Computer scientists use deduction in many ways. For example, a com- mon rule in algorithms is that for certain problem solutions it is critical that one task occur before a second task; this idea of one thing follow- ing another is called a sequential form of execution because the tasks must occur in sequence. A software developer applies knowledge of this sequencing when encountering a problem such as the software to send an e-mail message. The task of sending a message must be preceded by the task of specifying the recipient’s address. A valid algorithm must ensure such task ordering.
For example, consider the integer variables itemCost and priceWith- Tax, and an algorithm consisting of the following sequence of three instructions:
priceWithTax ← 0 itemCost ← 100
priceWithTax ← itemCost + itemCost *.055
Executing these three instructions in sequence, that is to say from first to last and one at a time, results in the value 105.5 assigned to price- WithTax. However, rearranging the order of the same three instructions changes the algorithm. For example, consider the following algorithm, using the same three instructions:
itemCost ← 100
priceWithTax ← itemCost + itemCost *.055 priceWithTax ← 0
When this second algorithm executes, the resulting value assigned to priceWithTax is 0. Such subtleties point out the importance of under- standing even something as simple as the order of a sequence.
Often the “rules” used by computer scientists are more like patterns. As a first illustration of an algorithmic pattern, consider the problem of swap- ping the content of two variables. Figure 4.5 contains a pattern for a swap algorithm that swaps (interchanges) the content of two variables—varA and varB—using a third variable, temp.
To illustrate how a programmer can use this pattern as a kind of rule, suppose we have two variables: myDog and yourDog. Let’s further assume that myDog stores the name “Fido” initially, while yourDog stores “Rover.” Now suppose we want to swap these variables so they store the opposite names. We can use the pattern from Figure 4.5 as a general rule and deduce a correct algorithm by substituting variable names (myDog is substituted for varA and yourDog for varB). This substitution results in the following algorithm:
temp ← varA varA ← varB varB ← temp FIGURE 4.5 The swapping pattern.
temp ← myDog myDog ← yourDog yourDog ← temp
Lest you think that patterns are unimportant. Think what would happen if programmers did not know about the swap pattern and incorrectly assumed that the following algorithm would work to swap myDog and yourDog:
myDog←yourDog yourDog ← myDog
Swapping illustrates one kind of algorithmic pattern. Another, more general, pattern of software execution is known as repetition. Repetition is used anytime a task needs to be repeatedly performed. Repetition is com- mon in computer programs because one of the things that the computer can do well is to repeat some process, no matter how mundane, over and over. Software developers might recognize a pattern of repeating some- thing five times and apply this pattern to selecting a basketball team or to dealing a five-card poker hand.
Patterns are not restricted to forms of program execution. There are patterns for successful software testing, patterns for ways to provide bet- ter software security, patterns of different software performance. Indeed, most of this book can be viewed as an examination of foundational pat- terns of computation, including the patterns of logic found in Chapter 2. Another way to think about deduction is to consider it a form of spe- cialization. In deduction we apply our knowledge of more general rules, theorems, or patterns in order to solve a specific problem. So deduction works from the general to the specific. But it is equally important for a computer scientist to be able to work from the specific to the general; this is another application of logic, known as inductive reasoning.
Inductive reasoning occurs during the process of recognizing the gen- eralities. For example, many software designs use the idea of separating an algorithm into three components:
1. Software for communicating with the user 2. Software for retrieving and storing data
3. Software for calculating results based on user input and/or retrieved data
This pattern is so common that it is known as a 3-tiered software archi- tecture. How did we discover this pattern? Such patterns are usually noticed by astute observation that different successful solutions actually use the same general framework
Why is it important to begin to think in terms of 3-tiered software? The answer to this question lies in part with modern computer hardware divi- sions. Typically, you use your computer to perform a task such as change your personal data on a social networking site. You are communicating with your personal computer (Tier 1), while the changes must occur on the computer owned by the social network company (Tier 3). For effi- ciency and other reasons, large computer installations store most data on separate database computers (Tier 2). Since three different computers are likely to be involved in processing your social network pages, it makes sense that the software be subdivided into three parts or tiers.
Knowledge of the patterns used in computer science is not only impor- tant to computer scientists. For example, knowing about 3-tiered archi- tectures is helpful in understanding that performance of a computer application depends upon the performance of three different systems; any one of these systems could be a bottleneck. Similarly, the 3-tiered architec- ture has significant implications for data confidentiality.