COM SCI 110, Week 2, Friday Class 09/23/2016
The set of rules that defines the combinations of symbols that are considered to be a correctly
structured document or fragment in that language
Allow people to read your code, understand your code, and maintain and change your code.
Makes it easier to read. Not every line needs commenting – but sections do!
At the top of your program you should have a header:
This program draws a picture of a …[ cat and it is a really ugly cat but it is the best that I can do.]
Written by: Mack Horton
Student Number: 10105658
Date: Sept 20, 2016
Date Modified: XYZ
o Open source
Allows other parties to access and modify the code.
What is the difference between a syntax error and a logic error?
o Syntax errors
I have screwed up in my syntax, I haven’t formatted my program correctly
o Logic error
I did not do what I expected to do. I.e., I wanted to draw a line from 0, 0 to 100, 100, but
instead I got confused and drew a line from 0, 0 to 10, 100.
Just as in algebra, a value can be assigned to a variable such as “x”.
When variables x appears inside and expression, it evaluates to its assigned value.
Hard coding – all shapes, parameters, were vertices, lengths, that were all numbers. House
starts at 100, 100. Vertex is here, and this vertex is here.
Normal coding – is with pictures, by relative distances and things. If I were to draw a cat with
200 pixels, and drawing area 500 x 500. COM SCI 110, Week 2, Friday Class 09/23/2016
What if? Did not want a drawing error of 500 x 500 but rather, 200 x 200 or 250 x 250. The cat
would be drawn perhaps outside of the drawing area.
What if! It did not matter the size of your drawing area. So that the cat can fit within the
drawing area regardless of the drawing area size. This is based on a ratio / value / variable.
Use print function to print the value of your variables.
In processing the print function is used by programmers only. Used to evaluate the variables
you assign while the program runs.
Size (500, 500) X = 3
X=3 Print (x)
Print (x) 3