CSE 221: Software Development Using Components. Getting Started

Size: px
Start display at page:

Download "CSE 221: Software Development Using Components. Getting Started"

Transcription

1 CSE 221: Software Development Using Components Getting Started Timothy J. Long Department of Computer Science and Engineering The Ohio State University Columbus 2007 by Timothy J. Long

2 Table of Contents Unit 1: Some Assembly Required Unit 2: Catalogs, Components, and Objects Unit 3: Client View of a Component Values Unit 4: Client View of a Component Operations Unit 5: The Text Component Unit 6: Global Operations Part 1 Unit 7: Global Operations Part 2 Unit 8: Super Text Unit 9: The Id_Name_Table Component Unit 10: Iteration Unit 11: Testing Unit 12: Debugging Unit 13: Recursion Developing Recursive Algorithms Unit 14: Recursion Understanding Why It Works Unit 15: Extensions Unit 16: Templates Unit 17: Some Important Mathematical Functions Unit 18: Performance Analysis Index

3 Unit 1: Some Assembly Required Preview of Coming Attractions In this unit be sure to look for the organizing theme of the CSE 221/222/321 course sequence. Building by Assembling It s 9:00 am Monday morning, the first day of class for How To Build It 101. The instructor announces that each student will need to build a bicycle in order to pass the class. More than that, the bike assignment is due at the start of class on Friday, just four days from now! Well, an announcement like that would send most of us packing. But just as you are about to reach the door, on your way to drop How To Build It 101, the instructor begins to pass out catalogs of bike parts, things like tires, rims, frames, brakes, sprockets, and so forth. For the assignment you are allowed to order parts from the catalog, and they will be delivered the next day, guaranteed. So you calm down, return to your seat, make out a parts list, and begin to think that this assignment might actually be fun. The next week, while riding your new bike across campus, you think back to the experience of building the bike. Each component came with an excellent description of what it could do and of how to assemble it into a bike system, and you put together a really cool bike in a fairly short time. It was amazing how much you accomplished, and how quickly, by assembling the off-the-shelf components. Just then the dark thought of building the bike from scratch flashes through your mind and, shuddering at the thought, you almost run off the bike path. Quickly forcing your mind back to happier thoughts, you have one of life s aha experiences: The bike assignment was not just about building a bike; but rather, it was about the bigger idea of building by assembling. Other Unit 1-1

4 examples immediately come to your mind: automobiles, electronic appliances, buildings, personal computers, and lawn mowers. Yup, you say to yourself, building things out of off-the-shelf components is definitely the way to go. And so, you ll be pleased to learn that the fundamental organizing theme of the CSE 221/222/321 course sequence is building software out of off-the-shelf components. Instead of promoting the idea of building software from scratch, we ll emphasize the more modern idea of assembling components into high-quality software. But that s not the whole story. Since we are the computer scientists of the world, one of our major responsibilities will be to stock the shelves themselves with useful, high-quality components. So we ll spend a lot of time focusing on components, and we ll learn how to design, specify, implement, analyze, and reason about reusable software components Imagine a car rolling down the assembly line. List some of the components that will be used to assemble the car. Which of the components do you think are manufactured from scratch at the Still Awake? assembly plant? 1-2. We know that student housing can sometimes be a little lacking. Nonetheless, take a look around your room and list some of the components that were assembled to build your room Suppose you were to select components for your dream computer. What components do you think you ll need to select? Which of the components do you think are built from scratch by the computer company that puts the system together? Unit 1-2

5 Unit 2: Catalogs, Components, and Objects Preview of Coming Attractions In this unit be sure to look for different types of catalogs #include compiler directive RESOLVE_Foundation and the components it includes objects and their declaration put-to and get-from statements. They're In A Catalog Off-the-shelf software components live in catalogs. Which catalogs are available to a software developer depends on things like where the developer might be working or which classes the developer might be taking. In the CSE 221/222/321 sequence, you will be using three types of catalogs: the course catalogs, your personal catalog, and lab and closed lab catalogs. The course catalogs contains a special catalog called the RESOLVE_Catalog, which is an extensive collection of components to be used throughout the course sequence. At times the course catalog may contain some additional catalogs. Your personal catalog will contain components that you have implemented yourself and would like to house in a catalog for possible use. The lab and closed lab catalogs will contain components needed for specific assignments; for example, there might be a 221_Lab1 catalog containing special components needed for Lab 1 in 221. Unit 2-1

6 Ordering Components From A Catalog When developing software, you ll want to use specific components from the available catalogs. The process of ordering from a catalog is accomplished in C++ through use of #include compiler directives. The following code segment shows an example of a C++ main program ordering components from catalogs: Code Segment 2-1 #include "RESOLVE_Foundation.h" #include "CT/Sorting_Machine/Kernel_1_C.h" #include "CT/Queue/Kernel_2_C.h" program_body main ( ) { // code for body of main goes here } Notice that Code Segment 2-1 uses three separate #include compiler directives. To get some understanding of these statements, let s begin with the obvious the names RESOLVE_Foundation.h, CT/Sorting_Machine/Kernel_1_C.h, and CT/Queue/Kernel_2_C.h don t make a bit of sense. Not to worry, since you ll eventually be able to decipher names like these and, when you can, you ll be well on your way to computer geekdom. Just for now, here s a short explanation of these statements. #include CT/Sorting_Machine/Kernel_1_C.h orders a component named Sorting_Machine_Kernel_1_C and #include CT/Queue/Kernel_2_C.h orders a component named Queue_Kernel_2_C. For the time being, any further explanation of these two components can remain shrouded in mystery with no damage done. On the other hand, the name Unit 2-2

7 RESOLVE_Foundation.h orders something a little bit different it orders a whole bunch of components all at once. In particular, it orders the components: Integer for working with integer-valued data like 13 and Real for working with real-number-valued data like Boolean for working with logical-valued data (true or false) Character for working with character-valued data like 'a', 'b', and'?' Text for working with character-string-valued data like "help me" and "PLEASE!" Character_IStream for working with input-stream-valued data (either the keyboard or a file) Character_OStream for working with output-stream-valued data (either the monitor or a file) Record for working with aggregate-valued data like name, rank, and serial number Representation for implementing kernel components (to be explained later!). It s hard to imagine a program doing anything at all without making some use of some of the nine basic components just listed, so you can expect every program you write to include the compiler directive: #include "RESOLVE_Foundation.h" By the way, the official technical term for ordering a component from a catalog is bringing a component into scope. And, one final bit of technical detail the three #include directives in Code Segment 2-1 did not specify the catalog from which the components were to be taken. For example, the directive #include "CT/Queue/Kernel_2_C_Body.h" says that the program would like to use a component named Queue_Kernel_2_C, but does not say from which catalog the component should be taken. So here s what happens. The compilation process is set up so that the compiler first looks for the component in the current lab or closed lab catalog, then it looks for the component in your personal catalog, and Unit 2-3

8 last it looks for the component in the RESOLVE_Catalog. As soon as the desired component is found it's used and the compiler stops snooping around Suppose a program has the compiler directive #include "component A" and that there is a component A in both your personal catalog and in the RESOLVE_Catalog. Which Still Awake? component A will be used in the program? Why? 2-2. As in question 2-1, if there is a component A in the current closed lab catalog and in your personal catalog, which component A will be used? 2-3. Suppose a program wanted to keep track of whether a water valve is open. For this purpose, which component would the program order and from which catalog? Using Ordered Components If software developers go to the trouble of ordering a component, they probably would like to put it to use. Here is a short example putting the Character_IStream, Character_OStream, Integer, and Text components to use: Unit 2-4

9 Code Segment 2-2 #include "RESOLVE_Foundation.h" ordering RESOLVE - Foundation components program_body main () { object Character_IStream input; object Character_OStream output; object Text your_name; object Integer your_age; declaring objects input.open_external (""); output.open_external (""); connecting input to the keyboard and output to the screen output << "What is your name? "; input >> your_name; output << "What is your age? "; input >> your_age; prompting for input and then getting it output << "Hi " << your_name << '\n'; adding 3 items to output if ((13 <= your_age) and (your_age <= 18)) { output << "Oh no! A teenager!\n" << "So sorry!\n"; } else { output << "Congratulations! " << your_age << " is a fine age to be!\n"; } What does this do? } input.close_external (); output.close_external (); disconnecting input and output Unit 2-5

