Code commenting style

April 4th, 2010

After programming for more than ten years I gradually refined my commenting style to a level that I am satisfied with, at least for now. Long story short, this is an example for C++:

// This is a comment.

Simple and precise. Let me explain why. The general format follows this pattern:

1. Comment character(s), such as /*, //, #, %.
2. Space.
3. Comment string, that starts with a capital letter (with rare exceptions).
4. Period.
5. Comment closing character, such as */, –>

1, 3, and possibly 5 must be present in any comment. Let’s focus on the parts that can be present or omitted. I include Space before the comment string to differentiate between a comment line and a commented out code:

// Use it as follows:
// exec(true);
//exec(yFlag);

In the example above, the first two lines are comments, because there is a single space before the comment string. The last line is a commented out line of code.

I use capital letter to start a comment and a period after a comment sentence for multiple reasons. First, it forces to make comments from well formed sentences, which can be easier to understand as compared to incomplete sentences. Second, it tells me where a comment sentence starts and ends. For example, if I see a comment line that does not end with a period, then I can assume the next comment line must continue the same sentence. For example:

// This is one
// comment sentence.

To recap. A space before helps separate at a glance comments from commented out code. Following a formal sentence structure (start with a capital letter and finish with a dot) helps to understand the comments better and provides information about where the comments start and end.

Government and business

March 13th, 2010

While looking for a company to work for in Baltimore area, I looked at all local hi-tech companies that have a website. For me it was surprising to see that some companies allocate the central place on their home page to a message “Minority/woman/veteran operated company!” I have read Atlas Shrugged so I clearly understand why they do it. Nevertheless, the fact that a business puts such a message in the center of attention, instead of its business merits, is disturbing. It is disturbing exactly for the reasons described in Atlas Shrugged.

Windows 7 wakes up unexpectedly

March 7th, 2010

I noticed that my computer wakes up without an apparent reason. Quick google search led me to the following information:

rem Change wake settings.
rem Get list of the devices.
rem PowerCfg -DEVICEQUERY wake_armed >DeviceList.txt
rem I got:
rem 	HID Keyboard Device (002)
rem 	HID-compliant mouse (003)
rem 	Intel(R) 82567LF-2 Gigabit Network Connection
rem Disable one devices one by one.
PowerCfg -DEVICEDISABLEWAKE "HID Keyboard Device (002)"

PowerPoint cuts off embedded sounds

February 12th, 2010

I was making a presentation in PowerPoint 2007 sp1. Yes it does matter what service pack you have, I encountered that animations done in sp1 did not work the same in PowerPoint without the service pack. The long story short, some sound files were not played completely during the slide show, even though preview did play them completely. After changing actual files with audacity (trying to make the sound files play correctly), I realized that if the files are not embedded in the presentation they are played just fine. I know there is sp2, but I did not want to update to it before my presentation is over. And in general, OpenOffice is waiting for my next presentation.

C++ logger class

February 8th, 2010

I was looking for a logger implementation for one of my projects. I needed a few features: simultaneous output to a console and a log file, efficiency, and ease of use. Quick google search revealed a few candidates: Apache log4cxx, and Pantheios. Do it yourself articles (example) about home made logging I ignored, because I have done enough of those (Boost Logging Library v2 is in the same category for me). Given that my primary platform is Windows, log4cxx was dropped, as windows was not directly supported.

Compiling a few examples for pantheios was not difficult, but getting it to do exactly what I planned, which is to have output to a console and a file at the same time, was a little more challenging. The solution was not obvious from the documentation, and sample name mx.1 did not stand out to me as meaning Mixing different back ends. But after searching in pantheios forums I have found the answer to my question.

At the end of the day Pantheios was my choice. We will see how happy I will be with it after I play with it for a while.

Avatar

January 18th, 2010

Avatar movieIn short, I liked it. Yes – it was a bit long, yes – it was naive, yes – there were no strategy in the final battle. Nevertheless, I enjoyed the movie and recommend anyone to watch it in a movie theater on a big screen.

