Advertisement

Did anyone else do this when they first started coding?

Started by December 21, 2010 07:47 PM
6 comments, last by Endurion 14 years, 2 months ago
I just had this memory from several years back. My first language was C++ and I had landed a job coding in C++, although my skills were quite poor at the time.

I found the typical coding style to be an unreadable wall of text, so I would do silly things like placing a page and a half worth of empty lines in between each method definition, so that I could clearly see the separation between methods. If I didn't do this, then methods seemed to run into each other and I had a very difficult time scanning the source file to find what I was looking for.

Eventually, I guess my brain got used to scanning C++ code. Over time, the amount of whitespace I would use got smaller and smaller, as the extra white space became more of a nuisance than a help. After a few months, my code looked more-or-less like everybody else's.
well I always put something like:
//=========================
between each definition, it makes it look nicer for me...
Advertisement
Yeah, stuff like that often helps. I used to do that at the top of source files, back when I had loads of macros and global data. I don't have that stuff much anymore.

I tend to put method comments before each method, for documentation purposes, but I don't need them. If I'm looking at a source file that doesn't have them, I can still pick out the individual methods quite easily. When I first started, I had a difficult time doing this even with method comments or other comment-type separators: my brain didn't really distinguish between those and other comments that happen to be inside the method definitions themselves.
Quote:
Original post by CDProp
Over time, the amount of whitespace I would use got smaller and smaller, as the extra white space became more of a nuisance than a help.

It was the other way round for me. With time and experience my code got a lot more whitespace, more comments, clearer structure and feels a lot less crammed. When I look at my early code nowadays, it actually looks like a completely unreadable and chaotic wall of text.
Yeah. I used to add a 5 lines block of comments (that I never filled) with a nicely ascii art made box. Somehow the idea that it'd be useful was pretty strong at the time.

Last night I found myself looking at a piece of code I just wrote that is filled with nested template arguments and member calls from different libraries including my own and UNDERSTANDING IT COMPLETELY.

I thought to myself: I used to hate this because I didn't understand it and now it not only makes sense but it also looks like a beautiful solution for something I couldn't solve before.

It was a pretty good feeling.
[size="2"]I like the Walrus best.
I mostly copied the coding style of ben bishop, although mine's more crappy looking. ben used to put:
//zz> ur comment here
//==================
I somehow wonder why his code looks tidier than mine even if I copied his commenting style....although I can understand it, it just somehow looks messy...
Advertisement
Quote:
Original post by Bow_vernon
I mostly copied the coding style of ben bishop, although mine's more crappy looking. ben used to put:
//zz> ur comment here
//==================
I somehow wonder why his code looks tidier than mine even if I copied his commenting style....although I can understand it, it just somehow looks messy...


Perhaps it's because it's not the comments that make code look tidy and understandable?

I also used to insert a lot of whitespace between methods and control blocks. I also wrote long methods and huge classes, so I needed a trigger while scrolling through a file where the next method started. Nowadays I write much smaller methods and got better as separating concerns into classes. There are much fewer walls of text now.

Also when I just started out I used to comment about every line of code I wrote:

// set counter to zero
int i = 0;

Nowadays when I read code like that I feel kind of offended by the author. As if I'm too stupid to read code and need everything written out in English.

Oh, and I also find these kind of comment kind of silly:

///////////////////////////
// End of post
///////////////////////////
STOP THE PLANET!! I WANT TO GET OFF!!
I did the same as owl. Basically a three line ASCII box with the name of the method in the top line. Back then I used the Watcom compiler with an IDE which name I've forgotten. The IDE hat a switch that condensed the display and showed all the first lines of comment boxes and let you jump to the line. 'twas very useful back then.

Now I remove those boxes when I happen to find some left in my codebase.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement