In future chapters you will learn about various computational ideas, and the particular Java programming language syntax that you use to express those ideas in a program. Other programming languages will express those ideas with different syntax than Java uses, just like different spoken languages would have different words for the same objects or concepts. However, just as the idea of “tree” is the same whether the word you use to represent the idea is the English word “tree,” or the Spanish word for that concept, or the Japanese word for that concept, likewise, the computational ideas we will learn will be the same, regardless of what language we happen to be using to express those ideas. In this course, we will use Java to express our ideas, and if this is the first time you’ve done any programming, it might be easy to think we are learning Java ideas instead of general programming ideas. That is not the case. We are learning general programming ideas which you will find in almost all modern programming languages, and the particular symbols which represent those ideas in Java, won’t necessarily be the same as the particular symbols that represent those ideas in other languages.
All computer programs basically consist of two components:
Given three numbers:
Show what this might look like in a mathematical expression or equation:
We just applied some small, primitive procedures —addition and division— to produce an average of the four numbers we were given. So, what we have really done above is to create a procedure for finding the average of four numbers. By combining primitive mathematical operations, we were able to produce a procedure that is slightly more complex. This more complex procedure is a composition of other, smaller procedures that together form a larger, more complex procedure. Later on, we may even want to give these composite procedures a name. Just as primitive procedures have names like 'addition' and 'division', we might name our composite procedure, 'averageOfFour' to reflect what it does.
We make use of this idea when writing computer programs, as well:
As an example, we may choose to use the abstract procedure like this:
What is a data primitive?
Give some other examples of a data primitives:
Give some other examples of a procedural primitives:
What is mean by composition?
Give some other examples of a data composition:
Give some other examples of a procedural composition:
What is mean by abstraction?
Give some other examples of a data abstraction:
Give some other examples of a procedural abstraction:
All these ideas fit together to aid us in program design. Quite often, we will often compose a larger piece of data out of smaller pieces of data, and then focus from then on, on the larger data concept rather than worrying about what smaller pieces of data form the larger one. Sometimes, those smaller pieces of data that form the larger piece of data, will be primitives, and sometimes they will instead be other data compositions we already created earlier. Ultimately, though, if you break any piece of data down into small enough detail, you will find that it is composed of the same limited set of data primitives that the language (and processor) supports. We just choose to focus on the “big picture” when we can, instead of always peeking into a data composition to see the smaller pieces of data from which it is made.
Similarly, we will often compose a larger procedure out of smaller ones and subsequently focus on the composite procedure and the overall task it accomplishes, rather than worrying about all the smaller procedures from which it was constructed. Sometimes, the smaller procedures we use to form the larger procedure will be primitives and sometimes they will instead be other procedural compositions we have created previously. Ultimately though, if you break any procedure down into small enough detail, you will find that it is composed of the same limited set of procedural primitives that the language (and processor) supports. We choose to focus on the “big picture” when we can, abstracting away the smaller procedures from which it is made.
In the first half of our course we will learn about many of the primitives available to us in the Java programming language, and we will also learn about the syntax available in Java for implementing data composition and abstraction. We will also learn the syntax and common patterns used to create procedural compositions and abstractions. In addition, we will see the concept of abstraction used in many other ways, as well.