7 Creative Development

5 Steps to a 5: AP Computer Science Principles 2024 - Sway J.S. 2023

7 Creative Development
STEP 4 Review the Knowledge You Need to Score High

IN THIS CHAPTER

Summary: People are creative! We may develop something just for us and our family or friends or an app to share with the world, for free or for a fee. There are processes in place to create well-developed and tested programs that include multiple stages of designing, coding, and testing. Collaboration, feedback, and iteration are key aspects of software development.

Image

Key Ideas

Image Collaboration on projects with a diverse team who represent a variety of backgrounds, experience, and perspectives can develop a better computing product.

Image A development process to design, code, and implement a software application using feedback, testing, and reflection should be used to create software applications.

Image Documentation should be developed that includes the requirements, constraints, and each program’s purpose. Internal comments in programs should also be included.

Image Programs must be adequately tested before releasing them to others to use. Debugging is the process of finding and correcting errors in programs.

Key Terms

Code segment

Collaboration

Comments

Debugging

Event-driven programming

Incremental development process

Iterative development process

Logic error

Overflow error

Program

Program behavior

Program documentation

Program input

Program output

Prototype

Requirements

Runtime error

Syntax error

Testing

User interface

Creativity in Computer Science

Computer Science is full of opportunities to be creative! Creativity is a way to express your personal ideas, color combinations, fonts, wording, and images, among countless other options. There are numerous design decisions needed for a programming application to be easy to use and interesting to view. For example, there is a great deal of software written for entertainment purposes. Creativity is essential for these so that people will want to use their time and possibly money to view or play them. Similarly, there is a great deal of software available to use to develop your own creation, from audio and visual files to mobile apps and everything in between. These software programs allow the creation and continued refinement from lower levels of detail or “rough sketches” to highly precise, “polished” ones. Depending on the ultimate planned outcome, software tools can provide an opportunity to create a sample or working prototype to obtain suggestions for improvement prior to investing the time and money required to create a “ready to sell” version.

Computing Innovations

Computer artifacts are anything created by a person using a computer. These include, but are not limited to, apps, games, images, videos, audio files, 3D-printed objects, and websites. Sometimes learning a new software tool and experimenting with the different features the software provides can result in a creative and unexpected result leading to a new innovation.

There are many types of innovations, but computing innovations have to include a computer program as part of its functionality. For example, a map was an innovation in its day, but maps are not computing innovations. However, GPS (Global Positioning System) driving instructions, one of my favorite innovations, and digital maps such as MapQuest and Google Maps, rely on computer code to provide their functionality.

Image

Computing innovations can be a physical device, such as the GPS, or a virtual one, such as MapQuest or Google Earth. A computing innovation’s purpose can be to solve a problem, such as needing directions on how to get somewhere or something that is entirely new. Understanding the purpose of the innovation helps developers create the solution to implement it. Think of the first rocket ships designed to travel into orbit and then the moon. It had never been done, so it was truly innovative! The team members may not have known how they were going to do it initially, but they at least understood what their ultimate goal was. And they succeeded!

Image

Collaboration

Collaboration has many benefits in the software development world. From the start, by working with sponsors of the project to identify its purpose, and then closely working with those who will actually use the software to understand the functionality needed, collaborative efforts consistently prove to save time and result in a better outcome by providing differing views and ideas in the development process. It can make for occasional lively meetings as team members share their views and negotiate design decisions too! A more homogeneous development team may inadvertently include bias in their software. The variety of views and experiences in a more diverse project team helps identify bias or prevent it in the first place. This is generally true in any field, and computer science is no exception. It also helps to have more than one person listening to the users to provide a clear understanding of the goals to meet or issues to solve. We hear and process information based on our experiences, so multiple perspectives can better identify and clarify what the application should provide early in the process. I once worked with a project team that used color to indicate crucial information. Red was an alert, yellow was cautionary, and green represented normal processing. The colors were not in a particular order like a traffic light was. It wasn’t until someone who was color-blind tested the software that anyone realized that it couldn’t be based on color alone. Text had to be added along with the color indicators.

Image

