Sign in to follow this  
  • entries
    156
  • comments
    253
  • views
    85256

Coding Ediquette

Sign in to follow this  

81 views

When a person is still fairly new to learning to program, is it a bad habit to get into when you choose to "try-and-error" the code that you have written?

IE.) -- Write a function, compile
or -- Write a loop, compile

What are some good habits to get into that you have found helpfull when you code?

Just thinking a bit before I head off to class.
Sign in to follow this  


3 Comments


Recommended Comments

Usually I compile when I feel that I've written enough code that will provide some sort of output, something I can test. The only reason why I think you'd compile so frequently is if you don't yet have a grasp on all the syntax of a language, in that case, compiling frequently may help you learn the syntax a bit quicker, also it will help you learn to identify common errors and how the compiler reports them.

You will probably find that the more experienced you become, the less often you will compile. Also, the larger the code base, the less you'll WANT to compile, because compiling will take precious minutes away from you.

Share this comment


Link to comment
I find that I compile every time I write a new class, or group of related classes, to make sure there are no bugs that I am introducing to my system before I write a lot.

I generally don't compile after every for-loop, but thats probably because you are not used to the syntax yet.

Anyway, if you are writing Object Oriented base code, I recommend this technique highly:

1) Write how you would like the code to work. For example:

Person Me;
Me.setAge(18);
Me.setSex(SEX_MALE);
Me.setHeightInInches(74.5);
Me.setWeightInPounds(185);

Now, obviously that won't compile. So you have to create a Person class. Okay, still won't compile. So you have to create those 4 functions until it compiles. It will help you focus on code design and appropriate style without clutter if you think "high to low" instead of "low to high." I consider low to high programmers to have very unreadable code that tends to be cluttered and repetetive. It generally means they think about a specific for-loop instead of the system as a whole.

Just a tip...

Share this comment


Link to comment
Hey fellas, I really appreciate the feedback on this question. Thank you for your time.

@visage
I really see where you are coming from and how that could potentially add to the project. Luckly, I am in no position to say that I'm attached to a specific 'way' of doing things so I will give that idea a shot.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now