Understanding Computers, Chapter 13

advertisement
Understanding Computers
Today and Tomorrow 12th Edition
Chapter 13:
Program Development
and Programming
Languages
Learning Objectives
• Understand the differences between structured
programming, object-oriented programming (OOP),
aspect-oriented programming (AOP), and adaptive
software development.
• Identify and describe the activities involved in the
program development life cycle (PDLC).
• Understand what constitutes good program design
and list several tools that can be used by computer
professionals when designing a program.
Chapter 13
Understanding Computers, 12th Edition
2
Learning Objectives
• Explain the three basic control structures and how
they can be used to control program flow during
execution.
• Discuss some of the activities involved with coding,
debugging, maintaining, documenting, and ensuring
the quality of programs.
• List some tools that can be used to speed up or
otherwise facilitate the program development process.
• Describe several programming languages in use
today.
Chapter 13
Understanding Computers, 12th Edition
3
Overview
• This chapter covers:
– The most common approaches to program design
and development
– The steps in the program development life cycle
(PDLC)
– Tools that can facilitate program development
– Popular programming languages
Chapter 13
Understanding Computers, 12th Edition
4
Approaches to Program Design
and Development
• Procedural programming: Focuses on the step-bystep instructions that tell the computer what to do
– Uses procedures (modules, subprograms): Smaller
sections of code that perform particular tasks
– Allows each procedure to be performed as many
times as needed without requiring multiple copies
of code
– Prior to procedural programming, programs were
one large set of instructions containing statements
that sent control to different parts of the program as
needed (i.e. GOTO statements)
– Structured programming: Breaks the program into
small chunks
• Top-down design
Chapter 13
Understanding Computers, 12th Edition
5
Approaches to Program Design
and Development
– Variables: Named memory locations
that are defined for a program
• Used to store the current value of
data items used in the program
Chapter 13
Understanding Computers, 12th Edition
6
Approaches to Program Design
and Development
• Object-oriented programming (OOP): Programs
consist of a collection of objects
– Objects: Contain data and methods to be used with
that data
– Class: Group of objects that share some common
properties
– Instance: An individual object in a class
– Attributes: Data about the state of an object
– Methods:
Perform
actions on an
object
Chapter 13
Understanding Computers, 12th Edition
7
Approaches to Program Design
and Development
• Aspect-oriented programming (AOP): Breaks program
into small pieces that overlap in functionality as little
as possible
– Program components can be developed and
modified individually, and easily reused
• Adaptive software development: Designed to make
program development faster and more efficient and
focus on adapting the program as it is being written
– Iterative: Cyclical approach that allows the
repetition of steps and tasks as needed
– Incremental: Developing one piece at a time
– Includes RAD (rapid application development) and
extreme programming (XP)
– More recent adaptive software development
approaches are called agile software development
Chapter 13
Understanding Computers, 12th Edition
8
The Program Development Life
Cycle (PDLC)
• Program development: The process of creating
application programs
• Program development life cycle (PDLC):The steps
involved with creating programs:
Chapter 13
Understanding Computers, 12th Edition
9
The Program Development Life
Cycle (PDLC)
• Problem analysis: The problem is considered and the
program specifications are developed
– Specifications developed during the SDLC are
reviewed by the systems analyst and the
programmer (the person who will code the
program)
– Goal: To understand the functions the software
must perform
– Documentation: Includes program specifications
(what it does, timetable, programming language to
be used, etc)
Chapter 13
Understanding Computers, 12th Edition
10
The Program Development Life
Cycle (PDLC)
• Program design: The set of steps needed in order for
the program to perform the tasks it is supposed to
perform (algorithm) is developed
– Good program design is extremely important
– Program design tools
• Structure charts: Depict the overall organization
of a program
• Flowcharts: Show
graphically step-by-step
how a computer program
will process data
• Use special symbols and
relational operators
Chapter 13
Understanding Computers, 12th Edition
11
Flowcharts
Chapter 13
Understanding Computers, 12th Edition
12
The Program Development Life
Cycle (PDLC)
• Pseudocode: Uses English-like statements to
outline the logic of a program
Chapter 13
Understanding Computers, 12th Edition
13
The Program Development Life
Cycle (PDLC)
• Unified Modeling Language (UML) Models: Set
of standard notations for creating business
models
– Widely used in object-oriented programs
– Includes class diagrams, use case diagrams,
etc.
• Business Processing Modeling Notation
(BPMN): Graphical notation used to depict the
steps in a business process
– Expresses business processes graphically
using Business Process Diagrams
– Look similar to flowcharts
– Designed to be understood by everyone
Chapter 13
Understanding Computers, 12th Edition
14
Unified Modeling Language (UML)
Models
Chapter 13
Understanding Computers, 12th Edition
15
The Program Development Life
Cycle (PDLC)
– Control structure: A Pattern for controlling the flow
of logic in a computer program
• Sequence control structure: Series of
statements that follow one another
• Selection control structure: Multiple paths,
direction depends on result of test
– If-then-else
– Case
• Repetition control structure: Repeat series of
steps
– Do-while
– Do-until
Chapter 13
Understanding Computers, 12th Edition
16
Control Structures
Chapter 13
Understanding Computers, 12th Edition
17
Control Structures
Chapter 13
Understanding Computers, 12th Edition
18
The Program Development Life
Cycle (PDLC)
– Good program design:
• Saves time
• Creates better programs
– Good program design principles:
• Be specific
– All things the program must do need to be
specified
• One-entry-point/one-exit-point rule
• No infinite loops or other logic errors
– Infinite loop: Series of steps that repeat
forever
– Design should be tested to ensure logic is correct
• Desk check; tracing tables
– Documentation: Includes design specifications
Chapter 13
Understanding Computers, 12th Edition
19
Good Program Design
Chapter 13
Understanding Computers, 12th Edition
20
Program Design Testing
Chapter 13
Understanding Computers, 12th Edition
21
The Program Development Life
Cycle (PDLC)
• Program coding: The process of writing the
programming language statements to create a
computer program
– When choosing a programming language,
consider:
• Suitability to the application
• Integration with other programs
• Standards for the company
• Programmer availability
• Portability if being run on multiple platforms
• Development speed
– Coding creates source code
Chapter 13
Understanding Computers, 12th Edition
22
Coding Standards
– Coding standards: A list of rules designed to
standardize programming styles
• Make programs more universally readable and
easier to maintain
• Includes the proper use of comments to:
– Identify the programmer and last
modification date
– Explain variables used in the program
– Identify the main parts of the program
– Reusable code: Generic code segments that can
be used over and over again with minor
modifications
• Can greatly reduce development time
– Documentation: Includes documented source code
Chapter 13
Understanding Computers, 12th Edition
23
Coding Standards
Chapter 13
Understanding Computers, 12th Edition
24
The Program Development Life
Cycle (PDLC)
• Program debugging and testing: The process of
ensuring a program is free of errors (bugs) and works
as it is supposed to
– Before they can be debugged, coded programs
need to be translated into executable code
• Source code: Coded program before it is
compiled
• Object code: Machine language version of a
program
• Language translator: Program that converts
source code to machine language
Chapter 13
Understanding Computers, 12th Edition
25
The Program Development Life
Cycle (PDLC)
• Types of language translators:
– Compilers: Combines
program with other
object modules and
creates a finished
executable program
– Interpreters:
Translates one line of
code at one time
– Assemblers: Convert
assembly language
programs
into
machine
language
Chapter 13
Understanding Computers, 12th Edition
26
The Program Development Life
Cycle (PDLC)
̶
Chapter 13
Preliminary debugging: Finds initial errors
• Compiler errors: Must be corrected before the
logic of the program can be tested
• Syntax errors: Occur when the programmer
has not followed the rules of the programming
language
̶ Program won’t run; usually an error
message is displayed
• Run time error: Occurs when the program is
running
̶ Often logic errors: Program will run but
produces incorrect results
̶ Dummy print statements can help locate
logic errors and other run time errors
Understanding Computers, 12th Edition
27
Preliminary Debugging
Chapter 13
Understanding Computers, 12th Edition
28
Preliminary Debugging
Chapter 13
Understanding Computers, 12th Edition
29
The Program Development Life
Cycle (PDLC)
– Testing occurs after the program appears to be
correct to find any additional errors
• Should use good test data
• Tests conditions that will occur when the
program is implemented
• Should check for coding omissions (product
quantity allowed to be < 0, etc.)
• Alpha test (inside organization)
• Beta test (outside testers)
– Documentation: Completed program package
(user’s manual, description of software commands,
troubleshooting guide to help with difficulties, etc.)
Chapter 13
Understanding Computers, 12th Edition
30
The Program Development Life
Cycle (PDLC)
• Program implementation and maintenance: Installing
and maintaining the program
– Once the system containing the program is up and
running, the implementation process is complete
– Program maintenance: Process of updating
software so it continues to be useful
• Very costly
– Documentation: Amended program package
Chapter 13
Understanding Computers, 12th Edition
31
Tools for Facilitating
Program Development
• Application Lifecycle Management (ALM): Creating
and managing an application during its entire lifecycle,
from design through testing
– Tools include:
• Requirements management: Keeping track of
and managing the information needs of users
– Requirements definition software
– Requirements management software
• Configuration management: Keeping track of
the progress of a program development project
• Program design tools to generate diagrams,
code, etc.
Chapter 13
Understanding Computers, 12th Edition
32
Tools for Facilitating
Program Development
• Application generator: Software product that enables
users to code new applications quickly
– Macro recorders: Record and play back a series of
keystrokes
– Report and form generators: GUI tools that enable
individuals to
prepare reports
and forms
quickly
Chapter 13
Understanding Computers, 12th Edition
33
Tools for Facilitating
Program Development
• Device software development tools: Assist with
developing software to be used on devices, such as
cars, ATM machines, consumer devices, etc
• Software development kits (SDK): Programming
package designed for a particular platform that
enables programmers to develop applications more
quickly and easily
– Released by hardware or software companies
(Microsoft, Apple, etc.)
• Application Program Interfaces (API): An interface
designed to help applications interface with a
particular operating system
– Often used in conjunction with Web sites
Chapter 13
Understanding Computers, 12th Edition
34
Programming Languages
• Programming language: A set of rules used to write
computer programs
– To write a program, you need appropriate software
for the programming language you will be using
• Categories of programming languages
– Low-level languages: Difficult to code in; machine
dependent
• Machine language: 1s and 0s
• Assembly language: Includes some words and
symbols
Chapter 13
Understanding Computers, 12th Edition
35
Programming Languages
Chapter 13
Understanding Computers, 12th Edition
36
Programming Languages
– High-level languages: Closer to natural languages
and so are easier to write in
• Machine independent
• Includes third-level procedural languages such
as FORTRAN, BASIC, COBOL, Pascal, and C,
as well as newer object-oriented languages
such as Visual Basic, C++, C#, Python, Ruby,
and Java
– Fourth-generation languages (4GLs): Even closer
to natural languages and easier to work with than
3GLs
• Declarative rather than procedural
• Includes structured query language (SQL) used
with databases
Chapter 13
Understanding Computers, 12th Edition
37
Programming Languages
– Natural programming languages: Users can
communicate in their native language
• Doesn’t have to follow program syntax
• In the infancy stage
– Visual programming languages: Uses a visual
programming environment
• User can use mouse and graphical interface
and the code is automatically generated
• Visual versions of many programming
languages
• Visual programming environment (VPE): Use
visual elements to assist in program
development but still require some coding
Chapter 13
Understanding Computers, 12th Edition
38
Common Programming Languages
• FORTRAN: High-level programming language used
for mathematical, scientific, and engineering
applications
– Efficient for math
and scientific
applications
Chapter 13
Understanding Computers, 12th Edition
39
Common Programming Languages
• COBOL: Designed for business transaction
processing
– Makes extensive use of modules and submodules
– Being phased out in many organizations
Chapter 13
Understanding Computers, 12th Edition
40
Common Programming Languages
• Pascal: Created as a teaching tool to encourage
structured programming
– Contains a variety of control structures used to
manipulate modules systematically
Chapter 13
Understanding Computers, 12th Edition
41
Common Programming Languages
• BASIC: Easy-to-learn, high-level programming
language that was developed to be used by beginning
programmers
– Visual Basic: Object-oriented version of BASIC
which helps programmers quickly and easily create
programs through the use of a visual environment
Chapter 13
Understanding Computers, 12th Edition
42
Common Programming Languages
• C: Designed for system programming
• C++, and C#: Object-oriented versions of C
Chapter 13
Understanding Computers, 12th Edition
43
Common Programming Languages
• Java: High-level, object-oriented programming
language frequently used for Web-based applications
– Platform independence is one of Java’s biggest
advantages
– Any operating system or browser that understands
Java (compiled Java programs) can run Java
bytecode applications
– Is one of the most popular programming languages
today
– Can be used to write Java applets
Chapter 13
Understanding Computers, 12th Edition
44
Common Programming Languages
Chapter 13
Understanding Computers, 12th Edition
45
Common Programming Languages
• Python: Open-source, dynamic, object-oriented
language that can be used to develop a variety of
applications
– Gaming, scientific, database, and Web applications
– Only recently gaining a following
Chapter 13
Understanding Computers, 12th Edition
46
Common Programming Languages
• Ruby: Open-source, object-oriented language that can
be used to create general-purpose or Web
applications
– Uses a syntax that is fairly easy to read and write,
allowing programmers to create database-driven
Web
applications
easily and
quickly
Chapter 13
Understanding Computers, 12th Edition
47
Summary
• Approaches to Program Design and Development
• The Program Development Life Cycle (PDLC)
• Tools for Facilitating Program Development
• Programming Languages
Chapter 13
Understanding Computers, 12th Edition
48
Download