Sign in to follow this  
ahayweh

Confidence in programming...

Recommended Posts

I have been reading Code Complete, and other similar books, and have been re-evaluating the habits I've formed over the years. I was wondering what the saving/compilation rates where of the more advanced programmers. Meaning, how often to you find yourself saving source files and compiling them? Do you find yourself compiling after each routine just to verify that it is working as intended? Or are you confident enough in your coding ability to where you don't really compile often? I'm not going to lie, I still find myself compiling/test even after a few blocks ( or even lines!! )at times just to reassure myself--which I've come to understand is the mark of a trial-and-error ( read : juvenile/ineffective ) programmer. Are there any other habits you practice that show the presence ( or lack of ) coding confidence? Thanks, ahayweh

Share this post


Link to post
Share on other sites
I don't compile that often now really. I often write a large number of functions and definitions of structures and then compile, as opposed to all the time. One exception is when Intellisense is confused or confusing me and i compile to see if i am right or not.

Share this post


Link to post
Share on other sites
Lol
Im ctrl+shift+s addicted. Every few lines I tap it so that my code is saved. In fact I tap it often in notepad (where it doenst work!) and other programs just to be shocked when I realise its not working.

as for compiling I do it after each "idea". If I am building an entire class I might write its skeleton until I press compile. If im working on a specific method and rebuilding it as i write it I tend to compile more often.

Usually compiling is just to make sure I got the correct syntax (specilly when I dont have intellisense).

Yours Truly
K

Share this post


Link to post
Share on other sites
When I start a new class I usually wait until i reach a compilable state :-)
Usually I lack of concentration skills (a problem I have in general) and do compile often just to be sure I'm not doing things completely wrong.

I mean, if I'm changing some code that is supposed not to modify the program behaviour, the if the code is not trivial I always compile often to check I'm not doing very bad things (recovering too late is always more hard than Compile & Run :-)

This aside, I have your same feelings, that this habit is an heritage of a wrong coding style...

Share this post


Link to post
Share on other sites
I save often (it marks the transition from a "write code" mental state to a "plan code" one). I often write several hundreds of lines (half a dozen classes and twenty or thirty functions) in-between compiles. Most of the errors my compiler comes up with are petty typing errors (like std::strign), with the occasional missing typename or namespace qualifier someplace or another.

Share this post


Link to post
Share on other sites
Sometimes I'll do a quick build just to see what complains about my changes. Think of it as "breadth-first" code modification. Other times, though, I'll just fully implement whatever I'm working on and chase down errors in the order they come up in the output.

Oh, and I too am a habitual "saver". I regularly hit Cntl-S instead of enter on Google when doing a search. I quickly realize that I didn't intend to save the webpage, though.

Share this post


Link to post
Share on other sites
For me, it varies how often I compile. But I usually find that I compile after a complete chain of thought is coded. I program in a very logical order (still use flow charts before writing the code). As I complete each step in the progression, I compile to make sure that each step is working before I code further. Makes it easier for me to debug as well.

As for how often I save ... let me put this way ... if you were watching me type code, you would think that "; ALT F S" is the correct syntax for ending a C++ statement.

Share this post


Link to post
Share on other sites
I save all the time too, and I compile almost as often. I think I compile so much out of laziness. I let the compiler check my code for me, instead of looking over it and making sure I did it right.

Svenjamin

Share this post


Link to post
Share on other sites
lol. It's good to hear that there are more pathological savers out there. I have decided to start consciously holding off redundant/unnecessary compilations. It just something about seeing 0 warning 0 errors that is reassuring ( like a pat on the back ). My problem is not only do I compile, but I link and run as well ( just to check to syntax errors... )

Share this post


Link to post
Share on other sites
This has little to do with confidence, more with practicality.

When there were terminals and punch cards, you couldn't just randomly punch keys and hope for the best.

- You'd write the algorithm.
- You'd pass it to programmer, who'd punch the keys and drill holes in 200 paper cards
- Then you'd mail that to the computing center
- In 3 days you'd receive a response ( R17=0. R16=5. ERR )

