Вы находитесь на странице: 1из 12

COLLEGE OF SCIENCE, TECHNOLOGY AND

APPLIED
ARTS
OF TRINIDAD & TOBAGO
BUSINESS & INFORMATION TECHNOLOGY DIVISION

ITEC133

Programming 1

Introduction to Programming and Course


&
Introduction to Object Oriented Concepts

Lecture Note 1

Kadeem Best

Table of Contents
An Overview of a Computer ...................................................................................................... 1
What is a computer?............................................................................................................... 1
Hardware ................................................................................................................................ 1
Computer Organization ...................................................................................................... 1
Software ................................................................................................................................. 2
Operating Systems(O.S) .............................................................................................. 2
Application Programs .................................................................................................. 3
Programming Fundamentals ...................................................................................................... 3
What is programming? ........................................................................................................... 3
Programming Languages ....................................................................................................... 3
What is a programming Language? ................................................................................... 3
Generations of Programming Languages........................................................................... 3
Types of Programming Languages .................................................................................... 4
Steps in Developing Programs ............................................................................................... 4
1.
Define the problem .................................................................................................. 4
2.
Analyze the problem ................................................................................................ 4
3.
Develop the solution (Develop an Algorithm) ........................................................ 5
4.
Code the solution(Algorithm) into a Programming Language ................................ 5
5.
Compile and Run the Program ................................................................................ 5
Algorithm ............................................................................................................................... 5
Pseudocode ............................................................................................................................ 5
Trace Tables ........................................................................................................................... 5
Overview of Java ....................................................................................................................... 6
What is Java ........................................................................................................................... 6
History of Java ....................................................................................................................... 6
Typical Java Development Environment ............................................................................... 6
An overview of the software development process. .......................................................... 7
The Java Platform .................................................................................................................. 7
Java Editions .......................................................................................................................... 8
The Java Runtime .................................................................................................................. 8
The Java Development Kit..................................................................................................... 9
Introduction to Object Oriented Concepts ................................................................................. 9
Objects ................................................................................................................................... 9
What Is an Object? ............................................................................................................. 9
Classes.............................................................................................................................. 10

An Overview of a Computer
What is a computer?
A computer is an electronic device capable of performing computations and making
logical decisions at speeds millions (even billions) of times faster than human beings
can. It has the ability to store, retrieve, and process data. You can use a computer to
type documents, send email, and browse the internet. You can also use it to handle
spreadsheets, accounting, database management, presentations, games, and more.
A computer can be divided into two main parts: hardware and software.

Hardware
Hardware is any part of your computer that has a physical structure, such as the
computer monitor or keyboard.

Computer Organization
Regardless of differences in physical appearance, virtually every computer may be
envisioned as divided into six logical units or sections:

Input Unit
This is the receiving section of the computer. It obtains information (data and
computer programs) from input devices (Input devices accept data in a form
that the computer can utilize) and places this information at the disposal of
other units so that it can be processed. Most information is entered into
computer through keyboards and mouse devices. However, Information can
also be entered in many ways, including by speaking to your computer, by
scanning images etc.

Output Unit
This is the shipping section of the computer. It takes information that the
computer has processed and places it on various output devices to make the
information available for use outside the computer. Most information output
from computers today is displayed on screens, printed on paper etc.

Memory Unit
This is the rapid-access, relatively low-capacity warehouse section of
computer. It retains information that has been entered through the input unit,
1

so that it will be immediately available for processing when needed. The


memory unit also retains processed information until it can be placed on
output devices by the output unit. Information in the memory unit is often
called either memory or primary memory

The Arithmetic logic Unit (ALU)


This is the manufacturing section of the computer. It is responsible for
performing calculations, such as addition, subtraction, multiplication and
division. It contains the decisions mechanism that allows the computer, for
example, to computer two items from the memory unit to determine whether
they are equal.

Central Processing unit (CPU)


This is the administrative section of the computer. It coordinates and
supervises the operation of the other sections. The CPU tells the input unit
when information should be read into the memory unit, tells the ALU when
information from the memory unit should be used in calculations and tells the
output unit when to send information from the memory unit to certain output
devices.

Secondary Storage Unit


This is the long-term, high-capacity warehousing section of the computer.
Programs or data not actively being used by the other units normally are
placed on secondary storage devices (eg. Your hard drive) until they are
again needed, possibly hours, days, months or even years later. Information
in secondary storage takes much longer to access thanS information in
primary memory. Examples of secondary storage devices include CDs and
DVDs, which can hold up to hundreds of millions of characters and billions of
characters, respectively

Software
Software is any set of instructions that tells the hardware what to do. It is what
guides the hardware and tells it how to accomplish each task. Some examples of
software are web browsers, games, and word processors such as Microsoft Word.
Software can be broken down into : Operating Systems, Application Programs.