10 After ordering a component, the first thing that must be done to it is to declare objects corresponding to the component. Code Segment 2-2 has four object declarations: object Character_IStream input; object Character_OStream output; object Text your_name; object Integer your_age; You might be wondering What the heck is an object?. Well, objects are entities that can assume values and whose values can be altered by the application of operations to the object. So, your_age is the name of an object that can assume integer values, your_name is the name of an object that can assume text-string values, input is the name of an object that can assume input-stream values, and output is the name of an object that can assume output-stream values. Here s a quick explanation of the other statements in Code Segment 2-2: input.open_external (""); This statement opens the object input and connects it to the keyboard. Values entered by the user through the keyboard will become part of the value of input and can be extracted from input by applying appropriate operations to input. output.open_external (""); This statement opens the object output and connects it to the screen. When the program adds values to output, these values will appear on the screen. Unit 2-6

11 output << "What is your name? "; output << "What is your age? " The first statement adds the text string "What is your name? " to the value of output, and "What is your name? " also appears on the screen since output is connected to the screen. The effect of output << What is your age? is similar. By the way, the cryptic notation << is called the put-to operator, as in put the text string "What is your name? " to the object output. input >> your_name; input >> your_age; One of the earlier statements prompts the user to enter a name. The text string the user entered, at the keyboard, in response to the prompt became part of the value of input, since input is connected to the keyboard. The statement input >> your_name extracts from input what the user typed and it becomes the value of your_name. The effect of input >> your_age is similar. The notation >> is called the get-from operator, as in get a value for your_name from the object input. output << "Hi " << your_name << '\n'; This statement adds three things to the value of output: the text string "Hi ", the value of the object your_name, and the strange looking '\n'. Since output is connected to the screen, "Hi " and the value of the object your_name appear on the screen. C++ interprets the sequence of two characters, \n, as a single newline or end-ofline character. \n does not literally appear on the screen; instead, \n causes subsequent output to appear on a new line. Unit 2-7

12 The last statement in Code Segment 2-2 is an interesting if-else statement. See if you can figure out for yourself the effect of this statement, including explaining the two put-to statements Modify Code Segment 2-2 so that if the user enters an age between 0 and 3 inclusive, the program outputs a message like "My, just 2 years old! Still Awake? What a cute little baby." For all other ages, the program just outputs the boring message "Thanks for entering your age." In Code Segment 2-2, suppose the condition (13 <= your_age) and (your_age <= 18) is changed to (13 <= your_age) or (your_age <= 18). What message will the program output if the user enters 4 for their age? 15 for their age? 102 for their age? Unit 2-8

13 Unit 3: Client View of a Component Values Preview of Coming Attractions In this unit be sure to look for client view implementer/maintainer view the elements of a client view mathematical modeling abstract value, abstract state, abstract state space type and subtype abstract_instance class abstract and concrete components formal comment constraint programming language type initial value standard_abstract_operations constructor, destructor, swap, and clear operations What Can It Do For Me? It may seem obvious, but let's say it anyway: Before a software developer can use a component, the developer must understand the component! Specifically, the developer must understand what the component can do and how to use it. Understanding what a component can do and how to use it is called the client view of a component. We did not say that a software developer must, before using a component, understand how a component does what it does. And, there is a good reason why not. Imagine what it would be like if everyone who wanted to surf the web first had to read and understand the millions of lines of source code that explain in complete detail how a browser does its job. Or imagine what it would be like if everyone who uses first had to read and understand the millions of lines of source code that explain in complete detail how software does its job. Under those circumstances, cyberspace would be sparsely populated. Unit 3-1

14 Of course, those software developers who develop and maintain a software component do need to be aware of how the component does its job. Understanding how a component does its job is called the implementer/maintainer view of a component. Eventually we'll look at components from the implementer/maintainer view, but for now we are concerned only with the client view Name two things that you understand how to use and, yet, you do not understand the internal details of how these things work Consider two possibilities. First, people understand all details Still Awake? of how something works before they use it. Second, people figure out what to do to use something before trying to figure out all details of how something works. As a general rule, which of these two possibilities do you think is most prominent in society? Can you think of any reason why the same should not apply to using software components? What To Tell A Client? When programmers, acting as clients, use a component in a piece of software, they declare objects corresponding to the component and then use the objects. For example, looking back at code segment 2-2, we see the four object declarations object Character_IStream input; object Character_OStream output; object Text your_name; object Integer your_age; Obviously, the programmer of code segment 2-2 must understand how to use the objects input, output, your_name, and your_age. So, in order to describe what a component can do, we look at things from an object perspective. From this perspective, there are three things that must be described so that clients understand objects and how to use them: Unit 3-2

15 the values an object can assume the initial value of an object the operations that can be applied to an object. That's it. Together, these three things make up the interface of a component. How To Tell A Client? Clients are people and when a software component is described to a person, it would be kind of silly to speak in a programming language only. After all, programming languages are intended for communicating with computers, not people! This leaves us with a slight problem: What language should be used to describe components to clients, who are people? Before giving you our surprising answer to this question, let's make an observation. When describing a component to a client, the description must be understandable. If it is not, the client may not choose to use the component or, worse yet, may use the component incorrectly, possibly leading to software failure and even to loss of life, if the software happens to be safety critical. At the same time, we cannot sacrifice precision for understandability. Ambiguity in a description could have the same consequences as misunderstanding. To address the twin concerns of precision and understandability, we will use the language of mathematics to describe software components from the client perspective. Mathematics is well known for precision and, with a little practice, it will prove to be understandable as well. The idea of using mathematics to describe something of interest is called mathematical modeling, an idea that is centuries old. Simply stated, mathematicians create formal, mathematical descriptions (models) of phenomenon of interest. Then, the models can be manipulated using mathematical techniques in order to better understand the phenomenon and to make predictions about its behavior. A famous example is e = mc 2, an equation Unit 3-3

16 that models the relationship between energy and mass. In software development, you have been using the idea of mathematical modeling without even realizing it. For example, consider an expression like i + j, where i and j are objects of type Integer. All but the most warped among us think of i and j as plain old integers, like 82 and 9947, and think of + as being the usual addition of integers. But this is the client perspective, because the real story of how the computer is representing integer values (for example, 32-bit twos-complement representation) and adding them through electronic circuitry is quite different. Still Awake? 3-3. Give two additional examples of mathematical models. The examples need not be from computer science Why do you think scientists and engineers use mathematics to describe or model things that are of interest to them? Explain. Describing Values To A Client An Example Let's look at a description of a software component for a clock that keeps time using am and pm (as opposed to a 24-hour or military clock). (We know, you're thinking boring, boring, boring! But consider this: A software component for keeping the time should be about the same complexity as a component for keeping the date. And yet, do you remember all of the fuss over Y2K?) Remember, from the client perspective, we need only describe the values a clock object can assume, the initial value of a clock object, and the operations that can be applied to a clock object. In this unit we'll describe the values a clock object can assume, including the initial value, and in the next two units we'll describe the operations. The value of an object, when viewed through the mathematical model for the object, is called the abstract value or the abstract state of the object. The set all of abstract values that an object can assume is called the abstract state space of the object. So, what we are about to do is to describe the abstract state space of an am-pm-clock component; that is, the values that an am-pm clock can assume as seen through the eyes of a client. Unit 3-4

17 To get started, let's consider a typical clock face: am pm 12 : 57 : 17 A Clock Face Our task is to capture, through a mathematical model, the important features of such a clock face. The clocks we have in mind show the hour, minute, and second and whether it is am or pm. Thus, the state of such a clock is a particular value for the hour, a particular value for the minute, a particular value for the second, and a particular value for whether it is am or pm. So, in this case, the mathematical model will be fairly straightforward to write down. Abstract Kernel for AM_PM_Clock: Part 1 of a Client Description The background is set and we're ready to look at our first client description of a component. The entire description is presented in two parts: Part 1 is presented in this unit and it is concerned with the mathematical model for describing values of am-pm clock objects. Part 2 is presented in the next unit, and it is concerned with the operations that can be applied to am-pm clock objects. Here we go! Unit 3-5

