Document Details

Uploaded by Deleted User

2015

Deborah Morley, Charles S. Parker

Tags

computer programming programming languages computer science software development

Summary

These lectures cover program development and programming languages, including different approaches to programming, the program development life cycle (PDLC), and various programming languages. The document also touches on tools for facilitating program development and describes various stages in the development process.

Full Transcript

# Understanding Computers: Today and Tomorrow, 15th Edition ## Chapter 13: Program Development and Programming Languages - 15th Edition - Deborah Morley - Charles S. Parker - Copyright 2015 Cengage Learning ### Learning Objectives 1. Understand the differences between structured programming, obj...

# Understanding Computers: Today and Tomorrow, 15th Edition ## Chapter 13: Program Development and Programming Languages - 15th Edition - Deborah Morley - Charles S. Parker - Copyright 2015 Cengage Learning ### Learning Objectives 1. Understand the differences between structured programming, object-oriented programming (OOP), aspect-oriented programming (AOP), and adaptive software development. 2. Identify and describe the activities involved in the program development life cycle (PDLC). 3. Understand what constitutes good program design and list several tools that can be used by computer professionals when designing a program. 4. Explain the three basic control structures and how they can be used to control program flow during execution. 5. Discuss some of the activities involved with debugging a program and otherwise ensuring it is designed and written properly. 6. List some tools that can be used to speed up or otherwise facilitate program development. 7. Describe several programming languages in use today and explain their key features. ### Overview This chapter covers: - The most common approaches to program design and development - The phases of the program development life cycle (PDLC) - Tools that can be used to design and develop a program - Good program design techniques and types of program errors - Popular programming languages ### Approaches to Program Design and Development #### Procedural Programming - An approach to program design in which a program is separated into small modules that are called by the main program or another module when needed. - **Procedure call** - locating specific tasks in procedures (modules or subprograms) that are called by the main program when needed. - **Allows each procedure to be performed as many times as needed; multiple copies of code not needed.** - **Prior to procedural programming, programs were one large set of instructions (used GOTO statements)**. #### Structured Programming - Goes even further, breaking the program into small modules (Top-down design). - **Variables** - Named memory locations that are defined for a program. - Used to store the current value of data items used in the program. #### Figure 13-1: Structured Programming This figure depicts a structured program that is divided into individual modules, each module representing a very specific processing task. The control program calls each module as needed. The figure shows a payroll application with the following modules: input, gross pay, deductions, net pay, output, compute federal taxes, compute state taxes, compute retirement contribution, compute other deductions, issues checks, and print payroll report. #### Object-Oriented Programming (OOP) - Programs consist of a collection of objects that contain data and methods to be used with that data. - **Class** - a group of objects that share some common properties. - **Instance** - An individual object in a class - Inherits the attributes and methods of the class. - Objects can be accessed by multiple programs - **Class libraries** #### Figure 13-2: Button Class This figure depicts the Button Class. It illustrates that each object (instance) in the Button Class has four attributes to hold data about the current state of the button and three methods to perform actions when messages are recceived. **Attributes:** - Data that describes the object. - Can be in a variety of formats. **Methods:** - Perform actions on an object. - Can be used with different types of objects. #### Aspect-Oriented Programming (AOP) - Separates functions so program components can be developed and modified individually from one another. - The components can be easily reused with separate nonrelated objects. #### Adaptive Software Development - Designed to make program development faster and more efficient and focuses on adapting the program as it is being written. - Features iterative and/or incremental development. #### Agile Software Development - Goal is to create software quickly. - Focuses on building small functional program pieces as the project progresses. - Emphasizes teams of people working closely together (programmers, managers, business experts, customers, and so forth). - Some mobile developers are using continuous mobile innovation. ### The Program Development Lifecycle (PDLC) #### Program Development (application software development) - The process of creating application programs. #### Program Development Life Cycle (PDLC) - The five phases of program development. #### Figure 13-3: Program Development Life Cycle (PDLC) The figure shows the five phases of the PDLC: problem analysis, program design, program coding, program debugging and testing, and program implementation and maintenance. Each phase produces some type of documentation to forward to the next phase. #### Problem Analysis - The problem is considered and the program specifications are developed. - **Specifications developed during the PDLC are reviewed by the systems analyst and the programmer (the person who will code the program).** - **Goal is to understand the functions the software must perform.** #### Documentation: Program Specifications - Result of the first phase of the PDLC outlining what the program must do. #### Program Design - The program specifications are expanded into a complete design of the new program. - **Algorithm for the program is developed.** - **Careful planning and design of a computer program are extremely important.** #### Program Design Tools - Planning tools that include diagrams, charts, tables, and models. - **Structure Charts (hierarchy charts) - depict the overall organization of a program.** - **Flowcharts - show graphically, step-by-step, the actions a computer program will take.** - use special symbols and relational operators - can be drawn by hand or with flowcharting software. - **Wireframes** - visual representation of the overall design and logic of an app or Web site - **Pseudocode** - uses English-like statements to outline the logic of a program, rather than the flowchart's graphical symbols. - **Unified Modeling Language (UML) Models** - Set of standards notations for creating business models. - Widely used in object-oriented programs. - Includes class diagrams and case diagrams. #### Figure 13-4: A Flowchart Example This figure shows a flowchart with the following steps: 1. Start 2. Set counter to 0 3. Read an employee record 4. Is there a record? - Yes: - Computer experience? - Yes: - Company service >= 5 years? - Yes: - Print employee Name - Increment counter - Read another record - No: - Next statement - Read another record - No: - Next statement - Read another record - No: - Print counter - Stop #### Figure 13-5: Wireframes The figure shows six different wireframe designs for mobile app screens. #### Figure 13-6: Pseudocode The figure shows a pseudocode with the following steps: 1. Start 2. Counter = 0 3. Read a record 4. Do While there are records to process - If computer experience - If company service >= 5 years - Print employee name - Increment counter - Else - Next statement - End if - Else - Next statement - End if 5. Read another record 6. End Do 7. Print counter 8. Stop #### Figure 13-7: Class Diagrams The figure shows a class diagram for Bicycles, including attributes and methods for Bicycles, and two instances of the class: Bike1 and Bike2. #### Control Structures - A pattern for controlling the flow of logic in a computer program, module, or method. - **The Sequence Control Structure** - a series of statements that follow one another. - **The Selection Control Structure** - multiple paths, with direction dependent on the result of a certain condition. - If-then-else - Case control structure - **The Repetition Control Structure (iteration control structure)** - series of statements in a loop that are repeated until a particular condition is met. - Do while structure - Do until structure #### Figure 13-8: The Three Fundamental Control Structures The figure shows the three fundamental control structures: sequence, If-then-else, and case. Each structure has only one entry point and only one exit point. #### Good Program Design - Is essential. - Saves time. - **Good Program Design Principles** - **Be Specific** - all things that the program must do or consider must be specified. - **Follow the One-Entry-Point/One-Exit-Point Rule**. - **No Infinite Loops or logic Errors** - an infinite loop is a series of steps that repeat forever. #### Figure 13-9: Writing Instructions for a Computer Versus a Person This figure shows a list of instructions for a person to make a piece of toast and a list of instructions for a computer to make a piece of toast. It illustrates that a computer requires step-by-step instructions. #### Program Design Testing - Design should be tested to ensure the logic is correct. - **Desk check** - **Tracing tables** #### Documentation: Design Specifications - Illustrates the program needed to fulfill the program requirements. - Expressed using structure charts, flowcharts, wireframes, pseudocode, and UML models. - Include any test data and results from desk checking. #### Figure 13-10: Desk Checking a Flowchart. The figure shows a desk check result for a flowchart for adding two numbers. It includes the flowchart stage, counter, decision test results, number, and sum. The test data is 6 and 3. The expected result is sum = 9. The actual result is sum = 9. The figure also shows a desk check result for an incorrect flowchart with the same test data. The expected result is sum = 9. The actual result is sum = 6. The figure also shows a screenshot of the incorrect program design. #### Program Coding - The program code is written using a programming language. #### Choosing a Programming Language - Suitability to the application. - Integration with other programs. - Standards for the company. - Programmer availability. - Portability if being run on multiple platforms. - Development speed. #### The Coding Process - The source code is the computer program before it is compiled. #### Coding Standards - Rules designed to standardize programming. - Makes programs more 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. #### Figure 13-11: Program Comments This figure shows an example of program comments, noting that they are usually preceded by certain symbols. It also highlights that comments at the top of the program should identify the name, author, date written and date last modified, purpose, and variables used. It also highlights that comments in the main part of the program should indicate what each section is doing. - Pretested, error-free code segments that can be used over and over again with minor modifications. - Can greatly reduce development time. #### Documentation: Documented Source Code - Program coding phase results in the program written in the desired programming language. - Should include enough comments (internal documentation) so that the source code is easy to understand and update. #### Technology and You Box: Programming Contests - One example is the TopCoder Open. - Six competitions - Initial qualifying rounds are online - 48 semifinalists compete on site. - $300,000 in prizes - Other competitions are available online. #### The Program Development Lifecycle (PDLC) #### Program Debugging and Testing - The process of ensuring a program is free of errors (bugs) and works as it is supposed to. #### Translating Coded Programs Into Executable Code - Coded programs need to be translated from source code written by the programmer to object code the computer can execute. - Converted using a language translator - programs that converts source code to object code. - **Compilers** - language translator that converts an entire program into machine language before executing it. - Can be designed for specific programming languages, such as Java or Python. - **Interpreters** - translates one line of code at a time. - **Assemblers** - convert assembly language programs into machine language. #### Figure 13-13: Syntax Errors The figure shows a screenshot of a syntax error in a Visual Basic program. This figure illustrates syntax errors, which occur when the syntax (grammar rules) for a program is not followed precisely. #### Inside the Industry Box: The Original Program "Bug" - A bug is an error that causes a program to malfunction. - First recorded instance of the term "bug" occurred in 1945. - Short circuit caused by a moth caught between two contacts in one of the computer's relays. #### Preliminary Debugging - **Compiler and Syntax Errors** - as programs are compiled or interpreted, errors occur which prevent the program from running properly. - Syntax errors occur when the programmer has not followed the rules of the programming language. - **Run Time and Logic Errors** - run time errors occur when the program is running. - Logic errors are errors in the logic of the program. - Program will run but produces incorrect results. #### 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. #### Translating Coded Programs into Executable Code - Coded programs need to be translated from source code written by the programmer to object code the computer can execute. - Converted using a language translator - programs that converts source code to object code. - **Compilers** - language translator that converts an entire program into machine language before executing it. - Can be designed for specific programming languages, such as Java or Python. - **Interpreters** - translates one line of code at a time. - **Assemblers** - convert assembly language programs into machine language. #### Figure 13-13: Syntax Errors The figure shows a screenshot of a syntax error in a Visual Basic program. This figure illustrates syntax errors, which occur when the syntax (grammar rules) for a program is not followed precisely. #### Inside the Industry Box: The Original Program "Bug" - A bug is an error that causes a program to malfunction. - First recorded instance of the term "bug" occurred in 1945. - Short circuit caused by a moth caught between two contacts in one of the computer's relays. #### Preliminary Debugging - Compiler and Syntax Errors - as programs are compiled or interpreted, errors occur which prevent the program from running properly. - Syntax errors occur when the programmer has not followed the rules of the programming language. - **Run Time and Logic Errors** - run time errors occur when the program is running. - Logic errors are errors in the logic of the program. - Program will run but produces incorrect results. #### 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. #### Translating Coded Programs into Executable Code - Coded programs need to be translated from source code written by the programmer to object code the computer can execute. - Converted using a language translator - programs that converts source code to object code. - **Compilers** - language translator that converts an entire program into machine language before executing it. - Can be designed for specific programming languages, such as Java or Python. - **Interpreters** - translates one line of code at a time. - **Assemblers** - convert assembly language programs into machine language. #### Figure 13-13: Syntax Errors The figure shows a screenshot of a syntax error in a Visual Basic program. This figure illustrates syntax errors, which occur when the syntax (grammar rules) for a program is not followed precisely. #### Inside the Industry Box: The Original Program "Bug" - A bug is an error that causes a program to malfunction. - First recorded instance of the term "bug" occurred in 1945. - Short circuit caused by a moth caught between two contacts in one of the computer's relays. #### Preliminary Debugging - Compiler and Syntax Errors - as programs are compiled or interpreted, errors occur which prevent the program from running properly. - Syntax errors occur when the programmer has not followed the rules of the programming language. - **Run Time and Logic Errors** - run time errors occur when the program is running. - Logic errors are errors in the logic of the program. - Program will run but produces incorrect results. #### Figure 13-14: Logic Errors The figure shows a screenshot of a Visual Basic program with logic errors. This figure illustrates Logic Errors, which are more difficult to identify. Dummy print statements can help determine the error. #### Testing - Occurs after the preliminary debugging process to find additional errors. - Uses good test data - data that is very similar to the actual data that will be used in the finished program. - Tests conditions that will occur when the program is implemented. - Checks for nonstandard situations or possible input errors. - **Two Stages:** - Alpha test (internal on-site test) - Beta test (outside test) #### Documentation: Completed Program Package - Copy of the test data, test results, finished program code, and other documentation generated during the testing phase should be added to the program package. - Developer documentation - User documentation #### Program Implementation and Maintenance - Once the system containing the program is up and running, the implementation process is complete. - **Program Maintenance** - the process of updating software so it continues to be useful. - Very costly. #### Documentation: Amended Program Package - Program package should be updated to reflect new problems or issues that occur and what changes to the program were necessary. #### Quick Quiz 1. Which approach to programming uses the concept of inheritance? - Object-oriented 2. True or False: An infinite loop is an example of a logic error. - True 3. A ```flowchart``` is a program design tool that shows graphically, step-by-step, the actions a computer program will take. ### Tools for Facilitating Program Development #### Application Lifecycle Management (ALM) Tools - Creating and managing an application during its entire lifecycle, from design through retirement. - **Tools include:** - **Requirements management** - keeps track of and manages the program requirements, which are defined and then modified. - **Configuration management** - keeps track of the progress of a program development project. - **Issue tracking** - records issues, such as bugs or other problems, that arise during development or after the system is in place. #### Application Generators - Software programs that help programmers develop software. - **Macros** - a sequence of saved actions that can be replayed when needed. - Programmers write them in a macro programming language, such as Visual Basic for Applications. #### Report Generators and User Interface (UI) Builders - **Report Generator** - prepares reports to be used with a software program, quickly and easily. - **User Interface (UI) Builders** - create the menus, forms, and input screens used with a program or database. - **Integrated Development Environment (IDE)** - a set of programming tools for writing software applications #### Figure 13-16: User Interface (UI) Builders The figure shows two different User Interface (UI) builders, one from OpenGate software and one from Microsoft. It highlights that UI builders are used to create the user interface for a software program. #### Device Development Tools - Assist with developing embedded software to be used on devices, such as cars, ATM machines, and consumer devices. #### Integrated Development Environments (IDEs) - Collection of tools used with a particular programming language to develop and test software. - Software Development Kits (SDKs) - programming packages designed for a particular platform. - Enables programmers to develop applications for that platform more quickly and easily. #### Application Program Interfaces (APIs) - Help applications interface with a particular operating system. - Often used in conjunction with Web sites. - Google's Maps API and Google's OpenSocial API allow developers to add Google Maps or social networking applications to Web sites, respectively. #### Trend Box: Mobile App Builders - Many tools are available to help develop mobile apps and deploy them on various platforms - One example is appsbar - After the app is created, appsbar tests it and then submits it to major app markets for publication #### Quick Quiz 1. Which of the following is not an Application Lifecycle Management (ALM) tool? - Application program interface (API) 2. True or False: A software development kit (SDK) is designed for a particular platform and allows programmers to develop applications quickly for that platform. - True 3. A **macro** is a sequence of saved actions (such as keystrokes, mouse clicks, and menu selections) that can be replayed whenever needed within the application program in which it was created. ### Programming Languages #### What Is a Programming Language? - A set of rules, words, symbols, and codes used to write computer programs. - To write a program, you need the appropriate software for the programming language being used. #### Categories of Programming Languages - Classified by the types of programs they are designed to create: procedural or object-oriented languages. - Often categorized by their level or generation. - **Low-Level Languages (earliest programming languages)** - **Machine language** - written at a very low level, just using 1s and 0s. - First generation of programming languages. - **Assembly language** - uses names and other symbols to replace some of the 1s and 0s in machine language. - Second generation of programming languages. - Programs take longer to write and maintain. - **High-Level Languages** - Closer to natural languages. - Machine independent. - Includes 3GLs (FORTRAN, BASIC, COBOL, C, etc.) and object-oriented languages (Visual Basic, C#, Python, Java, etc.). - **Visual programming environments (VPEs)** - use graphical interface to create programs; Some are designed for educational purposes. - **Scratch** - **Fourth-Generation Languages (4GLs)** - even closer to natural languages and easier to work with than high-level languages. - Declarative, rather than procedural. - Commonly used to access databases. #### Figure 13-18: Assembly and Machine Language The figure highlights machine language instructions in binary form, and assembly instructions. It also shows how the instructions translate into machine language. #### Figure 13-19: The Scratch Graphical Programming Language This figure shows a screenshot of the Scratch programming language, which uses visual block to design a program. #### Common Programming Languages #### FORTRAN - High-level programming language used for mathematical, scientific, and engineering applications. - Still used today for high-performance computing tasks (weather forecasting). - **Fortress** - a version designed for high-performance computing, which takes advantage of multi-core processors and computers with multiple processors. - Not being updated #### Figure 13-20: The Adding-Two-Numbers Program Written in FORTRAN The figure shows an example of a program written in FORTRAN. #### COBOL - Designed for business transaction processing. - Makes extensive use of modules. - Strength lies in batch processing and its stability. - Programs are lengthy and take a long time to write. - Considered to be outdated by some. - New versions are evolving. - COBOL.NET #### Figure 13-21: The Adding-Two-Numbers Program Written in COBOL The figure shows an example of a program written in COBOL. #### Pascal - Named after mathematician Blaise Pascal. - Created as a teaching tool to encourage structured programming. - Contains a variety of control structures used to manipulate modules systematically. #### Figure 13-22: The Adding-Two-Numbers Program Written in Pascal The figure shows an example of a program written in Pascal. #### BASIC and Visual Basic - Easy-to-learn, high-level programming language that was developed to be used by beginning programmers. - **Visual Basic** - an object-oriented version of BASIC that uses a visual environment. #### Figure 13-23: The Adding-Two-Numbers Program Written in BASIC The figure shows an example of a program written in BASIC. #### C, C++, and C# - **C** - much closer to assembly language than other high-level languages. - **C++** - an object-oriented version of C that is very popular for graphical applications - **C# (C sharp)** - a hybrid of C and C++ that is used to create Web applications, XML-based Web services, and Windows apps. #### Objective-C - For iPhone and other Apple applications. #### Figure 13-24: The Adding-Two-Numbers Program Written in C++ The figure shows an example of a program written in C++. #### Java - High-level, object-oriented programming language frequently used for Web-based applications. - Java programs are compiled into bytecode. - Can run on any computer that includes Java Virtual Machine (Java VM) - Can be used to write Java applets #### Figure 13-25: The Adding-Two-Numbers Program Written in Java The figure shows an example of a program written in Java. #### Dart - High-level, open-source, object-oriented programming language developed by Google. - Designed to replace JavaScript in Web applications. #### Figure 13-26: The Adding-Two-Numbers Program Written in Dart The figure shows an example of a program written in Dart. #### Ruby - High-level, open-source, object-oriented programming language that is often used to develop Web applications. #### Python - Open-source, dynamic, object-oriented language that can be used to develop a variety of applications: e.g., gaming, scientific, and databases. - Used by large organizations and some colleges, such as MIT #### Figure 13-27: The Adding-Two-Numbers Program Written in Python The figure shows an example of a program written in Python. #### How It Works Box: Creating Apps Using the Android SDK and Eclipse The figure shows a series of screenshots showing the steps to creating an Android app using the Android SDK and Eclipse. The screenshots show the following steps: 1. Create a new project 2. Add elements to the initial activity to create the UI 3. Edit the XML and Java files as needed 4. Launch the app in the desired emulator. #### Quick Quiz 1. An example of a high-level programming language is: - Pascal 2. True or False: Visual Basic is an object-oriented version of COBOL. - False 3. Java applets are small programs written in the ```Java``` programming language. #### Summary This chapter covers program development, including the phases of the program development life cycle (PDLC), program design, program coding, debugging, testing, and implementation. It also covers popular programming languages, including assembly language, machine language, FORTRAN, COBOL, Pascal, BASIC, Visual Basic, C, C++, C#, Objective-C, Java, Dart, Ruby, and Python. It also covers various tools that can be used to facilitate program development, including application lifecycle management (ALM) tools, application generators, report generators and UI builders, device development tools, IDEs, and APIs.

Use Quizgecko on...
Browser
Browser