Operating Systems(O.S)
An operating system is the most important software that runs on a computer.
It manages the computers memory, processes, and all of its software and
hardware. Examples of Operating Systems include: - Windows Vista,
Windows XP , Windows 7 and Mac OS.
2

Application Programs
Application Programs are designed to perform a specific function directly for
the user or, in some cases, for another application program. Examples of
application programs include word processors; database programs; Web
browsers; development tools; drawing, paint, and image editing programs;
and communication programs

Programming Fundamentals
What is programming?
Programming is instructing a computer to do something for you with the help of a
programming language

Programming Languages
What is a programming Language?
An artificial language used to write instructions that can be translated into machine
language and then executed by a computer.
Some programming languages include :- formula translation (FORTRAN), C, C++,
PASCAL, BASIC, Java

Generations of Programming Languages

First generation languages (abbreviated as 1GL)


Represent the very early, primitive computer languages that consisted entirely of 1's
and 0's - the actual language that the computer understands (machine language).

Second generation languages (2GL)


Represent a step up from the first generation languages. Allow for the use of
symbolic names instead of just numbers. Second generation languages are known
as assembly languages. Code written in an assembly language is converted into
machine language (1GL).

Third generation languages (3GL)


With the languages introduced by the third generation of computer programming,
words and commands (instead of just symbols and numbers) were being used.
3

These languages therefore, had syntax that was much easier to understand. Third
generation languages are known as "high level languages" and include C, C++,
Java, and Javascript, among others.

Types of Programming Languages


Programing Languages can be mainly divided into the follow categories :

Procedural
Procedural languages execute a sequence of statements that lead to a result.
In essence, a procedural language expresses the procedure to be followed to
solve a problem. Procedural languages typically use many variables and have
heavy use of loops and other elements of "state", which distinguishes them
from functional programming languages. Functions in procedural languages
may modify variables or have other side effects (e.g., printing out information)
other than the value that the function returns.

Object-oriented
Object-oriented programming views the world as a collection of objects that
have internal data and external means of accessing parts of that data. The
goal of object-oriented programming is to think about the problem by dividing
it into a collection of objects that provide services that can be used to solve a
particular problem.

Steps in Developing Programs


1. Define the problem
At this step you are required to examine the problem until you understand it
thoroughly.

2. Analyze the problem


Involves defining the data we need to provide to the program (input) and
information we want the program to produce (the output).

3. Develop the solution (Develop an Algorithm)


Once we have defined and analyzed the problem that is, decided on the
output and the input then we can go on to develop the solution.
The most important aspect of developing the solution is developing the logic
to solve the problem. This requires creating a set of step-by-step instructions
and/or rules called an algorithm. Each step performs a particular task. We can
write these steps in plain English.

4. Code the solution(Algorithm) into a Programming Language


Once we develop the algorithm, we need to convert it into a computer
program using a programming language (a language used to develop
computer programs). A programming language is entirely different from the
language we speak or write. However, it also has a fixed set of words and
rules (syntax or grammar) that are used to write instructions for a computer to
follow.

5. Compile and Run the Program


6. Document and maintain the program

Algorithm
An Algorithm is a set of step by step instructions if followed faithfully should give a
solution to a problem.

Pseudocode
Pseudocode is a structured way of expressing an algorithm. It uses the structural
conventions of a programming language, but is intended for human reading rather
than machine reading

Trace Tables
A trace table is a technique used to test algorithms, in order to make sure that no
logical errors occur whilst the algorithm is being processed. The table usually takes
the form of a multi-column, multi-row table; With each column showing a variable,
and each row showing each number input into the algorithm and the subsequent
values of the variables.

Overview of Java
What is Java
Java technology is both a programming language and a platform.

The Java programming language is a high-level language that can be characterized


by all of the following buzzwords:

Simple
Object oriented
Distributed
Multithreaded
Dynamic

Architecture neutral
Portable
High performance
Robust
Secure

History of Java
The Java programming language is designed to meet the challenges of application
development in the context of heterogeneous, network-wide distributed
environments. Paramount among these challenges is secure delivery of applications
that consume the minimum of system resources, can run on any hardware and
software platform, and can be extended dynamically.
The Java programming language originated as part of a research project to develop
advanced software for a wide variety of network devices and embedded systems.
The goal was to develop a small, reliable, portable, distributed, real-time operating
platform. When the project started, C++ was the language of choice. But over time
the difficulties encountered with C++ grew to the point where the problems could
best be addressed by creating an entirely new language platform. Design and
architecture decisions drew from a variety of languages such as Eiffel, SmallTalk,
Objective C, and Cedar/Mesa. The result is a language platform that has proven
ideal for developing secure, distributed, network-based end-user applications in
environments ranging from network-embedded devices to the World-Wide Web and
the desktop.