18 // /* *\ // Abstract Instance: AM_PM_Clock_Kernel // /* */ #ifndef AI_AM_PM_CLOCK_KERNEL #define AI_AM_PM_CLOCK_KERNEL 1 /// /// Global Context /// /// /// Interface /// abstract_instance class AM_PM_Clock_Kernel { public: /*! math subtype HOUR_MODEL is Integer exemplar h constraint 1 <= h <= 12 math subtype MINUTE_SECOND_MODEL is Integer exemplar m constraint 0 <= m <= 59 math subtype AM_PM_CLOCK_MODEL is ( hours: HOUR_MODEL minutes: MINUTE_SECOND_MODEL seconds: MINUTE_SECOND_MODEL am: Boolean )!*/ standard_abstract_operations (AM_PM_Clock_Kernel); Compiler directives for the C++ compiler. To be discussed in later unit. abstract_instance signifies a client description; class is the C++ term for a component;am_pm_clock_kernel is the component name. Math definitions used to describe mathematical model of AM_PM_Clock values Every object described by AM_PM_Clock_Kernel has constructor, destructor, swap, and clear operations. /*!!*/ AM_PM_Clock_Kernel is modeled by AM_PM_CLOCK_MODEL initialization ensures self.hours = 12 and self.minutes = 0 and self.seconds = 0 and self.am = true Every object described by AM_PM_Clock_Kernel has this initial value. // AM_PM_CLOCK_KERNEL TO BE CONTINUED Unit 3-6

19 Whoa! That Was Different! We're pretty sure that the code in AM_PM_Clock_Kernel is different from what you are used to! Don't worry. We'll carefully work our way through the code, paying close attention to the idea of mathematical modeling and how it appears in the AM_PM_Clock_Kernel component. This example will become the model (sorry for the pun) for how we do mathematical modeling in software components. // /* *\ // Abstract Instance: AM_PM_Clock_Kernel // /* */ This is a comment (ignored by the compiler) telling us (the reader) that the component to be described is an Abstract Instance and that it's name is AM_PM_Clock_Kernel. The terms Abstract Instance and AM_PM_Clock_Kernel will be described shortly. #ifndef AI_AM_PM_CLOCK_KERNEL #define AI_AM_PM_CLOCK_KERNEL 1 These two lines are compiler directives, similar to #include. They're really off-topic for what we are discussing, so we'll delay their explanation until later. Don't worry, since what they mean and why they are needed are both easy to understand. /// /// Global Context /// This is another comment (ignored by the compiler) that we (the reader) can ignore for now, as well. We'll revisit Global Context later in the course sequence. Unit 3-7

20 /// /// Interface /// This comment announces the start of the stuff we care about as clients of this component; namely, the interface of the component. abstract_instance class AM_PM_Clock_Kernel Finally some real action! The keyword abstract_instance signifies that what follows is a client description of a component. Components providing client descriptions are called abstract components. In later examples we ll see the keyword concrete_instance signifying an implementer/maintainer description of a component. Components providing implementer/maintainer descriptions are called concrete components. class is the keyword C++ uses to denote a component. Finally, AM_PM_Clock_Kernel is our choice for the name of the component. Use of the unusual word Kernel in the component name AM_PM_Clock_Kernel will be described in the next unit. /*! denotes the beginning of a formal comment and!*/ denotes the end of a formal comment, as in /*! formal comment goes in here!*/ We refer to these as formal comments because the content of the comment is a formal mathematical specification written in mathematics. Warning: CSE 221 students will become bilingual, reading both mathematics and C++! The two languages read a bit differently, so you'll need to work at not confusing them. Also, notice that there are two formal comments in the component AM_PM_Clock_Kernel. Unit 3-8

21 math subtype HOUR_MODEL is Integer exemplar h constraint 1 <= h <= 12 This little piece of mathematics defines a mathematical model for hours. The syntax is a somewhat pretentious, but here s how you can read it. HOUR_MODEL is the name of a new mathematical subtype, and you can think of subtype as just a set of values. To say math subtype HOUR_MODEL is Integer says that the set of values for the subtype HOUR_MODEL will be all integers; that is, {0, +1, -1, +2, -2, }. But wait a minute! In a clock, how can the value of the hour be something like or 88? Shouldn t the value of an hour be between 1 and 12 inclusive? Yes it should, and that is the purpose of the statements: exemplar h constraint 1 <= h <= 12 exemplar h just means let h be an any variable of type HOUR_MODEL. The constraint then specifies that the value of h must satisfy the condition 1 <= h <= 12, which is exactly what we want for our mathematical model of the idea of hours. In general, the purpose of a constraint is to place additional restrictions on a set of values. Normally, the effect of a constraint is to throw away unwanted values from an original set of values. The next figure illustrates this for HOUR_MODEL. math subtype MINUTE_SECOND_MODEL is Integer exemplar m constraint 0 <= m <= 59 The definition of the MINUTE_SECOND_MODEL is similar to the definition of the HOUR_MODEL, and it just provides a mathematical model for the idea of minutes and of seconds. Unit 3-9

22 Integer HOUR_MODEL The Effect of a Constraint math subtype AM_PM_CLOCK_MODEL is ( hours: HOUR_MODEL minutes: MINUTE_SECOND_MODEL seconds: MINUTE_SECOND_MODEL am: Boolean ) AM_PM_CLOCK_MODEL is an interesting model. Values for this subtype are actually 4- tuples; that is, each value has four parts: one part, named hours, that can assume values of type HOUR_MODEL (integer values in the range 1 through 12 inclusive) one part, named minutes, that can assume values of type MINUTE_SECOND_MODEL (integer values in the range 0 through 59 inclusive) one part, named seconds, that can assume values of type MINUTE_SECOND_MODEL (integer values in the range 0 through 59 inclusive) one part, named am, that can assume values of type Boolean (true or false). Thus, we might write down a typical value of type AM_PM_CLOCK_MODEL as (2, 56, 24, true) meaning that the current time is 2:56:24 am. Notice that there is no constraint clause in the definition of AM_PM_CLOCK_MODEL. Unit 3-10

23 AM_PM_Clock_Kernel is modeled by AM_PM_CLOCK_MODEL initialization ensures self.hours = 12 and self.minutes = 0 and self.seconds = 0 and self.am = true This is the second formal comment in the AM_PM_Clock_Kernel component. The first formal comment defined three mathematical subtypes in order to define formally a mathematical model for the values that am-pm clocks can assume. That mathematical model was named AM_PM_CLOCK_MODEL. Importantly, there is another type floating around in this component, as well, and its name is AM_PM_Clock_Kernel, the same name as the component name. Being the name of a component (a C++ class), AM_PM_Clock_Kernel is considered to be a programming language type, not a mathematical type. The statement AM_PM_Clock_Kernel is modeled by AM_PM_CLOCK_MODEL is a crucial comment because it links together the two types: the mathematical model AM_PM_CLOCK_MODEL and the programming-language type AM_PM_Clock_Kernel. The statement essentially says Hey! If you have an object in your program described by AM_PM_Clock_Kernel and would like to know what values it can assume, take a look at the definition of AM_PM_CLOCK_MODEL. That s where you ll find your answer. The last part of this second formal comment is the sequence of statements: initialization ensures self.hours = 12 and self.minutes = 0 and self.seconds = 0 and self.am = true These statements specify the initial value, that all newly declared objects described by AM_PM_Clock_Kernel, will be given automatically. For example, if my_clock is such an object, then immediately after the declaration of my_clock the value of Unit 3-11

24 my_clock will be my_clock = (12, 0, 0, true); that is, my_clock.hours = 12, my_clock.minutes = 0, my_clock.seconds = 0, and my_clock.am = true. (Actually, we just slipped in some additional mathematical notation, the dot notation used to refer to the individual entries in a tuple value. The next figure explains dot notation.) a tuple value: clock = (12, 0, 0, true) dot notation for tuple entries: clock.hours clock.minutes clock.seconds clock.am Mathematical Notation for Tuple Entries standard_abstract_operations (AM_PM_Clock_Kernel); This statement specifies that every object described by AM_PM_Clock_Kernel automatically will have the following four operations: constructor destructor Swap (denoted &=) Clear. More generally, these four standard_abstract_operations are always available for all objects. The constructor operation is applied automatically to every newly declared object and it ensures that newly declared objects are given an initial value, as specified in the initialization ensures clause. Unit 3-12