And after going through the punched cards, reading the binary code, you'd realize the programmer mis-read your period for a comma, causing a program error.

This would of course take 3 more days to find, and re-submittal would take another 3 days.

Real-time compilation is great. This makes Java and C# IDEs such great tools. They do make you lazier, but ultimately also more productive.

Share this post


Link to post
Share on other sites
Just for you people with wrist pains: Saving is Ctrl+S.

Ctrl+Shift+S is normally "save as" and Alt-F-S is probably a bit hard on your hands ;-)

Of course, you could always use emacs: Ctrl+X-Ctrl+S or vim (god knows what, probably escape :w or something - I'm just guessing here!) if you intend to punish your yourself :P

But yeah, I'm saving every time I breathe too. I almost exclusively recompile when I want to run the program. A decent IDE such as NetBeans does all checking in real time anyways.

Share this post


Link to post
Share on other sites
I also compile much too often. Not only that, I will make a back up of my project, it will be called "Junk" and then the project name. I will edit the "Junk" file, until I have made a fully functional upgrade to the program, and save the "Junk" file as the normal file itself, and then continue editing the "Junk" file with my next idea. Also, if the idea I am currently working on is huge and there are many things I need to implement before it is ready, I will save "checkpoint" files, as I go through the idea. Every time I complete a vital section of the idea, I will save it as "CP", which means checkpoint, and then a number corresponding to the checkpoint number it is, and then the file name. When the complete idea is coded, I'll re-save the "Junk" file to the normal file, and delete all the "CP" files. I do this so I don't have to go back to the very beginning of the idea if I mess up horribly in the middle of the idea. I am a very unconfident programmer, and fear dysfunctional code. My worst fear is having to rewrite an entire program.

Share this post


Link to post
Share on other sites
Quote:
Original post by Guhill
I also compile much too often. Not only that, I will make a back up of my project, it will be called "Junk" and then the project name. I will edit the "Junk" file, until I have made a fully functional upgrade to the program, and save the "Junk" file as the normal file itself, and then continue editing the "Junk" file with my next idea. Also, if the idea I am currently working on is huge and there are many things I need to implement before it is ready, I will save "checkpoint" files, as I go through the idea. Every time I complete a vital section of the idea, I will save it as "CP", which means checkpoint, and then a number corresponding to the checkpoint number it is, and then the file name. When the complete idea is coded, I'll re-save the "Junk" file to the normal file, and delete all the "CP" files. I do this so I don't have to go back to the very beginning of the idea if I mess up horribly in the middle of the idea. I am a very unconfident programmer, and fear dysfunctional code. My worst fear is having to rewrite an entire program.


VERSION CONTROL !!!!

Share this post


Link to post
Share on other sites
Quote:
Original post by Antheus
Quote:
Original post by Guhill
I also compile much too often. Not only that, I will make a back up of my project, it will be called "Junk" and then the project name. I will edit the "Junk" file, until I have made a fully functional upgrade to the program, and save the "Junk" file as the normal file itself, and then continue editing the "Junk" file with my next idea. Also, if the idea I am currently working on is huge and there are many things I need to implement before it is ready, I will save "checkpoint" files, as I go through the idea. Every time I complete a vital section of the idea, I will save it as "CP", which means checkpoint, and then a number corresponding to the checkpoint number it is, and then the file name. When the complete idea is coded, I'll re-save the "Junk" file to the normal file, and delete all the "CP" files. I do this so I don't have to go back to the very beginning of the idea if I mess up horribly in the middle of the idea. I am a very unconfident programmer, and fear dysfunctional code. My worst fear is having to rewrite an entire program.


VERSION CONTROL !!!!


QFE!

Share this post


Link to post
Share on other sites
Wow, Some of you are truly nuts! Either that, or you need better tools.

I save once --- when Visual Studio asks me to on exit. My computer has crashed and lost power unexpectedly before but I have never had a problem of losing data. How? It's called using the auto-save feature.

As for compiling, Visual C# performs automatic compiling for its intellisense, so I only compile when I need to run my program and otherwise depend on the editor to let me know when something is not correct.

Share this post


Link to post
Share on other sites
I write enough at a time that, if I compoile it and don't get errors, I'm always worried and think 'did I really compile that?!'

Share this post


Link to post
Share on other sites
Wow, call me a bit different here, but im of a completely different mind on the matter. I will code 1 class or CRITICAL function before each compile (unless its really painstakingly simple code like a windows process or button handler, etc). I also code them so that they can each be performed as a unit test and profiled, this way I have the confidence that a particular critical function or class works just as expected. And while this does take a bit of time, it would take alot more time in my mind to find the obscure bug caused by forgetting something important before moving on, only to have it show up months later.

Share this post


Link to post
Share on other sites
I have a static analysis tool and units tests that run automatically after a successful compilation, so I've learnt not to compile frequently.

I hit ctrl-s to save all the time though.

Share this post


Link to post
Share on other sites
I'm writing my code in the TDD way. I have to build & run often. My tests run automatically as a post-build step, so that failures in my unit tests show up just as if they were compiler errors.

As for saving... Well, I canceled the save-as dialog four times while writing this message - I'm a CONTROL+S addict... ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by Paulius Maruska
I'm writing my code in the TDD way. I have to build & run often.


Same here, but I don't build the new source code... at least directly. All new source code lives completely in header files (C++). When the iteration is complete, then we'll move the new source code into its own source file and tidy up the headers.

This makes it so we don't have to compile a minimum of two projects per test... just the test project.

As far as "saving" goes... all files are auto-saved on each build... which means after each unit test is written.

And "long term saving"... consider sites that offer Subversion hosting. We're using a very affordable host and TortoiseSVN as a front-end. There are free sites for open-source projects.

It's very reassuring being able to do commits after each coding session :)


YMMV

Chad

Share this post


Link to post
Share on other sites
Quote:
Original post by Ahnfelt
Of course, you could always use emacs: Ctrl+X-Ctrl+S or vim (god knows what, probably escape :w or something - I'm just guessing here!) if you intend to punish your yourself :P


Got it in one. You may think it's obscure, but it's amazing how quickly such things are committed to muscle memory. :S

Share this post


Link to post
Share on other sites
I hit CTRL+SHFT+B (build the solution) every time I'm not doing anything immediately (when I finish a class declaration and start to think about the implementation, when I finish writing a method and am not flowing strait into the next, when I get up to use the restroom, etc). [EXCEPT when the solutions I'm working in are poorly designed and large with really long build times - but that hasn't happened lately in C#]

I also get everyone else's changes from source control after every major spacer (when I finish a whole class or feature, etc), and build then.

I check in my code after nearly every significant step in which I haven't made the program any worse than it already was. This might be after writing 4 files and 1500 lines of code, or simply changing 1 complicated loop to be correct or better.

I run the program when I either do anything complicated that needs testing, when checking out other people's code caused changes in files that might reasonably impact my own work, or when I really "complete" anything. Which for me is NOT when I get something to work, but when am done enough that I can then move on to something else, with no plans to immediately (within the next week) return to this area again.

Just for fun I once dictated over the phone to a beginner friend of mine learning programming the building of a simple 2 form, 4 class windows program - without turning on my computer, looking at a book, or using a paper or pen ... just pacing up and down my hallway for about 2 hours. Including debugging any typos he made etc. Over the 2 hours there we're MANY little problems that showed up, primarily due to his not knowing about case sensitivity and such, but only 1 case of me actually dictating a faulty line.

5 years ago I'd make typo's and compile errors at a rate of maybe 2-5 and hour. Now I do a lot less code typing and a lot more design and architecture work, but when I do type things in I rarely make such mistakes at all (of course intellisense is the reason for at least 80% of the improvement - the rest is simply being deliberate and careful).

Share this post


Link to post
Share on other sites
I've always compiled and test-run at the end of writing a 'module' of code. That conceptual module though has gone from perhaps as small as a whole function into usually a small set of classes and all their integration as time/skill has gone along.

Share this post


Link to post
Share on other sites

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

Sign in to follow this