Formatting+Code+(Kyle+Skabelund)

Design a program that teaches the proper ways to format your code, or improve on the program that is already up. The one up seems as it would be a little difficult for kids in cp1a, or just starting out. I think this could be simplified. The way it is now, a lot of people aren't going to read through 24 pages of formatting code. I think this could be simplified and easier to understand for a cp1a student. We could make a new ILM for it or modify the old one.

Pages 1. Styles/Guidlines 2. Step 1 3. Step 2 (Correct) 4. Step 3 (Formatted) 5. Try it! 6. Quiz 7. Conclusion

Content 1. Show and Explain the different ways and styles to format code. There is many different ways to format your code. So I would use the same three styles that are already on the previously existing ILM. K & R, The One True Brace, and the Allman style.


 * K & R style**


 * Allman style**


 * One True Brace style**

2. Show examples of code that hasn't been formatted. The steps in the previously existing ILM are very well explained, but I think the content would be a little to bulky for some students. Especially at a beginner level. Maybe modify the ILM to incorporate some simpler code. Maybe in another step or before you go on to the more bulky content.

3. Show the user what should be corrected in the code.

4. Show the document that has been formatted correctly in one or all of the styles.

5. Let the user try for themselves. Show the user a chunk of unformatted code in one or all of the styles, and then ask them to format the code.

6. Correct the users work, and show what is right/wrong. This part would be very tricky, and i'm not sure how it would work. Possibly, when the user wants to check to see if they got the formatting and indentation right, a picture or text would pop up and show them the right answer. I would like to have the ilm highlight what they missed, but i think it would be really hard since programs don't account for indention and formatting.

7. Tell the user the importance of formatting code. Formatting code is very important, no matter what style you use, you should always format your code for many reasons. One, it makes it understandable. When code is hard to read, its tough to figure out what it should actually do. Two, it makes it a lot easier to see what is wrong. And last, in this field you rarely work alone, and having another person understand your code is very important.

I think this ILM would be a lot better if it could incorporate easier code with it for beginner programmers. This ILM is also a little tricky for correcting the user, to see if they formatted it correctly. The best idea I have is show the user the correct way after they click "check".

(Here is a link to the other ILM: []) Vicki: The goal of the original ILM was to teach programming style - which is more than just where to put braces. Where to put the braces is a pretty small part of programming style. I'm not sure it is worth the effort in producing an ILM if we don't get more "value added" from the effort. Maybe what we need to do it break up the original ILM to show different rules separately, rather than as one long example.

Mr. Weeks: I like the idea of breaking it down into shorter examples. I have included a couple of examples of actual unretouched code that escaped scrutiny which we see in our programming IA class. It is typically average code--students also indent randomly or differently in attempting to correct cryptic compiler syntax errors. We spend quite a bit of time with students getting the code into a reasonable state and it would be nice to to have a short ILM where the students can work on those fundamentals, especially since our class size is 40+. Good identifier names, comments, formatting are our main concerns. Correctness, maintainability and modularity are in there also. Most of their work is done in class so they only have about 40 hours at the computer per semester.

Vicki: Could we use videos plus peer reviewing here? There is an online class in writing for the sciences that is very interesting (in terms of how they teach writing style). They talk about the principle. They give lots of examples. They give an example and have you fix it. Then they show you what they did (and talk about why). I find myself reworking my writing to try to fix awkward phrases. It is motivating. The final thing they do is have you turn in something and have peers comment.

I think it is clear that good variable names and reasonable spacing makes it easier to read, but there are other techniques that aren't as obvious. I looked at a program called "Source Format" but it didnt' really do much to this code besides the obvious indenting.

using namespace std; int number=0; char escape=27; void space (int width) { if (width>=1) cout<<' ';
 * EXAMPLE 1 **
 * 1) include

if (width>1) space (width-1); }
 * ...ETC... **


 * EXAMPLE 2 **

int main(void){ cout <<"enter a number:"; int num1; cin >> num1; cout << endl; cout <<"enter another number:"<< endl; int num2; cin >> num2; cout << endl; if( num1 < num2) { for ( int ii=num1; ii <= num2; ++ii) { cout << ii << ", "; } cout << endl; } else if ( num2 < num1) { for (int ii=num2; ii<= num1; ++ii) { cout << ii << ","; } cout << endl; } return 0;

}