25 The destructor operation is applied automatically to every declared object as the object goes out of scope (is no longer available to the program). The destructor operation ensures that all memory occupied by the object undergoing destruction is explicitly returned to the memory manager for possible reuse. The swap operation is used to exchange the values of two objects of the same type, and goes by the notation &=. For example, suppose that my_clock and your_clock are two objects described by AM_PM_Clock_Kernel. If my_clock =(2,17,38, true) and your_clock = (8,44,0,false), after execution of the swap statement my_clock &= your_clock; my_clock = (8,44,0,false) and your_clock = (2,17,38,true). The Clear operation can be used to set the value of an object to the initial value specified in the initialization ensures clause. For example, if my_clock = (2,17,38,true), then after the operation my_clock.clear ( ); my_clock = (12,0,0,true). Still Awake? 3-5. Give three example values that lie in the gray-shaded region in the figure The Effect of a Constraint There is no constraint in the definition of the math subtype AM_PM_CLOCK_MODEL. Why not? Unit Wrap-up Comment 1: For most of us, after looking at the picture of the clock face presented earlier in this unit, our intuition would tell us that the value of the hours portion of an ampm clock will be one of 1, 2, 3,, 12. Our intuition would be similar for minutes, Unit 3-13

26 seconds, and am. So, you might ask, what's the big deal with the mathematical model? It just says what is obvious! True enough this simple example of a mathematical model pretty much does state the obvious. However, for other software components, the values that objects can assume may not be obvious at all. In those instances, a mathematical model can be indispensable. Do not be misled by this simple example it is only a warm up. Comment 2: Comment 2 appears in the next figure. IT IS FUNDAMENTALLY IMPORTANT. Make sure you understand it completely. Put it into an accessible, longterm part of your memory! Client descriptions of components must describe the values that corresponding component objects can assume. Such descriptions can be presented in different ways. Good descriptions will be precise (no margin for error) and understandable (by human readers). The mechanism that is used in CSE 221/222/321 to make such precise and understandable descriptions is mathematical modeling. Comment 2 Comment 2 is FUNDAMENTALLY important! Make sure you understand it completely! Unit 3-14

27 Unit 4: Client View of a Component Operations Preview of Coming Attractions In this unit be sure to look for operation formal parameters/formal arguments actual parameters/actual arguments operation header/operation prototype alters and preserves parameter modes is_abstract operation contract requires clause/ensures clause distinguished parameter procedure and function abstract and concrete kernels tracing tables how to call functions Where We ve Been, Where We re Going We are learning about a proper way to describe components to component clients. Here s what we know so far: Clients need to understand what a component can do and how to use it, and do not need to understand how the component does what it does. To use a component, clients declare objects described by a component and then use the objects. To understand an object and how to use it, clients need to understand the interface; that is, the values the object can assume and the operations that can be applied to the object. To describe the values an object can assume, we define a mathematical model for the abstract state space of the object (the abstract values the object can assume). Unit 4-1

28 That s where we ve been, using an am-pm-clock component as a working example. What we ll do next is to learn about a proper way to describe the operations that can be applied to an object, and we will continue to use the clock example. When that s done, we ll have a good understanding of how components are described to clients. The Before and the After When components come from a catalog, they come equipped with a set of operations that can be applied to objects described by the component. Generally, operations are used to change the values of objects, so what clients need to understand is how an operation changes the values of objects. (It should be as plain as day that there is no way that clients can understand the changes operations make to the values of objects if they don t understand what values the objects can assume! That s why we first carefully define the mathematical model and related programming type for the component.) The essential idea of an operation is simple: An operation has a fixed number of formal parameters, sometimes called formal arguments. Clients supply an operation with objects, called actual parameters or actual arguments, that correspond to the formal parameters and that have incoming values. Depending on the incoming values, the operation changes the values of the objects resulting in outgoing values for the client s objects. That s it. So, our descriptions of operations will describe: the number and types of the formal parameters the expected incoming values of the client-supplied objects or actual parameters the resulting outgoing values of the client-supplied objects. Still Awake? 4-1. Carefully explain why a clock object having only the four standard operations would not be very useful. In particular, what values could such an object actually assume? Unit 4-2

29 Describing Operations An Example The first operation we ll look at is an operation that can be used to set the hours in a clock object. The figure titled Client Description of Set_Hours for AM_PM_Clock_Kernel provides the actual C++ code, which is part of AM_PM_Clock_Kernel, describing this operation. Client Description of Set_Hours for AM_PM_Clock_Kernel // CONTINUATION OF AM_PM_CLOCK_KERNEL operation header operation contract procedure Set_Hours ( preserves Integer new_hours ) is_abstract; Set_Hours is the name of the operation the parameter list /*! alters self is_abstract signifies a requires client description 1 <= new_hours <= 12 ensures self.hours = new_hours and self.minutes = #self.minutes and self.seconds = #self.seconds and self.am = #self.am!*/ ensures signifies a postcondition the operation must meet requires signifies a precondition clients must meet // AM_PM_CLOCK_KERNEL TO BE CONTINUED There is quite a bit to understand in this little operation description, so we ll take our time and discuss it carefully. Unit 4-3

30 The Operation Header The C++ code procedure Set_Hours ( preserves Integer new_hours ) is_abstract; is called the operation header or operation prototype. It specifies the name of the operation and the parameter list. The name is Set_Hours, appearing just after the keyword procedure. In this case the parameter list contains a single argument and has the following structure: Anatomy of the Parameter List preserves Integer new_hours parameter type of name of mode parameter parameter The preserves parameter mode is explained in the next section. The keyword is_abstract signifies that the actual implementation of the operation Set_Hours will appear in some other component (class). This is just what we want, since the component AM_PM_Clock_Kernel presents a client view of the operation Set_Hours, and clients do not need to know how operations do what they do. (The code that actually implements an operation is called the operation body.) The Operation Contract The second crucial piece of the client description of Set_Hours is the formal comment /*!!*/ alters self requires 1 <= new_hours <= 12 ensures self.hours = new_hours and self.minutes = #self.minutes and self.seconds = #self.seconds and self.am = #self.am Unit 4-4

31 describing a contract between clients of Set_Hours and the Set_Hours operation itself. To get you into the spirit of things, here is another example of a contract: requires students show up for class and stay awake ensures the instructor delivers an incredible lecture Contracts are agreements between clients of a service and providers of the service. Contracts have two parts: the requires clause specifies obligations that clients must meet and the ensures clause specifies obligations providers must meet. There is a little catch, however. Providers are obligated to meet their obligations only if clients meet their obligations. In the second example, the obligation of the students (the client) is to come to the class and stay awake. If students meet their obligations, the instructor (the provider) is then obligated to deliver an incredible lecture. On the other hand, if the students do not show up for class or fall asleep in class, the instructor can do anything she wants, since she is no longer bound to her obligations. So, the instructor might deliver an incredible lecture, or she might tell the story of Goldilocks and the Three Bears, or she might go to aerobics. In the case of programming-language operations, the requires clause specifies conditions that incoming parameter values must satisfy. Since clients provide incoming values, this is an obligation of the client. The ensures clause specifies conditions that outgoing parameter values must meet. This is the obligation of the operation. Of course, if a client provides incoming parameter values that do not satisfy the requires clause, then the operation can supply anything it wants for outgoing values, or it might even fail to terminate its execution! As you might expect, the operation Set_Hours can be used to set the hours of an ampm clock. Clients supply the desired new value for the hours through the formal Unit 4-5

32 parameter new_hours. This explains the client obligation for the incoming value of new_hours: requires 1 <= new_hours <= 12 Assuming that a client supplies a good value for new_hours, operation Set_Hours should change the value of the clock so that its hours are the same as the incoming value of new_hours. But what clock object is to be changed? There is no clock object in the parameter list! Well, this is where a self-centric C++-ism comes into play. The operation Set_Hours is specified in the class AM_PM_Clock_Kernel and is considered to be a class operation (or a method in C++ jargon). Class operations must be applied to class objects. This means that clients must invoke the operation Set_Hours with a statement like my_clock.set_hours (my_hours) or like your_clock.set_hours (your_hours), where my_clock and your_clock are the class objects, described by AM_PM_Clock_Kernel, to which Set_Hours will be applied. (More intuitively, they are the clocks whose values are to be changed.) So, my_clock and your_clock are actually additional parameters in the call to operation Set_Hours, they appear just before the name of the operation, and are referred to as the distinguished parameter. In the contract for an operation, the distinguished argument always goes by the name self. We re all set to examine the obligation of the Set_Hours operation: ensures self.hours = new_hours and self.minutes = #self.minutes and self.seconds = #self.seconds and self.am = #self.am The equation self.hours = new_hours just says that the outgoing value of self.hours will be the outgoing value of new_hours. (Remember that self refers to an object described by AM_PM_Clock_Kernel and that values of objects described by AM_PM_Clock_Kernel are 4-tuples.) The equation self.minutes = #self.minutes just says that the outgoing value of self.minutes will be equal to the incoming value of self.minutes. (Once again, we have sneaked in some new Unit 4-6