Typical Java Development Environment


In the Java programming language, all source code is first written in plain text files
ending with the .java extension. Those source files are then compiled into .class files
by the javac compiler. A .class file does not contain code that is native to your
processor; it instead contains bytecodes the machine language of the Java Virtual
Machine (Java VM). The java launcher tool then runs your application with an
instance of the Java Virtual Machine.
6

An overview of the software development process.


Because the Java VM is available on many different operating systems, the
same .class files are capable of running on Microsoft Windows, the Solaris Operating
System (Solaris OS), Linux, or Mac OS. Some virtual machines, such as the Java
HotSpot virtual machine, perform additional steps at runtime to give your application
a performance boost. This include various tasks such as finding performance
bottlenecks and recompiling (to native code) frequently used sections of code.

Through the Java VM, the same application is capable of


running on multiple platforms.

The Java Platform


A platform is the hardware or software environment in which a program runs. Some
popular platforms include Microsoft Windows, Linux, Solaris OS, and Mac OS. Most
platforms can be described as a combination of the operating system and underlying
hardware. The Java platform differs from most other platforms in that it's a softwareonly platform that runs on top of other hardware-based platforms.
The Java platform has two components:

The Java Virtual Machine


The Java Application Programming Interface (API)

The API is a large collection of ready-made software components that provide many
useful capabilities. It is grouped into libraries of related classes and interfaces; these
libraries are known as packages.

The API and Java Virtual Machine insulate the program


from the underlying hardware.
As a platform-independent environment, the Java platform can be a bit slower than
native code. However, advances in compiler and virtual machine technologies are
bringing performance close to that of native code without threatening portability.
The terms"Java Virtual Machine" and "JVM" mean a Virtual Machine for the Java
platform.

Java Editions
The Java platform editions contain additional Java APIs for creating different types of
applications: Java comes in 3 main editions:
Java 2 Standard Edition (J2SE) - Designed to run on desktop and
workstations computers.
Java 2 Enterprise Edition (J2EE)=- With built-in support for Servlets, JSP, and
XML, this edition is aimed at server-based applications.
Java 2 Micro Edition (J2EE)- Designed for devices with limited memory,
(mainly phones) display and processing power.

The Java Runtime


In order to run Java applications, a computer has to have the J2SE Runtime
Environment (JRE) installed. The JRE includes the Java Virtual Machine (JVM). As
mentioned previously the JVM is the software that translates Java into your
machine's native language. So, someone running Windows on an Intel x86 machine,
would install the Windows version of the JRE.

The Java Development Kit


As a programmer, you'll also need the J2SE Development Kit (JDK). The JDK
includes everything you need to compile, debug, and run your Java applications. The
JDK includes the Java Runtime Environment so you shouldn't need to download the
JRE.

Introduction to Object Oriented Concepts

Objects
What Is an Object?
Objects are key to understanding object-oriented technology. Look around right now
and you'll find many examples of real-world objects: your dog, your desk, your
television set, your bicycle.
Real-world objects share two characteristics: They all have state and behavior. Dogs
have state (name, color, breed, hungry) and behavior (barking, fetching, wagging
tail). Bicycles also have state (current gear, current pedal cadence, current speed)
and behavior (changing gear, changing pedal cadence, applying brakes). Identifying
the state and behavior for real-world objects is a great way to begin thinking in terms
of object-oriented programming.
Take a minute right now to observe the real-world objects that are in your immediate
area. For each object that you see, ask yourself two questions: "What possible states
can this object be in?" and "What possible behavior can this object perform?". Make
sure to write down your observations. As you do, you'll notice that real-world objects
vary in complexity; your desktop lamp may have only two possible states (on and off)
and two possible behaviors (turn on, turn off), but your desktop radio might have
additional states (on, off, current volume, current station) and behavior (turn on, turn
off, increase volume, decrease volume, seek, scan, and tune). You may also notice
that some objects, in turn, will also contain other objects. These real-world
observations all translate into the world of object-oriented programming.

A software object.

Software objects are conceptually similar to real-world objects: they too consist of
state and related behavior. An object stores its state in fields (variables in some
programming languages) and exposes its behavior through methods (functions in
some programming languages).

Classes

In the real world, you'll often find many individual objects all of the same kind. There
may be thousands of other bicycles in existence, all of the same make and model.
Each bicycle was built from the same set of blueprints and therefore contains the
same components. In object-oriented terms, we say that your bicycle is
an instance of the class of objects known as bicycles. A class is the blueprint from
which individual objects are created.

10

Вам также может понравиться