With team members with different backgrounds, experiences, talents, and locations, effective team dynamics are essential to ensuring they work well together. This includes communicating with each other, both during agreements and disagreements, in a productive manner. Effective teams are able to negotiate and resolve conflicts to the betterment of the project, leaving the team working relationships intact. Consensus building is an important process and skill, and newly formed teams often go to workshops to develop or improve their communication and consensus building skill set.

Professional programmers seldom work in isolation. Teams are formed to complete the project. Collaboration among the team members and with their customers is instrumental to creating a quality solution. Programmers work with teams to design a solution, and may work individually to create sections of code, similar to designers, writers, composers, and artists of all types when they are producing something. They then come together for testing and feedback.

Image

Communication among team members is crucial as they program separate modules that will need to work together for the total solution. Pair programming is one commonly used method to help facilitate collaboration as well as create correct code. One person types in the program while the other reviews the program, states what to type in, and watches for errors. It also helps to have someone other than the developer test the program code to identify problems and help find solutions. It is always good to have more than one person understand the problem and solutions in the event a key team member leaves the project team before the work is finished.

Many companies have a national if not international presence or vendors in other locations. Technology makes it possible to collaborate with people in a variety of locations even if you are programming for yourself or a smaller organization. Many tools provide a way to share documents via the cloud for people to work on together, regardless of their time zone or location.

Online tools such as shared documents to record progress, problems, and solutions can aid in collaboration, especially when team members are in different locations from each other.

Development Process

Projects are all around us, whether it’s writing a research paper for school, completing a science lab, producing a graduation ceremony, or planning a celebration. Computer science also has projects where teams or individuals write code to create solutions for their user or customer.

Image

So you have a great idea for an app, or you have a project to complete for school or a part-time job you have. How do you get started to get the great idea out of your head and ready for someone to use? People over many years have faced this same dilemma. Fortunately, development processes have been created for individuals and teams to use to get us moving in the right direction.

A development process helps individuals and teams bring their ideas to fruition. Many people have a method or their own process to follow to get their creative juices flowing. This can be a traditional process, similar to an outline or timeline a person might follow, or an approach that is more “trial and error” or exploratory in nature. Both methods can create entirely new software applications or create a new use from combining all or parts of existing applications. It usually takes an iterative or incremental process to get from an idea to the actual creation in whatever form it takes. These processes can be used to find new solutions to problems as well as to create something of the creator’s choosing.

The following steps are considered the key steps for successful project development.

Image

Investigation

Image This step involves investigating the problem or idea to fully understand it. You really cannot create a good and complete solution without fully understanding what you are supposed to accomplish and any limitations involved. It’s highly unlikely that you will have unlimited time and money to create something, so the earlier you learn of any constraints, the better you can plan for them. This step also involves defining what the project needs to solve. All users with a stake in the program solution must be interviewed to document and understand what they need the project to do. You will have a much better product if you thoroughly understand the problem that needs to be solved before beginning to write the code.

Image Ask lots of questions of those who will or could use your program. Use surveys and questionnaires to collect data about what needs to happen. Shadow several people to find out what they currently do and how they do it. Document it in some form, and then confirm your understanding with all of them. It’s amazing sometimes that things seemed so clear, but when you show them to someone, they say that’s not at all what they meant!

It is also important to survey a variety of designated or potential users of the software. Just like the software development team, a variety of user perspectives and backgrounds and locations, if applicable, will help you create a better product that reflects and incorporates their various viewpoints.

All the details and specifications that you identify through investigation are included in the project requirements. This document also includes constraints identified and the user interactions that need to occur. All of this information feeds into the design.

Design

This phase involves taking the requirements identified and creating some form and functionality around them. The investigative phase provides information about what the project should do. The design determines how the requirements will be met. Ongoing communication with the users is important in creating a successful programming solution. There are several common ways individuals or teams work to create a good design. These include:

ImageBrainstorming—This is a process of identifying as many ideas as possible without commenting or evaluating them until the process is done. Often one seemingly “out there” idea can trigger another idea that is workable. No judgment on ideas is allowed!

