Software Development and the Scratch language

Problem Solving

Developing a software application is a complex process that requires some guiding principles or methodologies.

George Pólya wrote How to Solve It, a book that has sold over a million copies. In this book he divides the problem solving task into four stages:

  1.  Understanding the Problem
  2.  Devising a Plan
  3.  Carrying out the Plan
  4.  Looking Back (evaluating your solution)


Top Down Design (a.k.a. stepwise refinement)

method for designing programmed solutions to complex problems.

seeks to reduce the complexity of a problem by organizing it in a manageable way.

Top-down design has three major steps:

  1. Break the problem down into simpler subproblems
  2. Solve each subproblem (possibly by using top-down design)
  3. Combine the those solutions to form a solution to the problem
First step is the key.  Break down the problem by finding a natural decomposition of the problem. Consider building a house. If you divide it into subtasks of building the front and back halves then each subtask smaller but no easier! Instead, divide it into subtasks such as framing, electrical, plumbing, etc.

Top-down design can be applied repeatedly to a subproblem which remains complex

Other examples of non-trivial tasks


Software Development Lifecycle

This approach is echoed in what has become known as the Software Development Cycle, consisting of multiple phases and activities:

  1. Investigation : determine if software can meet client needs and its benefits outweigh the costs
  2. Analysis : determine what functions the software needs to perform
  3. Design : determine how those functions will be presented (user interface) and processed (logic and databases)
  4. Programming : write the software to implement the designed solution
  5. Maintenance : modify the software as client needs evolve
  6. Testing : discover defects - this activity is concurrent with all development activities

Algorithm

computer program is implementation of an algorithm : a step-by-step description of how the program's task will be accomplished. The task and algorithm may be very complex. A program is a set of instructions that tell the computer how to carry out the algorithm.


Programming Languages

In the beginning, there were machine languages.  Instructions coded as 1’s and 0’s.  OK for computer, hard to humans to do reliably

Assembly languages were developed, giving names to all the machine instructions.  Each assembly instruction corresponds to one machine instruction.  Better, but still hard for humans to do reliably.  Requires assembler to translate into machine language.

High level languages were developed.  Each language instruction corresponds to a (perhaps lengthy) sequence of machine instructions.  Much easier for people.

How many programming languages are there?  Thousands

There are so many because different problems and solutions can be expressed more efficiently using different vocabularies.  No single language includes all vocabularies.

All of them are equally powerful, however, as you will see next.


Theoretical basis for programming languages

Alan Turing, as one of his most important contributions to the field of computer science, developed a mathematical model of computation called the Turing Machine.

The Turing Machine has been shown to be capable of computing anything which is computable (i.e. programmable). Yes, there are things that cannot be programmed!

It has been shown that a programming language is equivalent to a Turing Machine in terms of the problems it can solve if it possesses three simple abilities.

  1. Sequence : the ability to specify the relative order of the instructions in a program (i.e., what comes first, etc.).
  2. Selection : the ability to make decisions, usually deciding which of two courses of action to take.
  3. Iteration : the ability to repeat an action over and over again

All the programming languages listed above (and thousands of others) have all these capabilities, and so are equally as powerful as Turing Machines and each other!

Language choice is a matter of how efficiently a solution can be expressed, not whether it can be expressed.


Scratch

What is Scratch?

To quote from scratch.mit.edu:

"Scratch is a new programming language that makes it easy to create your own interactive stories, animations, games, music, and art -- and share your creations on the web. Scratch is designed to help young people (ages 8 and up) develop 21st century learning skills. As they create Scratch projects, young people learn important mathematical and computational ideas, while also gaining a deeper understanding of the process of design."

The subtitle of Scratch is "imagine * program * share". We will focus on the first two. You are free to share your results with the Scratch online community, but we will not spend much time on this part. You can easily figure it out on your own if you wish to participate.

Scratch was developed by the Media Lab at the Massachusetts Institute of Technology (MIT).

How can I get Scratch?

Scratch is installed in the Towers 107B computer lab. You can also download it directly from scratch.mit.edu (30MB download). After the download and installation, you should get the option of getting a desktop icon that you can click on to launch Scratch.

What does a Scratch program consist of?

A Scratch program consists of a number of different components that all work together. Here are the major kinds of components.

Sprite - The most important component, because it is active.

Costume - A costume is the visual image of a sprite

Script - A script is a set of commands followed by a sprite

Blocks - The stuff that scripts are made of!

Stage - The backdrop for sprites

Enough description! How to I write and run a Scratch program?

To write a program, just
  1. Select New from the File menu, to clear out any current program
  2. Obtain and select a sprite
  3. Select the Scripts tab in the center (should be selected by default)
  4. Select the Block category; start with Control
  5. Drag and drop blocks from the block palette into the Script area!
  6. Repeat for additional scripts and sprites
  7. An easy way to remove a block is to isolate it and drag it back into the block palette
  8. Experiment!
Save it periodically!
  1. Select Save or Save As from the File menu
  2. Click the Computer folder at the left
  3. Click the Z: at the bottom of the list
  4. You are now in your Otterbein home folder
To run a program, just click the Green Flag. To stop it, click the Red Stop Sign.

Where are some Scratch resources?

Can I show my Scratch program to friends and family?

You can run your Scratch program on any computer that has Scratch installed. Another way is to join the Scratch community and post your program to their web site. Then you or anyone else can run it from there. Finally, the Scratch FAQ page (available from the Support screen) describes a technique to run your program from your own web page such as the one you created in this course. I have not tried it.

One thing you definitely cannot do is save it in any of the standard video formats for playing through a media player or posting on YouTube. Scratch does not have this capability.

Scratch is a full-blown programming language

Scratch includes all three of the major programming language constructs: