Comments

*To edit…

We’ve done absolutely loads of coding and learnt a lot of a very short period of time (about 8 hours). We’ve learnt a lot about basic programming constructs and electronics.

In the process we’ve added lots of little bit of code to our sketch (or sketches) and changed things over and over again.

This started with drawing of our Polygon bug…we learnt how to draw shapes and then started turning those shapes into our icon. You’ll notice however that your drawPolygonBug(); code is a very long list of shapes and its very hard to work out which bits you need to change.

That is because we missed a really important step.

Its an important step for our drawing but its also an important step in coding and to start this morning we are going to spend some time just cleaning things up and making sure that when you look at your code next week, or next month, you will be able to make sense of it.

The step we missed was a planning stage; we should have started by looking at our drawing and breaking it down into small steps and parts – our first bit of code might have consisted mainly of comments. Something like this;

drawPolygonBug(){

// main body shape
// eyes
// pupils
// mouth
// hair
// arms
// legs

}

That way we would have had a very clear plan for each step we had to complete.
We could then fill in each of the parts of the drawing. Like this;

drawPolygonBug(){

// main body shape
display.drawRect(30,15,40,40,1);
// eyes
display.drawRect(40,30,10,10,1);
// pupils
// mouth
// hair
// arms
// legs

}

As we completed each of the steps we would then have a clear map of all our content and it would be much easier to find and amend parts of our code later.

Exercise:

Even though we missed this step it will still be a valuable step to go through and mark up each element of your drawing code with comments so it looks like the top two shapes in the example above.

Leave a Reply

Your email address will not be published. Required fields are marked *