33 notation. The # symbol in #self.minutes signifies the incoming value of self.minutes.) All in all, the equation self.minutes = #self.minutes is just a fancy way of saying that the value of self.minutes does not change! The two equations self.seconds = #self.seconds and self.am = #self.am have a similar meaning. We re almost done, but nothing in the ensures clause says what the outgoing value of new_hours will be. Will it be 100? Or 66? The preserves parameter mode tells us the answer. preserves is a short hand way of saying, in an ensures clause, that new_hours = #new_hours. In other words, the incoming value of new_hours will also be the outgoing value. In this sense, then, the incoming value of new_hours is preserved. Finally, notice the little piece of the contract that says alters self. Remember that self is the distinguished parameter for Set_Hours. We always want to include a parameter mode for every parameter. In this case the parameter mode for self is alters. alters means that the incoming value of the parameter will be altered to an outgoing value, according to the description in the ensures clause. Thus, we should expect that the client-supplied am-pm-clock object for self will have its incoming value altered, by the operation Set_Hours, to an outgoing value How do we know that objects described by AM_PM_Clock_Kernel have values that are 4-tuples? 4-3. Do you think that requires clauses are concerned with incoming Still Awake? values or with outgoing values of parameters? Explain. If your answer is incoming values, explain why the requires clause for Set_Hours is not specified as 1 <= #new_hours <= Suppose that my_clock = (11,25,48,true) and that new_hours = 3. What will be the value of my_clock and new_hours after the operation my_clock.set_hours (new_hours)? Unit 4-7

34 Three More "Set" Operations An am-pm-clock component will need also operations to set the minutes, seconds, and am values of a clock object. Here are the specifications of two of these operations. The third operation is left for you to specify. Client Description of Set_Minutes and Set_AM Operations // CONTINUATION OF AM_PM_CLOCK_KERNEL procedure Set_Minutes ( preserves Integer new_minutes ) is_abstract; /*! alters self requires 0 <= new_minutes <= 59 ensures self.hours = #self.hours and self.minutes = new_minutes and self.seconds = #self.seconds and self.am = #self.am!*/ procedure Set_AM ( preserves Boolean am ) is_abstract; /*!!*/ alters self ensures self.hours = #self.hours and self.minutes = #self.minutes and self.seconds = #self.seconds and self.am = am // AM_PM_CLOCK_KERNEL TO BE CONTINUED Unit 4-8

35 4-4. Give the complete C++ code for the client description of a Set_Seconds Suppose that my_clock = (11,25,48,true) and that Still Awake? new_minutes = 31. What will be the value of my_clock and new_minutes afer the operation my_clock.set_minutes (new_minutes)? How about after the operation my_clock.set_minutes (52)? 4-6. Suppose that my_clock = (11,25,48,true) and am = true. What will be the value of my_clock and am afer the operation my_clock.set_am (am)? What Time Is It? We re almost finished with the first complete example of a client description of a component. So far, the clock operations include the four standard operations and the Set_Hours, Set_Minutes, Set_Seconds, and Set_AM operations. With this selection of operations, clock objects can be assigned any legal clock value, as specified in AM_PM_Clock_Kernel. But suppose you would like to know the time according to your_clock, where your_clock is an am-pm-clock object. How can you find out? None of the current operations allow us to inspect or observe the value of an am-pm-clock object. For this purpose, we need four additional operations: Get_Hours, Get_Minutes, Get_Seconds, and Is_AM. Following are the client descriptions of Get_Hours and Is_AM. We'll let you take care of Get_Minutes and Get_Seconds. Unit 4-9

36 Client Description of Get_Hours and Is_AM Operations // CONTINUATION OF AM_PM_CLOCK_KERNEL This operation is a function; it will return an Integer value. Get_Hours is the name of the operation. function Integer Get_Hours ( ) is_abstract; /*! preserves self ensures Get_Hours = self.hours!*/ No requires clause signifies no precondition for clients to meet. function Boolean Is_AM ( ) is_abstract; /*! preserves self ensures Is_AM = self.am!*/ The parameter list is empty. ensures explains the return value of the function. }; // THIS IS THE END OF AM_PM_CLOCK_KERNEL #endif // AI_AM_PM_CLOCK_KERNEL As usual, the description of these operations involves some new stuff. We ll work through the Get_Hours operation; Is_AM is similar. The function header is function Integer Get_Hours ( ) is_abstract Each of the set operations such as Set_Hours was specified as a procedure. On the other hand, the Get_Hours operation is specified as a function. The idea of a function is borrowed from mathematics. Here s an example: f (x, y) = x y y x. Clients of this little math function supply values for the parameters x and y, and the function returns the Unit 4-10

37 single value x y y x, computed from the supplied values for x and y. Notice that ƒ returns a single value without changing the values of parameters x and y. The essential idea of a function is: A function has a fixed number of formal parameters, sometimes called formal arguments. Clients supply a function with objects, called actual parameters or actual arguments, that correspond to the formal parameters and that have incoming values. Depending on the incoming values, the function computes a single value to be returned to the client and the function makes sure that outgoing values for the client s objects are the same as the incoming values. So, to describe a function to a client, we'll describe: the number and types of the formal parameters the expected incoming values of the client-supplied objects or actual parameters the type of the resulting single value the function is computing for the client the resulting single value the function is computing for the client. We can now understand the structure of the function header for Get_Hours: Anatomy of the Function Header function Integer Get_Hours ( ) is_abstract keyword type of name of parameter keyword signifying the return the list signifying a function value function client description 4-7. What is the type of the return value for the function Is_AM? Explain why this is the type. Still Awake? Unit 4-11

38 The function contract is /*! preserves self ensures Get_Hours = self.hours!*/ Notice anything unusual? To start with, there is no requires clause! With a little explanation, this is understandable. Since the parameter list is empty, the only formal parameter for Get_Hours is the distinguished argument self, an object with a value described by AM_PM_Clock_Kernel. Whatever clock value a client might supply for self, Get_Hours will be able to return the hours portion of the value. So, there is no need to impose any restrictions on incoming values. The description of outgoing values is quite simple since self is the only parameter and Get_Hours is a function. Remember that functions do not change the values of any of their parameters. So we know, just from the fact that Get_Hours is a function, that self = #self; that is, that self is preserved. Last, the name of the function appears in the ensures clause: Get_Hours = self.hours This will always be the case for all functions. We simply let the name of the function, in the ensures clause, stand for the single value to be returned by the function. A good way to read the equation Get_Hours = self.hours is the value to be returned by Get_Hours is self.hours. Still Awake? operation Explain how to read the ensures clause of Is_AM In the function Is_AM, what is the outgoing value of self? Provide a complete client description of the Get_Minutes operation Provide a complete client description of an Get_Seconds Unit 4-12

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share. LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.

More information

[Refer Slide Time: 05:10]

[Refer Slide Time: 05:10] Principles of Programming Languages Prof: S. Arun Kumar Department of Computer Science and Engineering Indian Institute of Technology Delhi Lecture no 7 Lecture Title: Syntactic Classes Welcome to lecture

More information

How to Study Mathematics Written by Paul Dawkins

How to Study Mathematics Written by Paul Dawkins How to Study Mathematics Written by Paul Dawkins Before I get into the tips for how to study math let me first say that everyone studies differently and there is no one right way to study for a math class.

More information

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python Introduction Welcome to our Python sessions. University of Hull Department of Computer Science Wrestling with Python Week 01 Playing with Python Vsn. 1.0 Rob Miles 2013 Please follow the instructions carefully.

More information

Introduction to Python

Introduction to Python WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

More information

Writing in the Computer Science Major

Writing in the Computer Science Major Writing in the Computer Science Major Table of Contents Introduction... 2 Statement of Purpose... 2 Revision History... 2 Writing Tasks in Computer Science... 3 Documentation... 3 Planning to Program:

More information

Introduction to Open Atrium s workflow