Storyboarding—This process is used in many fields, such as making videos as well as game design. There are layouts available for use, and you identify the functionality that goes together and identify the data and where it comes from, how it is processed, and where it goes next. Place the design decisions related to these in the panel of the storyboard. Then repeat the stages for the next section until all the requirements have been included.

Image

Modules—Designers will often group features of an application that belong together into a module or component. For example, starting a new game includes resetting scores to 0, refreshing or clearing the screen, and moving players to their starting positions, among others. All of these requirements could be grouped in a module.

Image

User interface—Designing how someone uses the software is the key to its success and the speed with which it may be adopted. All of the interactions both into and out from each step that people will see and use are considered the “user interface.” People evaluating and recommending software usually comment on how easy to use, how visually appealing, how useful the user interface, and how the overall “user experience” is. Designers use anything from paper diagrams to transparencies, overlaying them with new interactions based on selections, to fully designed screen images to create and test user interfaces.

Image

Testing strategy—It may sound strange to think of testing this early in the process. There isn’t any code written yet, but this is when the testing strategy should be identified. You already know the functions the software needs to do based on the requirements documented in the investigative phase. Make sure the testing strategy addresses each requirement.

Image

Prototyping

Prototyping is a very effective process, especially when working with users on design or a new technology they will use. It can be a mockup of the user interface screens to give users a starting point for suggestions. Many times people have a hard time describing what they want, but they know it when they see it! Design often works like this.

Image

Prototypes can also include small simulations of working code to give a realistic view of how the process will work. Feedback is critical to getting well-designed software, and prototypes are inexpensive ways to get a start on the feedback cycle.

Image

Testing

Program Basics

Let’s talk programming basics. Lines of code written in a programming language make up a software program. The code can run or “execute” its specified instructions on a computer. Sections of the code are sometimes referred to as a code segment. Segments work together to perform a certain function. How a program behaves describes how it runs during execution and how anyone using it interacts with it. This includes screens and messages displayed, buttons to press, menu options to select, and many others. Programs are described by their overall purpose as well as how they perform to accomplish the purpose.

The program will have some way to request or receive input and react to the input. Input is data provided to the program by someone using it, through a sensor, a file of data, a microphone, an image, or some other method. Event-driven programming relies on an event to occur to trigger code to run. These events are input to the program. Examples of events include finger swipes or taps, a message coming through via a text, a mouse click, or a timing event.

Through processing the input, programs generally produce some form of output. Output can include writing to a file for use by another program, displaying a message or image on a device, playing a song or video, or printing a 3D object, among others.

Image

Test Plans

You have to thoroughly understand what the program should do, produce, and display to effectively test a project and find any errors. All features, using expected data and unexpected data, should be tested to determine if the programs work and if they provide the functionality as intended. Using the testing strategy defined in the investigative phase, a good test plan will have the test cases and expected results identified for all the requirements. When the code is executed, the actual results are compared to the expected results to determine if the code is working or not. The expected and actual test results can be used by a programmer to prove a program runs correctly.

All program functionality must be adequately tested as well to ensure program correctness. This includes testing with valid and invalid data as well as “boundary” cases, which are those on the edge of program limitations.

Example: If something should happen when a value is less than 32, also check 31 and 33 as the boundary cases.

Testing should also ensure that all features work in the way the user needs them to. Do not just test that all functions work. If a user needs to update a record and uses three different ways to accomplish this, be sure to test all three in the order the user would use them to ensure they work as needed, as well as testing them independently. Also test what happens if they are used in the wrong order.

Debugging

Debugging means finding and correcting errors in your program. There are steps you can take when creating your code to help with later troubleshooting. Remember that test cases with expected results should be set up to evaluate each requirement before testing begins.

• Use procedures rather than duplicating code. It is much easier to read and understand a shorter program, and programs that use procedures are shorter. The procedure can be called as many times as needed, and then needed updates only need to be made in one location in your code. See the chapter on Big Idea 3 for more on procedures.

