Telecommunications

Download Report

Transcript Telecommunications

Chapter 11
Programming Concepts
And Languages
Programming
A program is a set of
instructions (codes) telling a
computer how to perform
various tasks. Programming
is the act of creating these
programs.
Coding
Coding for an HTML Document
Coding is a term used by programmers to refer to the
act of writing source code.
Program Language Characteristics
Programming languages contain
smaller vocabularies than human
(natural) languages. Programming
language syntax (the rules for
stringing together language
elements) is also less complex
than human language syntax.
Classifications of
Computer Languages
Computer languages are classified as low level
or high level.
Low-level languages are called machine code—
the binary language computers use.
High-level languages are relatively similar to
natural languages such as English.
Computer Languages
Low-level languages run faster and take up less disk space.
High-level languages are easier to learn and use.
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<meta name="description" content="EMC/Paradigm
Publishing, publishers of textbooks and new media, is a
premier book and media supplier. Offering textbooks from K12 to the college level, including international publications.">HTML
is a
high-level
language.
Programming Language Generations
1G: Machine code
2G: Assembly language
3G: Visual Basic, C++, etc.
4G: Script languages such as HTML
5G: Graphical user interface languages
The Four Main Computer
Language Programming Elements
Variables
Looping
Decision Statements
Executable Statements
Large Programming Projects
Many programming
projects are too big to be
completed by a single
individual, so they
require a programming
team
Software Engineers
Software engineers typically coordinate programming projects
working with programming teams.
Problem-Solving Techniques
Divide-andConquer Approach
Problem-Solving Steps
Divide-and-Conquer Approach
(Top-Down Design)
1 Break down big
problems into smaller
problems
2 Document process
using an outline format
Problem-Solving Steps
Programmers follow a standard set of 6
steps:
1. Identify the problem.
2. Analyze the problem.
3. Brainstorm solutions and choose the best one.
4. Write the algorithm.
5. Prototype the solution.
6. Implement and test the solution.
Identify the Problem
Programmers must first hammer out
the definition of the problem before
they can begin to solve it.
A programmer starts every project like an
interrogator, beginning with a thorough set
of questions covering every aspect that is
not clear.
Analyze the Problem
Analyzing the problem
can involve learning new
skills or concepts.
If a solution requires writing a
program in a particular
programming language, then
part of understanding the
problem includes
understanding the
programming language.
Brainstorm Solutions
The best strategy is to create a list of all possible
solutions, evaluate them, and then choose the
best one before proceeding.
Write the Algorithm
Programs are first written out as an
algorithm before being written in a
programming language.
An algorithm is a complete list of steps for solving
a problem. Algorithms usually are written in
pseudocode, which is a very high-level language
that computers cannot read.
Write the Algorithm
A pseudocode algorithm for changing a lightbulb
•
•
•
•
•
•
•
•
•
•
•
Get stepladder from closet.
Place stepladder under fixture.
Turn switch off.
Remove fixture from ceiling.
Remove old lightbulb from socket.
Put old lightbulb into trash can.
Get new lightbulb from cupboard.
Put new lightbulb into socket.
Place fixture on ceiling.
Turn switch on.
Put stepladder into closet.
Prototype the Solution
Prototyping means creating a small
semi-functional version of the
solution to see if and how it works.
Prototyping gives a better idea of
whether or not the solution is going to
work before weeks or months of effort
are put into it.
Second, it gives real form to the solution,
allowing the creator to show the solution
to others and get their feedback.
Implement and Test the Solution
Solve the problem. This is where
the program is actually coded.
Testing the solution frequently as each step of the
algorithm is translated into a program helps
ensure fast and accurate development.
During the implementation phase, programmers install
the planned solution.
Documentation, such as a user’s manual, is often
written at this stage of the project.
The Evolution of Programming
Approaches
Structured Programming
Modularity
Object-Oriented Programming (OOP)
Rapid Application Development (RAD)
Structured Programming
Structured programming presented guidelines for an organized,
logical approach that focuses on thinking at a higher level.
The programmer thinks in
terms of structured groups
of instructions.
A section of code is often called a
routine or function. Code for that
function is then broken down into steps.
The process of creating groups of
instructions as independent elements is
the essence of structured programming.
Modularity
Programmers work to create code modules
that handle the separate components of a
program:
• Makes the code reusable
• Helps in tracking down the source of errors.
• Saves time because programmers don’t
have to “reinvent the wheel” every time they
write new programs.
The more independent and reliable the
elements of a program are, the higher the
modularity of a program is said to be.
Object-Oriented
Programming (OOP)
Object-oriented programming (OOP) defines each
module (called an object) with definite rules for
interfacing and a protected set of variables.
Protected variables are one of the key advancements in
programming, as they allow a programmer to prevent data
from being altered during program execution.
A programmer working with a team sets up rules for the
legal use of an object’s data, thereby reducing the
chances for error when someone unfamiliar with the code
tries to use it.
Rapid Application
Development (RAD)
The primary focus of RAD was
designing methods to reduce costs
by decreasing the time it takes to
develop a project.
Changes included eliminating labor-intensive
written phases of the design stage by
moving to early prototyping and by using
higher-level languages.
Visual Basic, Delphi, and other high-level languages with
good interface capabilities are often used in RAD.
Rapid Application
Development (RAD)
Programmers using RAD follow these guidelines:
Use visual development
(4GL) tools whenever possible.
Rapidly prototype new projects
in order to reduce redesign
time.
Approach
coding with
these priorities:
1 Use existing
code first.
2 Buy existing
code second
3 Write new
code last
Development Tools
Compilers:
• Programs that translate source code into machine
language
• A compiler reads entire program and displays list
of errors that might be present.
Interpreters: Programs that translate instructions
one-by-one as source code is written
Debuggers: Software that locates program bugs
and helps programmers examine operations while
program is running
Programming Errors
The main types of errors programmers must
isolate and fix, one by one, to get a program
working are:
Syntax Errors: Mistakes
in the way program
elements are strung
together; often due to
typing mistakes or
misunderstanding
the rules of the language
Logic Errors:
Incorrect instructions
to computer; thus
action performed
incorrectly
Run-time Errors:
Code mistakes that
cause program to
stop running;
examples: crash
bugs, infinite loops
Style Errors: Ways in which program was
written; program may still run
Hacking Code
Lbgkigmfadmbvfp
Bgfobnkbnvonkngf,.bg
Gnn.ghlnhl.grfggn1nh21
BVV<blmgf.rg
Pglbnn]
Gdb;bvl[pn.g
Fj.
Th[lnl;m,mlp,nbl
Hacking code means writing code
without carefully planning and
structuring the program.
Documentation Tools
Flowcharts: Visual diagram of
an algorithm
CASE Tools: Suite of
applications that help
programming team schedule and
coordinate its operations
Comments: Explanations
inserted into program source
code
Commercial Software Life Cycle
Major Programming Languages
The very first
programming language
was machine code.
Assembly Language
Assembly language was invented to make programming
easier by attaching symbols and words to represent the
numbers in machine code.
Assembly languages run the fastest and use the least
memory.
Older Programming Languages
COBOL:
FORTRAN:
Developed in
1960 by Dr.
Grace Hopper
and used chiefly
for large
business
applications
Created in 1957,
FORTRAN was
language of choice
for math, science,
and engineering
projects.
Both programs are still used by large organizations such as
the IRS, the Social Security Administration, the federal
banking system, the military, and universities.
Older Programming Languages
RPG:
BASIC:
Commonly used
in business
environments,
particularly in
programs for
IBM AS/400
mainframe
Created in 1960s as
a teaching tool,
BASIC only supports
command-line
interfaces; an
interpreted language
High-Level Programming Languages
C
Java
C#
C++
Script Languages
Visual Basic
High-Level Programming Languages
C: Developed at Bell Labs in early 1970s; combines aspects of
BASIC and Assembly language
C++: Superset of C with added features such as objectoriented programming
C#: Object-oriented language derived from C++ and Java
Java: Composed of applets that can run on all types of
platforms, Java was created to facilitate communication on the
Internet
Scripting Languages: Interpreted languages; nonprocedural,
meaning they explain what the computer should do in Englishlike terms but not precisely how to do it; examples: VBScript,
Perl, JavaScript; DHTML, XHTML
On the Horizon
DEVELOPMENT SERVICE PROVIDERS (DSPS)
Development service providers (DSPs) are a new class of online software
development packages that allow software developers in geographically
separate locations to work together on the same software.
ECLIPSE: AN OPEN-SOURCE DEVELOPMENT TOOLKIT
Announced in November 2001by IBM, Eclipse project has the goal of
developing a universal development tool platform into which various
vendors can integrate best-of-breed software development tools. This is a
significant step toward establishing an open-source development toolkit.
SOFTWARE WRITING SOFTWARE
The development of robotics systems for building smaller computer
components is the driving force behind the miniaturization of computers.