Introduction to Open Atrium s workflow Okay welcome everybody! Thanks for attending the webinar today, my name is Mike Potter and we're going to be doing a demonstration today of some really exciting new features in open atrium 2 for handling

More information

Compass Interdisciplinary Virtual Conference 19-30 Oct 2009

Compass Interdisciplinary Virtual Conference 19-30 Oct 2009 Compass Interdisciplinary Virtual Conference 19-30 Oct 2009 10 Things New Scholars should do to get published Duane Wegener Professor of Social Psychology, Purdue University Hello, I hope you re having

More information

Part 1 Foundations of object orientation

Part 1 Foundations of object orientation OFWJ_C01.QXD 2/3/06 2:14 pm Page 1 Part 1 Foundations of object orientation OFWJ_C01.QXD 2/3/06 2:14 pm Page 2 1 OFWJ_C01.QXD 2/3/06 2:14 pm Page 3 CHAPTER 1 Objects and classes Main concepts discussed

More information

Curriculum Map. Discipline: Computer Science Course: C++

Curriculum Map. Discipline: Computer Science Course: C++ Curriculum Map Discipline: Computer Science Course: C++ August/September: How can computer programs make problem solving easier and more efficient? In what order does a computer execute the lines of code

More information

Introduction to Python

Introduction to Python Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment

More information

Glossary of Object Oriented Terms

Glossary of Object Oriented Terms Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction

More information

>> My name is Danielle Anguiano and I am a tutor of the Writing Center which is just outside these doors within the Student Learning Center.

>> My name is Danielle Anguiano and I am a tutor of the Writing Center which is just outside these doors within the Student Learning Center. >> My name is Danielle Anguiano and I am a tutor of the Writing Center which is just outside these doors within the Student Learning Center. Have any of you been to the Writing Center before? A couple

More information

PGR Computing Programming Skills

PGR Computing Programming Skills PGR Computing Programming Skills Dr. I. Hawke 2008 1 Introduction The purpose of computing is to do something faster, more efficiently and more reliably than you could as a human do it. One obvious point

More information

Hypercosm. Studio. www.hypercosm.com

Hypercosm. Studio. www.hypercosm.com Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

Appendix... B. The Object Constraint

Appendix... B. The Object Constraint UML 2.0 in a Nutshell Appendix B. The Object Constraint Pub Date: June 2005 Language The Object Constraint Language 2.0 (OCL) is an addition to the UML 2.0 specification that provides you with a way to

More information

CAs and Turing Machines. The Basis for Universal Computation

CAs and Turing Machines. The Basis for Universal Computation CAs and Turing Machines The Basis for Universal Computation What We Mean By Universal When we claim universal computation we mean that the CA is capable of calculating anything that could possibly be calculated*.

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

5 Group Policy Management Capabilities You re Missing

5 Group Policy Management Capabilities You re Missing 5 Group Policy Management Capabilities You re Missing Don Jones 1. 8 0 0. 8 1 3. 6 4 1 5 w w w. s c r i p t l o g i c. c o m / s m b I T 2011 ScriptLogic Corporation ALL RIGHTS RESERVED. ScriptLogic, the

More information

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved. 1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,

More information

Club Accounts. 2011 Question 6.

Club Accounts. 2011 Question 6. Club Accounts. 2011 Question 6. Anyone familiar with Farm Accounts or Service Firms (notes for both topics are back on the webpage you found this on), will have no trouble with Club Accounts. Essentially

More information

Computer Science, Maths, Raspberry Pi

Computer Science, Maths, Raspberry Pi Computer Science, Maths, Raspberry Pi Alan Mycroft Computer Laboratory, University of Cambridge http://www.cl.cam.ac.uk/users/am/ and Raspberry Pi Foundation http://www.raspberrypi.org Sheffield Cutlers

More information

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration Developer Web Age Solutions Inc. USA: 1-877-517-6540 Canada: 1-866-206-4644 Web: http://www.webagesolutions.com Chapter 6 - Introduction

More information

Lab 9. Spam, Spam, Spam. Handout 11 CSCI 134: Spring, 2015. To gain experience with Strings. Objective

Lab 9. Spam, Spam, Spam. Handout 11 CSCI 134: Spring, 2015. To gain experience with Strings. Objective Lab 9 Handout 11 CSCI 134: Spring, 2015 Spam, Spam, Spam Objective To gain experience with Strings. Before the mid-90s, Spam was a canned meat product. These days, the term spam means just one thing unwanted

More information

Software Engineering Concepts: Testing. Pointers & Dynamic Allocation. CS 311 Data Structures and Algorithms Lecture Slides Monday, September 14, 2009

Software Engineering Concepts: Testing. Pointers & Dynamic Allocation. CS 311 Data Structures and Algorithms Lecture Slides Monday, September 14, 2009 Software Engineering Concepts: Testing Simple Class Example continued Pointers & Dynamic Allocation CS 311 Data Structures and Algorithms Lecture Slides Monday, September 14, 2009 Glenn G. Chappell Department

More information

Ep #19: Thought Management

Ep #19: Thought Management Full Episode Transcript With Your Host Brooke Castillo Welcome to The Life Coach School podcast, where it s all about real clients, real problems and real coaching. And now your host, Master Coach Instructor,

More information

GAcollege411 Site Overview Transcript

GAcollege411 Site Overview Transcript GAcollege411 Site Overview Transcript College Student Hey little man. High School Student What!!? UGH! Don t call me that! So, home for Spring Break, how s college going? College Student Oh, pretty good,

More information

Setting up your web hosting and installing wordpress

Setting up your web hosting and installing wordpress Setting up your web hosting and installing wordpress Meet your new best friend: WordPress! If you've spent any time online in the past few years, you may have heard the term "WordPress" thrown around.

More information

What does student success mean to you?

What does student success mean to you? What does student success mean to you? Student success to me means to graduate with a B average with no failing grades. Ferris is ridicules tuition rates don t affect me since I was fortunate enough to

More information

Mike: Alright welcome to episode three of Server Talk, I m here with Alexey. I m Mike. Alexey, how are things been going, man?

Mike: Alright welcome to episode three of Server Talk, I m here with Alexey. I m Mike. Alexey, how are things been going, man? Mike: Alright welcome to episode three of Server Talk, I m here with Alexey. I m Mike. Alexey, how are things been going, man? Alexey: They re doing pretty good. Yeah, I don t know, we ve launched two

More information

Problem Solving Basics and Computer Programming

Problem Solving Basics and Computer Programming Problem Solving Basics and Computer Programming A programming language independent companion to Roberge/Bauer/Smith, "Engaged Learning for Programming in C++: A Laboratory Course", Jones and Bartlett Publishers,

More information

PHP Debugging. Draft: March 19, 2013 2013 Christopher Vickery

PHP Debugging. Draft: March 19, 2013 2013 Christopher Vickery PHP Debugging Draft: March 19, 2013 2013 Christopher Vickery Introduction Debugging is the art of locating errors in your code. There are three types of errors to deal with: 1. Syntax errors: When code

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]

More information

How to Get of Debt in 24 Months

How to Get of Debt in 24 Months www.steamenginefinancialcoaching.com How to Get of Debt in 24 Months by John Bonesio, Financial Coach How to Get Out of Debt in 24 Months There are lots of debt solutions out there. You may have heard

More information

Database Management System Prof. D. Janakiram Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Database Management System Prof. D. Janakiram Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. Database Management System Prof. D. Janakiram Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. 23 Concurrency Control Part -4 In the last lecture, we have

More information

10 Java API, Exceptions, and Collections

10 Java API, Exceptions, and Collections 10 Java API, Exceptions, and Collections Activities 1. Familiarize yourself with the Java Application Programmers Interface (API) documentation. 2. Learn the basics of writing comments in Javadoc style.

More information

Equity Value, Enterprise Value & Valuation Multiples: Why You Add and Subtract Different Items When Calculating Enterprise Value

Equity Value, Enterprise Value & Valuation Multiples: Why You Add and Subtract Different Items When Calculating Enterprise Value Equity Value, Enterprise Value & Valuation Multiples: Why You Add and Subtract Different Items When Calculating Enterprise Value Hello and welcome to our next tutorial video here. In this lesson we're

More information

Objectives. Python Programming: An Introduction to Computer Science. Lab 01. What we ll learn in this class

Objectives. Python Programming: An Introduction to Computer Science. Lab 01. What we ll learn in this class Python Programming: An Introduction to Computer Science Chapter 1 Computers and Programs Objectives Introduction to the class Why we program and what that means Introduction to the Python programming language