• Another step is to use well-named variables and procedures. If they are descriptive names that communicate what they do, it is easier to trace through a program and understand what it is supposed to do. See Big Idea 3 for more information on variables. For example: amtDue is much clearer as a variable name than ad.

• Hand-tracing the flow of the program line-by-line is also an effective debugging tool. This is often the best way to find a logic error. You write down the variable names and values as they change along with iteration numbers of loops and check the code line-by-line.

• Many IDEs (integrated development environments) where you can write and test your code include coding visualizations. These show the code structure and each line that executes to help track where errors are occurring.

• Debuggers are programs written to test and debug other programs. Many IDEs include debuggers. These are like automated versions of hand-tracing and show your code step by step as it executes.

• The use of temporary print or DISPLAY statements inside a program help with debugging. By printing out intermediate values to the screen or on paper, or to indicate when a program reaches a certain section of code, the programmer can more easily identify the error. These extra print statements are removed after the error is resolved.

There are several types of errors that can occur when testing. The types you must know for this course are described below.

Types of Errors

Syntax errors deal with things like punctuation or missing parentheses ( ) and typos. These are identified when you try to compile your program and must be corrected before the program will run. Each programming language has its own syntax, or rules, that must be followed.

Runtime errors do not cause an error at compile time but occur when the program is executing. A common example is when a variable has a value of zero and the program tries to divide by it. The program may run successfully many times when the value is not zero, but will crash when it is zero.

Logic errors occur when the program produces unexpected results. These errors are typically harder to identify. You may think your program ran correctly, because there were no identified errors. The program can run, but the actual results would be different than expected.

The test cases with expected results can really help identify these. If you have a table of expected test results, and the program does not produce the expected value, you need to carefully check your code to find and correct the problem and be sure you understand what the program is supposed to do. The problem could be as simple as using “+” rather than “-” in a calculation, or you may have used the wrong variable name in a program statement.

Overflow errors occur in computers when an integer is larger than the programming language can hold. A fixed number of bits are assigned to hold integers in many programming languages. When the limit is reached, an overflow error occurs. This varies for different computers, and you are not expected to know this value for each computer for the AP exam. See the Big Idea 2 chapter about data for more information about overflow errors.

Reflection

There are two development processes you need to know for this course. Each involves reflection of results before moving on in the development process.

An iterative development process is a repetitive one. The steps are repeated several times throughout the project as new information is gathered or clarified, testing is performed and revisions are needed, or customers change their mind about what they need. Each iteration produces a better result. After working through the investigation and design phases, often the coding/prototyping, testing, and reflection steps are repeated multiple times until the code works. Sometimes you do have to go back to other phases to work through those steps again. Feedback is a significant step in this process. You can create a working program, but if it is difficult to use or confusing, then people will not use it. Ask them! Ask a variety of people. You can ask your friends, but make sure to ask others as well. Friends may think too similarly to you or not want to tell you the truth.

Image An incremental development process breaks the pieces of the program into smaller sections. A section is coded, tested, modified, tested, and so on until it is working. Then work begins on another section. Once it is working, it is also tested for any interactions with sections of code already completed. Then work begins on the next module, and the cycle continues. The overall software system is built piece by piece, or incrementally, until completed. For example, if you are writing an app for a game, you might break it into the following sections:

• Instructions

• Game play

• Keeping score

• Determining the highest score

• Starting a new game

These all work together to create the complete game. Each section can be worked on independently, even by different people, until it is working correctly, and then it will be tested with the rest of the modules already written.

Be sure you understand these steps and follow them when you are working on your Create performance task. You will have a better product as a result!

Documentation

Program documentation is the “guide” to how the program is designed to work. The requirements document created in the investigation phase is the start of the program documentation. Programmers should also add to the program documentation, explaining the program features and how it should be used to meet the functionality originally identified in the specifications. This also could be in the form of a user guide to use in training those who will use the programs as well as “help” text. Ideally, documentation will be created as the program is being developed by the programmers to accurately record what a program is intended to do.

Well-named variables and procedures can be somewhat “self documenting” by describing their purpose, but do not take the place of additional documentation. Documentation is so useful when you either return later to modify the code or a team member has to pick up your code and understand what it is doing to successfully make modifications.

