www.cs.colostate.edu
Download
Report
Transcript www.cs.colostate.edu
CS115 -- 9/29/2004
(Recitation Objectives) and
Computer Science
and
Objects and Algorithms
Recitation Objectives
●
●
●
●
●
Occasional projects to support lecture topics, such as
studying Google as an introduction to talking about
information and the web.
Improve your programming skills
Create a good web site (at least 2 linked pages) for
yourself
Learn at least some Java, some html, and some Linux
An opportunity for you to check in with me about your
grade if you wish to do so.
What is Computer Science?
●
●
●
At the highest level computer science (CS) is the study
of computation and information processing, both in
hardware and in software.
Computation can be defined as finding a solution to a
problem from given inputs (information received) by
means of an algorithm (set of instructions).
For thousands of years, computing was done with pen
and paper, or chalk and slate, or mentally, sometimes
with the aid of tables.
Information Processing...
●
At its most general, information processing is the
changing (processing) of information in any
manner that an observer can detect. Computer
scientists study how information is used by or
changed by computers.
More Computer Science
●
●
●
In practice, computer science includes a variety of topics
relating to computers. These range from the abstract
analysis of algorithms, formal grammars, etc. to more
concrete subjects like programming languages, software,
and computer hardware.
Computer science is very different from mathematics,
programming, software engineering, and computer
engineering, although these fields are often confused.
Computer science has its roots in electrical engineering,
linguistics, and mathematics.
Quotations...
●
●
Edgar Dijkstra: “Computer science is no more
about computers than astronomy is about
telescopes.”
Richard Feynman: “Computer science is not as
old as physics; it lags by a couple of hundred
years. However, this does not mean that there is
significantly less on the computer scientist's plate
than on the physicist's: younger it may be, but it
has had a far more intense upbringing!”
What is an Object?
●
An object is a unique concrete instance of an
abstract data type whose identity is separate from
that of other objects, although it can communicate
with them using messages.
What is an abstract data type?
●
●
●
An abstract data type is a conceptual structure that
includes both data and the methods to access it.
Abstract data types are described in terms of the
operations they support (their interface) instead of how
they are implemented. Users are aware of the interface
but not of the implementation.
When done correctly this means that the implementation
can be completely changed without needing to modify
any existing code that is using the abstract data type.
Benefits of object-oriented
programs...
●
●
When structured correctly, one can build and
change chunks of programs independently from
each other.
Another claim for object-oriented program is that
this approach models real life problems
"naturally" by a sort of simulation.
Objects...
●
Object-based systems are typically built using a
class-based language, where an instance is
"instantiated" as an object of a particular class.
Each instance is a variation on a general theme,
which is defined by the parent class. For example,
my personal plate could be described as an
instance of a plate (where plates are a class of
dishes).
Objects...
●
In small groups, we will assign you a small task.
●
Quickly identify the objects involved in the task.
●
●
Pick ONE object and identify the attributes
(qualities) of the object and its methods (actions it
can do).
Pick someone who will tell the class the task, the
objects, and the attributes and methods of the
object you chose.
What is an Algorithm?
●
●
An algorithm is a well-defined set of instructions, finite
in number, for accomplishing some task which, given a
set of inputs, will result in some recognizable end-state.
The concept of an algorithm is often illustrated by the
example of a recipe, although many algorithms are much
more complex; algorithms often have steps that repeat
(iterate) or require decisions (such as logic or
comparison) until the task is completed.
Formally...
●
In formal mathematical terms, an algorithm is
considered to be any sequence of operations
which can be performed by a Turing-complete
system.
Simply...
●
●
Algorithms are the ideas behind the computer
programs.
The algorithm stays the same regardless of the
language the program is written in and the
location/size/generation/type of the computer on
which it is running.
Algorithms...
●
●
Algorithms typically have steps that repeat
(iterate) or require decisions (comparison and
logic) until the task is completed.
Functions are often used to implement
algorithms.
Different algorithms ...
●
... may complete the same task with a different set of
instructions in more or less time, space, or effort than
others. A cooking recipe is an example of an algorithm.
Given two different recipes for making potato salad, one
may have "peel the potato" before "boil the potato" while
the other presents the steps in the reverse order, yet they
both call for these steps to be repeated for all potatoes
and end when the potato salad is ready to be eaten.
Correctness
●
Correctly performing an algorithm will not solve
a problem if the algorithm is flawed, or not
appropriate to the problem. For example,
performing the potato salad algorithm will fail if
there are no potatoes present, even if all the
motions of preparing the salad are performed as if
the potatoes were there.
Some things ...
●
Computer scientists study include:
–
Objects, how and how to structure and use them
–
Algorithms, including correctness, appropriateness,
space, time, and difficulty
Your assignment...
●
Describe an object:
–
Pick a SIMPLE task (like making a cup of tea with a
teabag).
–
Describe the task functionally (how would you
explain it to a five-year-old).
–
Now describe it in an object-oriented way:
●
●
Identify the list of objects involved
For ONE of the objects list its attributes (qualities) and
methods (the things it can do)