Electric shaver

January 18th, 2010

Braun Series 7- 790cc Pulsonic ShaverMe and my wife decided to make a present to both of us by buying an electric shaver for me (who does not like presents like that?). Shaving every day with a regular razor irritates my skin, which is not fun. Not shaving every day irritates my wife’s skin, even less fun. My only experience with electric shavers was when I used a cheap kind, which did not do a good job. That’s why we decided to invest in an expensive shaver. Enter Braun Series 7- 790cc Pulsonic Shaver. The first impression was… very good. We will see how my skin reacts to it after the adjustment period of a few weeks.

RescueTime vs ManicTime vs Wakoopa

January 18th, 2010

After running ManicTime I found the application was not meeting my requirements exactly. The application does not reuse tags automatically, this means that I need manually assign tags every an application was used. On the other hand, the statistics pane allows me to create specific groups of applications that are used to show time, which essentially gives me the result I want. The downside is that there is no information about what documents were open by the applications. If I use the same applications for different projects, then I can not differentiate between those projects. On the good side, the program author responded very quickly to my request and promised that the new release will have some updates that will be useful for me.

Software for time tracking

December 13th, 2009

I have been using RescueTime for more than a year. By “using” I mean that the application was running on my computer. Time to time I went online to see how my time was spent. Recently, after not visiting the site for a long time, I found out that my data is stored only for three month and some features (a year overview among others) are available only in paid accounts. It seems that $50 a year is not that much. But before committing my cash I decided to see what other options are there. Thanks to alternativeto.net (new website to me, and a good one too) I found a few alternatives.

Before going through the alternatives, I will specify what it is that I am looking for from an application like this. The most important usage for me is to know how much time I spent on a certain project. This simply means that I want to be able to specify what applications (documents in applications) corresponds to what project. Tagging is a way to do that. The next step is to see how much time different activities within a project occupied my time. This is also can be accomplished by tagging. I see benefits of storing the data online, but it is not a priority for me, because I do not plan to use multiple computers. For the next year or so I see myself working exclusively with windows and hence support for other operating systems is not a priority.

wakoopa: First impression was negative. After business like RescueTime, all the colors, pictures, and profiles looked a little alarming. Similarly to RescueTime, the data is stored online. Unlike RescueTime the account is free.

slifelabs: Looks too commercial without enough information to convince me to try them. Hence I did not even sign up there.

ybex: Seems to be oriented on what they need and my benefit is a side effect. This was not very convincing, hence no signing up there either.

manictime: Unlike RescueTime, the data is stored locally and the program is freeware, but for Windows only. The application has much larger memory footprint than other solutions.

Osho books.

November 8th, 2009

I enjoy reading Osho’s books, even though they do get repetitive (for a good reason), here are some thoughts about them.
Freedom: The Courage to Be Yourself (Insights for a New Way of Living Series)

Freedom. This book introduced me to a few interesting concepts: “freedom for”, and “three dimensions of freedom”. Given that for Osho (and I agree with him) freedom is the ultimate goal, the topic of freedom is a very important topic. Surprisingly I was thinking very little about this topic before (yet another stab into self-hypocrisy). Great read.

Joy: The Happiness That Comes from Within (Osho, Insights for a New Way of Living.)

Joy. Yet, another good read. If you understand the difference between pleasure, happiness, and joy, there is no need to read the book. If you do not know what is the opposite of joy, or how pain and pleasure are connected, then, please, read the book.

Intuition: Knowing Beyond Logic

Intuition. Taxonomy of bases for our actions: instinct, intellect, and intuition. The differences and similarities between these methods are explained. A very good book to read for a scientist.

Meditation: The First and Last Freedom

Meditation. Different meditation techniques with some explanation of why and how they work. An amusing read, but I am not sure that it is fully applicable to our times.