Programmers should comment blocks of code inside the program to indicate the functionality of those sections. Remember that comments are ignored when the program is translated into machine code and are to help people understand what is going on in a program. Comments should also be used in a program to explain complex or confusing sections of code. Note that not all programming IDEs allow comments, so the program documentation becomes even more important in these cases.

Another important topic to include both in your code as a comment and in the project documentation is crediting any code used from another source. This can be a program library imported into the program or through an API (Application Programming Interface) that allows connectivity to an external program. This is important for giving credit to the author as well as stating where the code originated if changes need to be made that will impact the use of the code.

Image Review Questions

Concepts

1. Collaboration can provide which of the following?

(A) Several points of failure

(B) Clean data

(C) Duplication of effort

(D) Better products resulting from different perspectives

2. What is a benefit of using a software development design process?

(A) By following the process, the code will work the first time.

(B) Using the process, the code will be efficient regardless of a programmer’s experience.

(C) The code will be developed in 50% less time using a development/design process.

(D) The process is iterative, resulting in a better program.

3. Which of the following is not a common step in many software development processes?

(A) Designing

(B) Investigating

(C) Identifying patterns

(D) Testing

4. What do using surveys, interviews, and observations identify?

(A) Device specifications

(B) Program errors

(C) User requirements

(D) Valid program input

5. Why is documentation important?

(A) To explain a program’s purpose and functionality

(B) To make it easier to understand and modify the code later

(C) To be useful for training people on how to use the program

(D) All of the above

6. Why should boundary values be tested?

(A) Testing boundary values is not necessary.

(B) To ensure they are identified as errors

(C) To ensure warning messages are sent about the boundaries

(D) To ensure the program does not include too few or too many elements

7. What is a crucial step in an iterative development process?

(A) Feedback

(B) Preparing prototypes

(C) Meeting deadlines

(D) Meeting budget constraints

8. What is a benefit of understanding a problem before coding?

(A) A better designed program is created to handle all the needed functionality.

(B) Less testing is required.

(C) Little or no documentation is then needed.

(D) Users will not need training to use the program.

9. Which phase in the development process determines how to meet the application requirements?

(A) Analysis

(B) Design

(C) Programming

(D) Testing

10. How do event-driven programs progress?

(A) They run in a linear fashion from start to end.

(B) The code executes sequentially.

(C) The code executes when an action occurs that it is programmed to recognize.

(D) The code runs iteratively.

Application of Concepts

11. What is one way to debug a program?

(A) Add temporary print messages to determine program values.

(B) Test with different data values each time.

(C) Document the error in the user guide and online help text.

(D) Override the error with the correct value.

12. Which development process breaks the requirements down into small modules and adds the code, once working, to the project as a whole?

(A) Additive

(B) Incremental

(C) Iterative

(D) Spiral

13. What is one way to ensure testing is thorough?

(A) Create expected results prior to testing.

(B) Create a diagram of the program’s processing.

(C) Execute the code to ensure it runs.

(D) Add temporary DISPLAY statements to see intermediate results in the program.

14. What type of error breaks the rules of the programming language, like a grammatical error?

(A) Logic error

(B) Overflow error

(C) Runtime error

(D) Syntax error

15. If your program executes without errors, but the results are incorrect, what type of error do you likely have?

(A) Logic error

(B) Round-off error

(C) Runtime error

(D) Syntax error

16. Which method of finding errors is most useful to identify logic errors?

(A) Creating new test cases

(B) Hand-tracing

(C) Rerunning the program with different inputs to see the impact on outputs

(D) Running a simulation

17. Attempting to access an invalid index in a list results in what type of error?

(A) Logic error

(B) Overflow error

(C) Runtime error

(D) Syntax error

18. What is an example of event-driven programming?

(A) Prompting a user to type in a response

(B) Using constants for data values in place of variables

(C) A mobile device that orients to a new position

(D) A microphone transmitting audio data to a program

Image Answers and Explanations