More information

Scenic Video Transcript Direct Cash Flow Statements Topics. Introduction. Purpose of cash flow statements. Level 1 analysis: major categories

Scenic Video Transcript Direct Cash Flow Statements Topics. Introduction. Purpose of cash flow statements. Level 1 analysis: major categories Cash Flow Statements» What Do I See?» Direct Cash Flow Statements» Scenic Video http://www.navigatingaccounting.com/video/scenic-direct-cash-flow-statements Scenic Video Transcript Direct Cash Flow Statements

More information

3 Improving the Crab more sophisticated programming

3 Improving the Crab more sophisticated programming 3 Improving the Crab more sophisticated programming topics: concepts: random behavior, keyboard control, sound dot notation, random numbers, defining methods, comments In the previous chapter, we looked

More information

Computing Concepts with Java Essentials

Computing Concepts with Java Essentials 2008 AGI-Information Management Consultants May be used for personal purporses only or by libraries associated to dandelon.com network. Computing Concepts with Java Essentials 3rd Edition Cay Horstmann

More information

IP Subnetting: Practical Subnet Design and Address Determination Example

IP Subnetting: Practical Subnet Design and Address Determination Example IP Subnetting: Practical Subnet Design and Address Determination Example When educators ask students what they consider to be the most confusing aspect in learning about networking, many say that it is

More information

E-mail Marketing for Martial Arts Schools:

E-mail Marketing for Martial Arts Schools: E-mail Marketing for Martial Arts Schools: Tips, Tricks, and Strategies That Will Send a Flood of New Students into Your School Practically Overnight! By Michael Parrella CEO of Full Contact Online Marketing

More information

16.1 DataFlavor. 16.1.1 DataFlavor Methods. Variables

16.1 DataFlavor. 16.1.1 DataFlavor Methods. Variables In this chapter: DataFlavor Transferable Interface ClipboardOwner Interface Clipboard StringSelection UnsupportedFlavorException Reading and Writing the Clipboard 16 Data Transfer One feature that was

More information

Goal: Practice writing pseudocode and understand how pseudocode translates to real code.

Goal: Practice writing pseudocode and understand how pseudocode translates to real code. Lab 7: Pseudocode Pseudocode is code written for human understanding not a compiler. You can think of pseudocode as English code that can be understood by anyone (not just a computer scientist). Pseudocode

More information

Spring 2013 Structured Learning Assistance (SLA) Program Evaluation Results

Spring 2013 Structured Learning Assistance (SLA) Program Evaluation Results Crafton Hills College RRN 682 July 2013 Research Brief Spring 2013 Structured Learning Assistance (SLA) Program Evaluation Results Prepared by Lorena Guadiana Summary of Main Findings 85% of respondents

More information

Chapter 2. My Early Days Trading Forex

Chapter 2. My Early Days Trading Forex Chapter 2 My Early Days Trading Forex I want to talk about my early days as a Forex trader because I m hoping that my story will be something you can relate to. So it doesn t really matter if you are brand

More information

But have you ever wondered how to create your own website?

But have you ever wondered how to create your own website? Foreword We live in a time when websites have become part of our everyday lives, replacing newspapers and books, and offering users a whole range of new opportunities. You probably visit at least a few

More information

Writing Simple Programs

Writing Simple Programs Chapter 2 Writing Simple Programs Objectives To know the steps in an orderly software development process. To understand programs following the Input, Process, Output (IPO) pattern and be able to modify

More information

Todd: Kim: Todd: Kim: Todd: Kim:

Todd: Kim: Todd: Kim: Todd: Kim: Todd: [0:00:18] Hey everybody, welcome to another edition of The Prosperity Podcast, this is No BS Money Guy Todd Strobel. Once again, we have my cohost, bestselling financial author Kim Butler with us,

More information

THE STORY OF TRACY BEAKER BACK AND BAD by Mary Morris

THE STORY OF TRACY BEAKER BACK AND BAD by Mary Morris THE STORY OF TRACY BEAKER BACK AND BAD by Mary Morris Where s the butter? Right under your nose. Not in the puddle! Hey, hey, hey! That s not for lunch! Fine time to be defrosting the freezer! You told

More information

FREE REPORT: Don t Be Embarrassed It Is NOT Your Fault!

FREE REPORT: Don t Be Embarrassed It Is NOT Your Fault! FREE REPORT: The Top 5 Tax Secrets The IRS Doesn t Want You To Know And How To Use Them To Reduce Your Stress And Save You Money ESPECIALLY During Tough Economic Times Guaranteed! Dear Taxpayer, Believing

More information

Math Matters: Why Do I Need To Know This?

Math Matters: Why Do I Need To Know This? Math Matters: Why Do I Need To Know This? Bruce Kessler, Department of Mathematics Western Kentucky University Episode Fourteen 1 Annuities Investment strategies Objective: To illustrate how knowing the

More information

Building a Multi-Threaded Web Server

Building a Multi-Threaded Web Server Building a Multi-Threaded Web Server In this lab we will develop a Web server in two steps. In the end, you will have built a multi-threaded Web server that is capable of processing multiple simultaneous

More information

Management Information System Prof. Biswajit Mahanty Department of Industrial Engineering & Management Indian Institute of Technology, Kharagpur

Management Information System Prof. Biswajit Mahanty Department of Industrial Engineering & Management Indian Institute of Technology, Kharagpur Management Information System Prof. Biswajit Mahanty Department of Industrial Engineering & Management Indian Institute of Technology, Kharagpur Lecture - 02 Introduction Part II Welcome to all of you

More information

HOUR 3 Creating Our First ASP.NET Web Page

HOUR 3 Creating Our First ASP.NET Web Page HOUR 3 Creating Our First ASP.NET Web Page In the last two hours, we ve spent quite a bit of time talking in very highlevel terms about ASP.NET Web pages and the ASP.NET programming model. We ve looked

More information

MITI Coding: Transcript 5

MITI Coding: Transcript 5 1 MITI Coding: Transcript 5 T: Randy, thanks for coming in today. I wonder if it would be ok if I shared just a few facts with you that I ve gotten from the intake worker. And then we can go on to talk

More information

IN THE HANDS OF TIME

IN THE HANDS OF TIME MATHS B-DAY 2006 Friday 24 November IN THE HANDS OF TIME The Maths B-Day is sponsored by and Maths B-day 2006-1- Wiskunde B-dag 2006 0 Introduction The maths B-day assignment this year is totally focused

More information

Reputation Marketing

Reputation Marketing Reputation Marketing Reputation Marketing Welcome to our training, We will show you step-by-step how to dominate your market online. We re the nation s leading experts in local online marketing. The proprietary

More information

6.1. Example: A Tip Calculator 6-1

6.1. Example: A Tip Calculator 6-1 Chapter 6. Transition to Java Not all programming languages are created equal. Each is designed by its creator to achieve a particular purpose, which can range from highly focused languages designed for

More information

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science Program Schedule CTech Computer Science Credits CS101 Computer Science I 3 MATH100 Foundations of Mathematics and

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and: Binary Search Trees 1 The general binary tree shown in the previous chapter is not terribly useful in practice. The chief use of binary trees is for providing rapid access to data (indexing, if you will)

More information

Profiles of Mechanical Engineers

Profiles of Mechanical Engineers Profiles of Mechanical Engineers Alex Burkat, P.E. Principal Mechanical Engineer Walt Disney Imagineering Glendale, CA Education: MS, Mechanical Engineering, Ohio State University Honors Diploma, Moscow

More information

River Dell Regional School District. Computer Programming with Python Curriculum

River Dell Regional School District. Computer Programming with Python Curriculum River Dell Regional School District Computer Programming with Python Curriculum 2015 Mr. Patrick Fletcher Superintendent River Dell Regional Schools Ms. Lorraine Brooks Principal River Dell High School

More information

7 Secrets To Websites That Sell. By Alex Nelson

7 Secrets To Websites That Sell. By Alex Nelson 7 Secrets To Websites That Sell By Alex Nelson Website Secret #1 Create a Direct Response Website Did you know there are two different types of websites? It s true. There are branding websites and there

More information

Email Etiquette (Netiquette) Guidance

Email Etiquette (Netiquette) Guidance Email Etiquette (Netiquette) Guidance January 2007 Email Etiquette (Netiquette) Guidance January 2007-1/13 Version Control Version Author(s) Replacement Date 1.0 Timothy d Estrubé Information Governance

