Feb 18

I ran by a few things when searching for techniques to make your programming beautiful. Here is what I ran by:

  1. Strive to add more function by deleting code.
  2. A Designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away. (Saint-Exupery)
  3. In software, the most beautiful code, the most beautiful functions, and the most beautiful programs are sometimes not there at all.
  4. Vigorous writing is concise. Omit needless words. (Strunk and White)
  5. The cheapest, fastest, and most reliable components of a computer system are those that aren’t there. (Bell)
  6. Endeavor to do more and more with less and less.
  7. If I had more time, I would have written you a shorter letter. (Pascal)
  8. The Inventor’s Paradox: The more ambitious plan may have more chance of success. (Polya)
  9. Simplicity does not precede complexity, but follows it. (Perlis)
  10. Less is more. (Browning)
  11. Make everything as simple as possible, but no simpler. (Einstein)
  12. Software should sometimes be seen as a soap bubble. (Perlis)
  13. Seek beauty through simplicity.

That list is from a book entitled, “Beautiful Code” by Andy Oram and Greg Wilson. Sometime or other, I’ll get my hands on a copy… lol

Feb 17

So, I recieved my grade for my second program in Computer Science 1 today. I found out that I had a 90 at first… I immediately took a step back and said, this isn’t right… So, luckily today was President’s day and the professor had off from teaching at high school which means he had office hours all day! I decided to swing by and inquire about the details of why I recieved a 90 on my assignment… After thorough research, he figured out that I was marked off for one of the ten test cases not working (which was due to my poor implementation of the extra credit), so I proposed a question to him and here’s what it was: “Why am I getting marked off for the extra credit being wrong when the assignment is 100% right?” He agreed and pulled my grade up, yay!

On a side note, I posted the actual assignment itself here: Recursive Permuations for people to download and use as an example. I posted my assignment because I thought it would be a great template for others to see when dealing with finding recursive permutations of a string. This program really taught me alot and helped to better my programming style. While doing the assignment, I realized the importance of properly naming your variables:

Instead of:

 int i; //used for loop

Try:

int loopCounter; //used for iterating through something

Anyways, long story short, I thought this assignment was great! He assigned the third assignment on the 9th of February and I finished it tonight after redoing it 2 times already. Once I submit it and it’s graded, ill post it on my site. Stay in touch :)

Jan 29

This past week and a half has been rough for me. I have spent countless hours debugging my program because of stupid errors I’ve made when trying to manage my program. I have learned, all too well, the importance of clear variable names and the use of additional commenting. I really have spent some time trying to think about how I can make my code beautiful.

So, Here’s 3 easy things you should remember when dealing with the management of data structures in C.

Step 1: Name your pointers in someway that indicates its a pointer.

Alot of the times, I manage to pass a variable and at that time I knew it was a pointer but what happens one or two days later? If you name your variables inefficiently, your brain will explode when trying to understand what you were thinking. It’s a fact. In order to avoid something that will take you MUCH more time than it should, just make the effort to do it right in the first place.

Bad examples of pointer names:

int * temp;
char *** stringArray;
char ** string;

Good examples of pointer names:

int * tempPointer;
char *** stringArrayPointer;
char ** stringPointer;

// - OR -
int * tempP;
char *** stringArrayP;
char ** stringP;

Step 2: Function Commenting

Be sure to add comments to your function that help keep you on track. Make these comments clear and straight to the point. Try to describe what the goal of the function is, precisely. This will keep you on track when you need to refer back to what the heck you’re doing.

P.s. - If you think you can get by without commenting things, you’re thinking foolishly and you should change.

Step 3: Don’t say your code doesnt work.

Saying your code doesnt work is like saying your book doesnt work. If I gave you my book and said what do you think of it, and you replied with: It doesn’t work, I’d take my book and hit you in the face with it.” - Mouser, donationcoder.com

Basically, when you stare at your code wondering what is going on, because its inevitable, take a second to realize WHY its not working instead of saying, my code doesnt work.