1. D—Collaboration can provide the possibility of insights we may never get otherwise by having team members with different backgrounds and perspectives create, design, and evaluate data, documents, products, and so on.

2. D—The steps in the software development design process are iterative, causing the developer to reevaluate after testing to fix and improve the program. No process can ensure that the code will be correct the first time, nor be efficient, nor decrease the development time by 50%, making D the correct answer.

3. C—Finding patterns is not a common step in the software development processes. The other options are key steps in developing a well-designed and working program.

4. C—These are investigative tools used to determine user requirements for the application.

5. D—Documentation is important to:

• Explain a program’s purpose and functionality

• Make it easier to understand and modify the code later

• Train people on how to use the program

6. D—Boundary values should be tested to ensure the program does not process too few or too many elements. These are common errors in programs.

7. A—Feedback from users on the proposed design and programs is a key aspect of an iterative development process.

8. A—One benefit of understanding a problem before coding is creating a better designed program to handle all the needed functionality.

9. B—The design phase determines how the application requirements will be achieved.

10. C—An event-driven program is one that waits for an event, such as a swipe or mouse click, to trigger the code to run.

11. A—One way to debug a program is to add temporary print messages to determine program values.

12. B—The incremental development process breaks the requirements down into small modules. Once coded and tested, the module is added to the overall application.

13. A—Creating expected results for the data you are testing prior to testing allows you to compare the actual results to the expected ones to ensure the program is functioning correctly.

14. D—A syntax error keeps the code from executing until it is corrected. These errors include things like missing punctuation, unmatched parentheses, and typos.

15. A—A logic error is the likely culprit. These can occur if you use the wrong variable name for a calculation or use the wrong operation, such as subtraction rather than addition.

16. B—Hand-tracing the code can help identify where a logic error occurs. (There are other debugging tools that are also useful for finding logic errors.)

17. C—This will result in a runtime error. The program may run accurately many times or through most of the program until the index position becomes too large or too small for the list you are using. The program will end with an error.

18. C—A mobile device that orients to a new position is an event that a gyroscope in the device will recognize. The gyroscope recognizes orientation so code will be initialized to redisplay information on your screen with the new orientation.

Image Rapid Review

Advances in technology provide the ability to share programs or their output with users worldwide. They can become popular with widespread use very quickly. These advances have spread the development of new programs and technologies and have expanded use of existing program applications to other businesses and organizations. Software that is developed by teams with different skill sets and perspectives results in better designed and programmed solutions. Collaboration by the team has many benefits, including sharing the workload, creating better solutions than an individual probably would, and testing of each other’s work.

Software development should use an iterative developmental process, an incremental development approach, or both. An iterative process is a repeating process that continues with feedback, rework, and testing until the users’ requirements have been met. An incremental process keeps breaking down the requirements into smaller chunks. Modules of code can be developed and tested, and once they are working correctly through using an iterative approach, can then be incorporated into the larger application.

Both processes include consulting with users, analyzing and designing a solution, coding the solution, and then testing. Documenting the programs and providing external documentation for those using the system are very important to make it easier to use, maintain, and modify the code as the users’ needs change.

Documenting the requirements is important to identify what the program application needs to accomplish and to get sign-off when it is complete and working. Commenting the code is needed to document what the code does along with explaining complicated sections of code for the person that updates the code in the future.

Program input can be from a variety of sources such as from the user, files, other programs, or from events, which include taps or swipes to trigger the execution of code. Program output can be sent from a program to another program, written to a file, or sent to a device such as a printer or speakers.

Thorough testing of software is critical before releasing it for general use, although programs developed for personal use do not need the same level of testing and documentation. Expected test results should be identified early in the design process for testing the code. Actual results should be compared to the expected ones to determine if the program is working correctly for all possible conditions. Syntax errors must be corrected before the program will run and are specific to the programming language. Runtime errors occur when the program is executing. It may run fine sometimes, but certain conditions cause it to end with an error. Logic errors do not prevent the program from running but produce incorrect results. The expected test results help find these errors. Overflow errors occur when a number is too large for the computer to handle with its architecture. Debugging is the process of finding and fixing errors in the code.