Introduction - School of Computer Science

morbiditysurlyΛογισμικό & κατασκευή λογ/κού

15 Νοε 2012 (πριν από 4 χρόνια και 8 μήνες)

272 εμφανίσεις

INTRODUCTION

Introduction to Computer Science I
-

COMP 1005, 1405


Instructor :
Behnam

Hajian

bhajian@scs.carleton.ca




Attention:


A large amount of material in this set of slides has
gotten from course notes prepared by Dr. Mark Lanthier.

Objectives and syllabus

The objectives in this course is


To indentify the basic view of architecture of a computer.


To expose students to a high level programming
language (i.e., java).


To make students learn the basic programming concepts.

Where are you?

Where you are?

What you learn?

Objectives and syllabus


An introduction to Computer Science and Problem Solving.


Variables and Object.


Data Structure.


Control statements (if
-
else, switch
-
case).


Loops (while, for).


2D graphics.


Array, and list.


Methods and Functions.


Calculations, Formatting and Conversions.


Sorting.


Recursion.


Shared data

Evaluation, Course information:

Evaluation
:


6 programming assignments:30%


3 Quizzes (in
-
class exams):30%


Tutorials participation 10%


Final Exam: 30%

Website
:


Course material will be available on
WebCT

or the course
link in my webpage.


https://lms.carleton.ca/webct

OR
http://people.scs.carleton.ca/~bhajian/comp1005/winter2012


Lectures
:


Monday&Wednesday

14:35 PM


15:55 PM
@
103

Steacie

Building (
SC
).

Course information

Office hours:


Monday & Wednesday 4PM
-

5 PM @ HP
5331

TextBook
:


Course notes

of
Introduction to Computer
Science 1

mainained

by Mark
Lantier

uploaded in
WebCT
.

References
:


Getting Started with Processing
, Casey
Reas

and Ben Fry


http://processing.org/shop/

Computers


What is a computer?


A computational device


Logical decisions billions of times faster than humans


Hardware


keyboard, screen, disks, memory, CPU


Software


email, word processing, spreadsheets, OS



What are Computers Used For?


Communications: Internet, e
-
mail,
cell

phones


Word Processing: typing/printing documents


Business Applications: accounting, spreadsheets


Engineering Applications: scientific analysis,
simulations


Database Management: police records, stock
market


Entertainment: games, multimedia applications


Manufacturing: CAD/CAM, robotics, assembly


... many more ...

Who is Involved With Computers ?


System/Hardware Designers
= people that design computers
and related products.


Manufacturers

= people that actually build and assemble
computers.


Software Designers
= people that design applications to be
used with the computers.



Programmers

= people that write computer programs to
achieve working applications,
games

and other software
packages.


End User
= people that buy and use the software when it is
done.


We are going to play the role of the
Programmer in this course.


Computer Organization


Input unit


keyboard, microphone


Output unit


screen, printer


Memory unit


Random Access Memory (RAM)


short
-
term, rapid access, low capacity
warehouse


Read only memory ROM


Smaller amount of memory


stable when power off.


Stores enough code to boot system

Computer Organization


Secondary storage unit


disks, tapes


long
-
term, slow access, high capacity warehouse


Central Processing Unit (CPU): Microprocessor (Intel Pentium,
Motorola power PC): fetches machine instructions from
memory, executes them


Arithmetic
and logic
unit (ALU)


calculations, comparisons


CU (Control Unit)


coordinator
,
administrator,

Computer Architecture

CPU

Program

Control Unit

ALU

Memory

I/O

What is a
program ?

A
program is traditionally known as:


a sequence of instructions that can be executed by a
computer to solve some problem.


In this course, we will learn to write our own
programs to solve some very simple problems.

How do we write
good programs ?

What is a
programming language ?

What is
Procedural programming ?

What is
Object
-
Oriented programming ?

Processing




Each program is called a “
sketch
” in Processing. The top left play button
starts your program which brings up a window (shown yellow here with a
picture of a teddy bear). Since, many processing programs are meant to
be animations, there is also a stop button beside the play button to stop
the program. You should explore the Processing IDE (i.e., Integrated
Development Environment) a little to get used to it.


Processing uses the same
syntax

as
JAVA
. That means, Processing code
looks almost exactly like JAVA code. So when you are programming in
Processing, you are actually learning JAVA as well. However, Processing
has been designed in a way that makes it easier to get you started
because some of the overhead in getting your first program working is
hidden.


As you may recall, Processing is a graphics
-
based language and
therefore we will spend a lot of time and effort drawing various things on
the screen. When drawing anything, it is important to specify
where you
want to draw.

The JAVA Programming Language

JAVA is a very popular object
-
oriented programming
language from SUN Microsystems. It has become a basis
for new technologies such as: Enterprise Java Beans
(EJB’s),
Servlets

and Java Server Pages (JSPs) , etc. In
addition, many packages have been added which
extend the language to provide special features:



Java Media Framework (for video streaming, webcams,
MP3 files, etc)



Java 3D (for 3D graphics)



J2ME (for wireless communications such as cell phones,
PDAs)

Why java?

Writing a program in Processing


Use Java syntax.


In order to tell computer what to do, we have to use
Instructions. They are called statements.


Each statement follow a specific syntax.


Each statement end with Semicolons ;


Compiling is the process of converting a program into
instructions that can


be understood by the computer.



As you may recall, Processing is a graphics
-
based language and therefore we
will spend a lot of time and effort drawing various things on the screen. When
drawing anything, it is important to specify
where you want to draw.







Colors in Processing


More graphical functions


Some important comments on java


Java is a case sensitive language.


Most of the library names start with capital letters.


In order to complete your code in
netbeans

you can use control +
space keys.

Problem Solving



Understand the Problem


Formulation of Problem


Example


Develop and Algorithm






Write the program



Test the Program


Solution evaluation


Abstraction


Abstraction

is the process of reducing or factoring out
details that are not necessary in order to describe an
algorithm


Algorithm efficiency


Algorithm efficiency is used to describe properties of an
algorithm
relating to how much of various types of
resources it consumes. (Wikipedia)






Difference between print and
println


The first line uses
print while the second line uses
println
.
When using just
print,
the next text to be
printed will be immediately to the right of this text.


When using
println
, a line feed and carriage return is
printed,
which means that the text to follow will appear
at the beginning of the next line of the console (i.e.,
output window).

Example:


QUESTIONS?