Identify object-oriented programming

standingtopAI and Robotics

Nov 17, 2013 (3 years and 11 months ago)

83 views

Identify object
-
oriented programming
languages

A
computer program

is a series of instructions

that direct a computer to perform specific tasks.


A
programming language
is a set of words,
symbols, and codes that enable a programmer to
instruct the computer to perform a set of tasks.


Programming languages are either low
-
level or
high
-
level.

Computer Programs

Low
-
level Programming Languages



Machine Language
-

a first
generation computer
language



Assembly Language


a
second generation computer
language




Machine language

uses a series of binary digits (1s and 0s), or
combinations of numbers and letters that represent binary digits,
and is the only language a computer directly understands.

Machine Language

(First Generation Language)

00090

000090

50E0

30B2



010B4

000094

1B44

000096

1B55

000098

F273

30D6

2C81

010D8

00C83

00009A

4F50

30D6

010D8

0000A0

F275

30D6

2C7B

010D8

00C7D

0000A4

4F70

30D6

010D8

0000AE

5070

304A

0104C

0000B2

1C47

0000B4

5050

304E

01050

0000B8

58E0

30B2

010B4

0000BC

07FE



Assembly language

uses symbolic instruction codes.

Symbolic instruction codes are meaningful abbreviations & codes in which “A”
might stand for addition, “C” might stand for compare, or “M” might stand for
multiply.

Assembly languages also use symbolic addresses to identify storage locations.

For example, RATE might refer to a storage location that contains the pay rate
being used in the program.

This language is slightly more user friendly than machine language.

Assembly Language

(Second Generation Language)

CALCPAY

EQU

*

ST

14,SAVERTPY

SR

4.4

SR

7.7

SR

5.5

PACK

DOUBLE,RTHRSIN

CVB

4.DOUBLE

ST

7.RATE

High
-
Level Languages

(Procedural Programming Languages)

With a procedural language, or third
-
generation language (3GL),
programmers write instructions using code that is very similar to the
English language, which simplifies the program development process.
For example, ADD stands for addition and PRINT means to print.
Arithmetic operations are represented by + for addition,
-

for subtraction,
/ for division, and * for multiplication.


*

COMPUTE REGULAR TIME PAY

MULTIPLY REGULAR
-
TIME HOURS BY HOUR
-
RATE


GIVING REGULAR
-
TIME
-
PAY

*

COMPUTER OVERTIME PAY

IF OVERTIME
-
HOURS >0


COMPUTER OVERTIME
-
PAY = OVERTIME
-
HOURS * 1.5 * HOUR RATE

ELSE


MOVE 0 TO OVERTIME PAY

Popular Standard procedural languages are:


BASIC

a simple, interactive problem
-
solving language


COBOL

a language designed for business applications


C

a powerful language that requires professional programming skills

High
-
Level Languages

(Procedural Programming Languages)

Below is an example of code written in BASIC:



High
-
Level Languages

(BASIC)

Sample 1: Unstructured original BASIC

(Applesoft BASIC)

Sample 2: Modern Structured BASIC (e.g. QBASIC)


An example of
code written in
COBOL.


COBOL stands for
Co
mmon
B
usiness
O
riented
L
anguage



High
-
Level Languages

(COBOL)

Below is an example of code written in “C”:


High
-
Level Languages

(C)

/* Computer Regular Time Pay

*/

rt_pay


rt_hrs * pay_rate;

/* Computer Overtime Pay

*/

if (ot_hrs > 0)


ot_pay


ot_hrs * 1.5 * pay_rate;

else


ot_pay = 0;

/* Compute Gross Pay

*/

Gross


rt_pay * ot_pay;

/* Print Gross Pay

*/

Printf(“The gross pay is %d
\
n”. gross):

A t
compiler

or an
interpreter

ranslates the 3GL source program into a
machine language object code

that a computer can execute.


An
interpreted

program runs each line of code individually and translates it
into machine language while it is executing the program.


A
compiled

program is run through a compilation process that converts the
entire program from the source code into machine code. Compiled
programs run much faster than interpreted programs and are usually
identified by the filename extension of .exe.

Compiling or Interpreting
Computer Code

Visual programming languages are sometimes called fifth
-
generation
languages (5GL) and provide a visual or graphical interface, called a
visual programming environment (VPE) for creating source code.



Visual Programming


Visual programming languages are
often used in a rapid application
development (RAD) environment.
RAD allows programmers to
implement a program in segments
and use pre
-
built components which
simplify program development.



Visual Programming

Rapid Application Development (RAD)

An example of RAD would be the icons
shown on the above desktop and folder.
The icon of the diskdrive representing
the computer drives is used in several
places


but the same routine is used to
create all of them.




Visual programming
languages include:


Visual Basic .NET 2003


Visual C++ .NET 2003


Visual C# .NET 2003


Delphi


PowerBuilder



Visual Programming


This is an example
of a Visual Basic
6.0 environment
used to create a
program in Visual
Basic.


Characteristics of Object
-
Oriented
Programming Languages


Programmers use an
object
-
oriented programming
(OOP) language

to implement object
-
oriented design.

An
object

is an item that can contain both data and the
procedures that read or manipulate the data.

A major benefit of OOP is its ability to reuse and modify
existing objects, which allows programmers to create
applications faster.

OOP languages include C++, which is an object
-
oriented
extension of the C programming language, and Java,
which is similar to C++ but uses a just
-
in
-
time (JIT)
compiler to convert its source code into machine code.


On the right is the HTML code that produced the webpage shown on the left.
Examine the code and see if you can determine what some of it does.

See if you can explain what the code in
red

does.

Web Page Written in HTML


<html>

<Head>

<center>

<Title>DogieO's Homepage</title>

<br>

</head>

<body bgcolor="#FFFFFF" text="#OOOOOO">


<h1>
DoggieO's Home Page
</h1>

<br>

<image src="
doggieo.gif">

<br>

Hello, my name is DoggieO. I enjoy all aspects of life, especially chasing other
animals.<br>

I am a freshman at Cannine High School where I am on the Fetch Team.<br>

Below are my favoriate links.<br>

<br>

<a href="http://www.Petsmart.com">Petsmart where I get my food and
toys.</a><br>


<a href="http://www.google.com">Google Search Engine where I get all my
information.</a><br>

<br>
</center>

</body>

</html>

On the right is the Java code that makes the buttons on the left page change color. When
the user “mouse
-
overs” the button, it switches the graphic which represents the button so
that the button appears to change colors or “light up” showing it is active.
Below are the two
buttons that switch in and out of the page as a result of the Java script code below.

Web Page Written in Java



<title>Pop Activities Page</title>


script LANGUAGE="JavaScript"><!
--


if (navigator.userAgent.indexOf("Mozilla") !=
-
1)

{


if (parseInt(navigator.appVersion) > 2) BrowserOK = 1;


else BrowserOK = 0;

}

function highlight(img) { if (BrowserOK == 0) return;


document[img].src = img + "G.jpg";

}

function unhighlight(img) { if (BrowserOK == 0) return;


document[img].src = img + "S.JPG";

}

//
--
>


</script>

As you can see, we have many languages. Below are just a few.
Languages are improved upon or new languages are developed
as we find new applications and uses for computers.

Although we have many languages, they all share common elements;
so it is easy to learn and program in other languages once you are
exposed to writing code for one program language.