Sunday, September 13, 2009

Adhering to coding standards. It's not that bad.

It's easy to talk about writing in the correct style and following the standards for coding. But when it's time to actually edit your code and make sure it's correct, there is a lot of work involved. I was assigned to correct my source code from my robocode project and it allowed me to look at the codes of my peers. That was good because I found that there were other implementations out there I hadn't thought of or failed to implement.

One of my weaknesses as a programmer is in mathematics. When I looked at another classmates code today, I realized how easy an implement the program was when he just wrote a formula to compute a value. What I did in my implementation was a big bunk of a mess. Trigonometry was a big help to that classmate. When I had tried that kind of implementation in my own program it was very hard. This is one aspect of programming I need to work on.

However, I also realized that I also have some strengths. I have a very strict way of coding and I always look for exceptions and problems to the program. For example, I included a HitRobotEvent method that specified what to do in case there was a robot collision. I included them in all my simple robots that needed it. Some of my classmates didn't do that, so I think I have a different perspective for how a program should work. I kind of think in terms of a overall program and it really bothered me that a collision could happen, so I look for all the cases in which thing could happen. The assignment didn't specify what to do in that kind of situation, but I think it's a good mindset to have. In professional coding, you need to have test cases in mind in order to prevent any type of bugs.

When I read "The Elements of Java Style" it showed me that I had been doing at least some things right. I already include white space and good variable names in my code to improve understanding. These things just made sense. They were guidelines set not because someone said so. They were things worth doing and benefited all programmers. Although I have to admit it is very tedious at times. For example, hard tabs are used by most beginning programmers. But it's prohibited by Coding guidlines. It's a bad habit that creeps in because ICS101 doesn't really warn you about this, but it would be a good idea to inform beginners about that sort of thing. Most of what I know about programming standards and are congruent with Java standards I learned back in ICS101.

Overall, these guidelines aren't difficult to follow. It's like writing a sentence in a paper. If you want to sound professional, you better improve your grammar.
Here is a link to my page for the revised robocode source code.

(http://www2.hawaii.edu/~wingma/)

These are coding standards set by my professor.

No comments:

Post a Comment