Download Goals of this Course - UCF Computer Science

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Goals of this Course
1. To teach students to think about problems in an algorithmic manner.
2. Teach students how to express their algorithms through structured
programming, in Java.
3. Once students have a feel for the structured programming paradigm, then
they will be introduced to the object-oriented paradigm. The ultimate goal of
this course is to get students solve problems using an object-oriented
program design.
Why Java as a First Language?
Computer science educators certainly do not agree on which language new
students should learn first. However, as we enter the 21 st century, the goal of
universities has become not only to teach the theory behind the study of
computer science, but also to get students to be adept with practical
applications they will use in the workforce.
Since more and more applications use the World Wide Web, and an
understanding of Java is a must in writing these applications, most (if not
all) computer science students should learn Java.
The complexity of practical applications nowadays necessitates objectoriented design. Due to its “clean” design, it is easier to learn the concepts of
object-oriented design through Java than other popular programming
languages such as C++.
Since it is difficult (not impossible!!!) to teach an old dog new tricks, the
earlier a computer scientist learns how to design programs in an objectoriented manner, the easier it will be for him/her to embrace object-oriented
design. It follows that by learning Java first, students will master the objectoriented paradigm much more easily than if they learned Pascal or C first.
What all of this means in English!!!
So, if you have never programmed a computer before, that last page of notes
probably seemed like Greek to you. So, here’s a recap in English:
The goal of this course is to teach you to solve problems in a precise
manner. A computer is merely a tool that will help you solve problems.
Once you have figured out HOW to precisely solve a problem, you will have
to write a program that implements your solution. You will learn how to do
this in the programming language Java.
Java is typically not taught as a first programming language. However, now
that Java has been fully accepted by academia AND industry, it makes more
sense to teach it as a first language. By learning Java first, you will
understand and accept object-oriented design easily. (I will not try to define
“object-oriented design” here. I know this may seem quite annoying, seeing
has how I’ve already used the term 20 times, but trust me when I say you
don’t need to worry about what “object-oriented” design means, for now. If
fact, I will not define the term until halfway through the class, so you’ll have
to keep on guessing until then:))
Finally, one main advantage of Java should be mentioned before we go on: it
is more portable than other programming languages. Portable means that you
can write a program on one computer and then run it on many other
computers.
Some Basics Before We Dive into Java
What does a computer do?
Contrary to popular belief, computers are not smart. Some movies, like
Short Circuit, portray computers as capable of having thoughts. For now,
this simply is not accurate. (There are some diehards out there who still
believe we will be able to make a computer emulate human thought...)
Rather, a computer processes data (or information) using a set of instructions
(also known as computer programs). A computer would do absolutely
NOTHING without a person writing instructions for the computer to
perform. So, essentially, a computer executes instructions written by people.
A computer’s components
A computer can be divided into two main categories: hardware and software.
The hardware is the physical components that make up the computer and the
software is the set of programs that the hardware executes.
Hardware
We can break up the hardware into six logical sections as follows:
1. Input unit: Since a computer must process information, this information
must be given to the computer from somewhere. This somewhere is the
input unit. A common example of an input unit is a keyboard.
2. Output unit: A computer would be useless if it could not communicate to
us the results of processing data. Output units allow the user to view the
results of executing computer programs. An exampleof an output unit is a
monitor.
3. Memory unit: As it’s name indicates, the memory unit stores information
that the computer needs to execute programs. Specifically, the memory
stored as random access memory(RAM) can be quickly retrieved by the
computer for calculations.
4. Arithmetic and Logic Unit(ALU): Performs crucial instructions such as
simple arithmetic (addition, subtraction, multiplication, division) and logical
instructions, such as comparing to real number values.
5. Central Processing Unit(CPU): The part of the computer organizes the
other units of the computer. It handles when input should be transferred to
memory, when the ALU should perform operations, and tells the output unit
when it should send information to output devices.
6. Secondary storage unit: This is where long term information is stored, like
a disk. If you are not currently using a program, it would be stored in
secondary storage. Programs remain there until they are used, at which point
the necessary information to execute the program efficiently is copied into
RAM. It takes much longer to access information from secondary storage
than RAM. But, secondary storage is much cheaper per unit memory than
RAM.
Software
1. Operating System
One of the most important pieces of software on a computer is the operating
system. Examples of operating systems are UNIX, MS-DOS, and Windows.
The job of an operating system is to provide an interface for the user so they
can run other programs easily, as well as to allocate the computer’s
resources in an efficient manner. Ever notice how it looks like your
computer is running three or four programs simultaneously? (You might
have Word open, be playing a CD and reading from a Netscape window all
at the same time.) However, your computer is NOT really running all of
these programs at the exact same time. Rather, it determines a priority for
each program, and allocates its resources accordingly. For example, it may
spend 10 ms on Netscape, then 3 ms on your CD player, followed by 5 ms
on Word, repeating this type of cycle over and over again, adjusting the time
for each applications as needed. Since these time intervals are much to small
for humans to notice, it appears to us as if all four applications are
simultaneously running. However, it is just the operating system doing a
good job of allocating resources, since there is only one processor in a
standard computer.
2. Other applications
The applications you are probably most familar with are word processors,
spreadsheets, games, etc. Typically, these are written in a high-level
programming language, such as C, C++ or Java.
Machine, Assembly and High-Level Languages
The computer does not understand Java, or any other high level computer
language. In fact, a computer only understands its own machine language,
which is made up of 0’s and 1’s. But it would be ridiculous for people to
program in 0’s and 1’s.
Initially, people programmed in assembly languages. An assembly language
is a simple language with a set of a few commands such as ADD, SUB,
LOAD, etc. An assembler translates this into a machine language specific to
the computer on which a program is running. However, this proved to be too
tedious for large applications, since individual assembly language
commands do very little.
Thus, high level languages with more powerful commands were invented
and have become the tool that almost all software developers use to write
their programs. But, in order for a computer to understand a high-level
language, applications had to be written to convert a high-level language to
assembly. A compiler is such an application.
Java Class Libraries
Although, you won’t use Java’s class libraries much in the beginning of this
course, it is important to understand the basic idea behind them. All Java
code is organized into separate units called classes. You will write your own
classes in this class. (No pun intended!!!) However, Java comes with many
prewritten classes. In each of the classes, there will be certain methods you
will be able to use, rather than writing your own. For now, just remember
that each Java class is built up of methods, and that you will be able to use
methods in prewritten Java classes to help you complete some of your
programs.
Example of an Algorithm
Before I finish this lecture, I want to show you an example of an algorithm.
The textbook definition of an algorithm is “a finite number of precise steps
that solves a problem.” In essence, an algorithm is a set of instructions. So,
you have seen algorithms all of your life. For example, cooking a
microwaveable burrito entails following a set of instructions. According to
Patio, the best way to “cook” their beef and bean burrito is as follows:
1. Remove burrito from wrapper.
2. Place on microwave-safe plate folded side down.
3. Heat on high for 2 to 3 minutes or until hot, rotating place once during
heating.
4. Let stand 1 to 2 minutes before serving.
Pretty much any moron can follow these directions. There is little room for
error. But, I’ll bet a few people could mess it up. A good algorithm must be
unambiguous. That is why each step in an algorithm should be specific and
precise. More importantly, a good algorithm must solve the problem at hand.
Generally speaking, the more simple the solution, the better.
You’ll notice that there are always certain ambiguities in English that we can
not avoid. But, this type of language is unacceptable for a computer, which
has no common sense to clear up certain ambiguities. Thus, computer
languages, like Java, are completely unambiguous. There are certain
statements that are permissible (grammatically correct) in Java. Each of
these can be executed in exactly one way.
When designing computer programs, you will first come up with a general
algorithm to solve the problem at hand. Then, you have to implement that
algorithm in Java. The more precise your algorithm is, the easier it will be to
implement.
In the next lecture, I will start showing you Java statements so that you can
execute a simple program.