Sub Menu contents

Unit 3

Creating Graphics & Images Bit by Bit

3.1 Unit Overview

3.2 Paint Pot Tutorial

3.3 Representing Images

3.4 Paint Pot Projects

3.5 Paint Pot Refactoring

3.6 Error Detection

3.7 Parity Error Checking

3.8 Magic 8 Ball

3.9 Persisting Photos

3.10 Map Tour

3.11BB Electronic Documents

3.12 Wrap Up


Paint Pot Refactoring

In this lesson we won’t add new functionality to the Paint Pot app. Instead, we will revise the code, leaving the app’s behavior unchanged. This process is called refactoring and programmers do this to improve the quality of their code in various ways -- e.g., to simplify its design, make it easier to read and easier to maintain.

In this case we will introduce the concept of a programmer-defined procedure that will help reduce the complexity of our code and make it easier to read and maintain. This is an example of procedural abstraction, a very important concept and practice in programming.

Unit Objectives

Refactoring to Improve Code

Open App Inventor with the Paint Pot Refactor template in a separate tab and follow along with the video tutorial. After the project opens, use the Save As option to rename your project PaintPotWithProcedure

Adding Comments to Code

An important feature of every programming language, including App Inventor, is the ability to add comments to the code. A comment is a non-executable block of text that can be added to a program to provide clarification and documentation of the code. Adding comments to one’s code is a standard practice that programmers employ to help others (and themselves) understand their code.

In App Inventor, each non-collapsed block comes with the capability of having a comment added to it. To access this capability you must right-click on the block and choose the Add Comment option. This will add a small comment-icon, a blue circle with a question mark, to the block.

Good Commenting Practices

A good practice to follow is to provide comments in the following situations:

Make sure that you do the self-check at this link and that you update your Google Site Portfolio