More information

Getting ahead online. your guide to. GOL412_GBBO brochure_aw5.indd 1 10/2/10 10:10:01

Getting ahead online. your guide to. GOL412_GBBO brochure_aw5.indd 1 10/2/10 10:10:01 1 Getting ahead online your guide to GOL412_GBBO brochure_aw5.indd 1 10/2/10 10:10:01 2 Welcome to Getting British Business Online Whether you re totally new to the Internet or already have a website,

More information

Cryptography and Network Security Department of Computer Science and Engineering Indian Institute of Technology Kharagpur

Cryptography and Network Security Department of Computer Science and Engineering Indian Institute of Technology Kharagpur Cryptography and Network Security Department of Computer Science and Engineering Indian Institute of Technology Kharagpur Module No. # 01 Lecture No. # 05 Classic Cryptosystems (Refer Slide Time: 00:42)

More information

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms PROG0101 FUNDAMENTALS OF PROGRAMMING Chapter 3 1 Introduction to A sequence of instructions. A procedure or formula for solving a problem. It was created mathematician, Mohammed ibn-musa al-khwarizmi.

More information

Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration

Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration This JavaScript lab (the last of the series) focuses on indexing, arrays, and iteration, but it also provides another context for practicing with

More information

CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf

CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf First Name: Last Name: NetID: The purpose of this lab is to help you to better understand functions:

More information

The programming language C. sws1 1

The programming language C. sws1 1 The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan

More information

Writing Thesis Defense Papers

Writing Thesis Defense Papers Writing Thesis Defense Papers The point of these papers is for you to explain and defend a thesis of your own critically analyzing the reasoning offered in support of a claim made by one of the philosophers

More information

Trading Commodity Stocks

Trading Commodity Stocks This trader is ready to go. Chapter 11 COMMON SENSE TRADING Yes, he has all his tools in place. Just look at all those charts. What's more, he may have found the secret of trading by the moon. If not that,

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper

More information

Christianna S. Williams, University of North Carolina at Chapel Hill, Chapel Hill, NC

Christianna S. Williams, University of North Carolina at Chapel Hill, Chapel Hill, NC Christianna S. Williams, University of North Carolina at Chapel Hill, Chapel Hill, NC ABSTRACT Have you used PROC MEANS or PROC SUMMARY and wished there was something intermediate between the NWAY option

More information

not at all a manual simply a quick how-to-do guide

not at all a manual simply a quick how-to-do guide not at all a manual simply a quick how-to-do guide As a general rule, the GUI implemented by spatialite-gis is closely related to the one implemented by the companion app spatialite-gui So, if you are

More information

Java Application Developer Certificate Program Competencies

Java Application Developer Certificate Program Competencies Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle

More information

Software Engineering. What is a system?

Software Engineering. What is a system? What is a system? Software Engineering Software Processes A purposeful collection of inter-related components working together to achieve some common objective. A system may include software, mechanical,

More information

Special thanks to Sacha Greif, who wrote some. posts about publishing an ebook and inspired me. to try my hand at it!

Special thanks to Sacha Greif, who wrote some. posts about publishing an ebook and inspired me. to try my hand at it! Special thanks to Sacha Greif, who wrote some posts about publishing an ebook and inspired me to try my hand at it! WHAT'S IT ABOUT? Oh hey Timmy. I'm just writing a book here. So if you don't mind- Well,

More information

How To Get A Job At A Community College

How To Get A Job At A Community College 28 Preview Now More Than Ever: Community Colleges Daniel Wister When Miranda left for school at a faraway university, she thought that all her dreams were on their way to coming true. Then, once disappointment

More information

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine 7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change

More information

TeachingEnglish Lesson plans. Mobile phones. Topic: Mobile phones and text communications

TeachingEnglish Lesson plans. Mobile phones. Topic: Mobile phones and text communications Mobile phones Topic: Mobile phones and text communications Aims: - To develop students understanding of telephone and text communications - To give students a chance to practise speaking Level: Pre-intermediate

More information

Sample Process Recording - First Year MSW Student

Sample Process Recording - First Year MSW Student Sample Process Recording - First Year MSW Student Agency: Surgical Floor, City Hospital Client System: Harold Harper, age 68, retired widower Date: November 18, 20xx Presenting Issues: Cardiologist observed

More information

Programming Project 1: Lexical Analyzer (Scanner)

Programming Project 1: Lexical Analyzer (Scanner) CS 331 Compilers Fall 2015 Programming Project 1: Lexical Analyzer (Scanner) Prof. Szajda Due Tuesday, September 15, 11:59:59 pm 1 Overview of the Programming Project Programming projects I IV will direct

More information

Colleen s Interview With Ivan Kolev

Colleen s Interview With Ivan Kolev Colleen s Interview With Ivan Kolev COLLEEN: [TO MY READERS] Hello, everyone, today I d like to welcome you to my interview with Ivan Kolev (affectionately known as Coolice). Hi there, Ivan, and thank

More information

Using Karel with Eclipse

Using Karel with Eclipse Mehran Sahami Handout #6 CS 106A September 23, 2015 Using Karel with Eclipse Based on a handout by Eric Roberts Once you have downloaded a copy of Eclipse as described in Handout #5, your next task is

More information

Figure out the early start and early finish. Early start. Early finish

Figure out the early start and early finish. Early start. Early finish Figure out the early start and early finish oming up with the float for each activity is useful, but you can actually do better! When you have a long critical path, but the other paths in your network

More information

FULL DEEBRAND YOUR PERSONABLE IDENTITY. Want to Build a Profitable Brand Identity that s got some REAL Personality?

FULL DEEBRAND YOUR PERSONABLE IDENTITY. Want to Build a Profitable Brand Identity that s got some REAL Personality? YOUR PERSONABLE IDENTITY Want to Build a Profitable Brand Identity that s got some REAL Personality? HELLO AND WELCOME Hi, I m Dee, I m the lady with the slightly Bristol accent who is completely in love

More information

Python Loops and String Manipulation

Python Loops and String Manipulation WEEK TWO Python Loops and String Manipulation Last week, we showed you some basic Python programming and gave you some intriguing problems to solve. But it is hard to do anything really exciting until

More information

Back to School: Working with Teachers and Schools

Back to School: Working with Teachers and Schools Back to School: Working with Teachers and Schools Starting school each fall is a challenge for the student and parents. The following article offers some valuable suggestions as your child starts a new

More information

Exploratory Testing in an Agile Context

Exploratory Testing in an Agile Context Exploratory Testing in an Agile Context A guide to using Exploratory Testing on Agile software development teams. Elisabeth Hendrickson 2 Exploratory Testing. So you bang on the keyboard randomly, right?

More information

Insight Guide. E-Learning Compliance. www.kineo.com

Insight Guide. E-Learning Compliance. www.kineo.com Insight Guide E-Learning Compliance LAST MENU BACK NEXT Insight Guide Overview The challenges of compliance training Questions to ask before you begin your design 20 minutes A new generation of design

More information

CHAOS LIMITATION OR EVEN END OF SUPPLY CHAIN MANAGEMENT

CHAOS LIMITATION OR EVEN END OF SUPPLY CHAIN MANAGEMENT CHAOS LIMITATION OR EVEN END OF SUPPLY CHAIN MANAGEMENT Michael Grabinski 1 Abstract Proven in the early 196s, weather forecast is not possible for an arbitrarily long period of time for principle reasons.

More information

Guide to planning for your financial future

Guide to planning for your financial future Guide to planning for your financial future When you first start out in your career you might be thinking about paying back student debt, taking trips abroad or buying a car. And in a few years time, you

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

More information

Who Wants To Literally Save Thousands In AdWords Management Fees?

Who Wants To Literally Save Thousands In AdWords Management Fees? How to Keep Your PPC Management Company Honest Who Wants To Literally Save Thousands In AdWords Management Fees? HERE S THE PROBLEM Not all PPC managers are created equal. Some are really good at what

More information

Prospecting Scripts. 2 keys to success in Real Estate

Prospecting Scripts. 2 keys to success in Real Estate Prospecting Scripts 2 keys to success in Real Estate 1. TALK TO PEOPLE 2. ASK THE RIGHT QUESTIONS 1. Door-knocking or cold calling properties around a new listing (inviting them to a property preview)

More information