Tag Archive: english


Before we dive into the topic of this post, I would like to share with you the best possible advise I could ever give – never do everything by the book.

I know it sounds kinda odd and may appear to be irresponsible. After all, this series is about what to avoid and promote best practice. Am I not asking you do what I tell you? No, I am not.

I am asking you to think and to reason consciously why you chose to code something the way you did.

In the first post of this series, I wrote about how returning early improves code readability. It may appear so in the code snip presented in the post. It may seem to be appropriate in scenarios off the top of your head. However, I am most certain that there are contexts where returning early actually does the opposite – hurting code readability.

It is important that we understand a best practice is anything but the law. When circumstances change, it may not stand.

I ask you to think as you code.

Now, back to the topic. In this post, we will revisit a well known best practice from a less discussed perspective. View full article »

A very interesting and informative answer on Stack Overflow.

Note in the end of the post, author of the answer presented a trick demonstrating how one could overload functions by return type. Coincidentally, a similar hack had been shown in an earlier post of mine.

One more example why you shouldn’t insist on using different naming schemes to name classes from functions consistently.

Hey, sometimes, objects are functions and functions are objects.

It has been a while since I last wrote. It is not that I wrote enough, I still love it, and am keen to share my (possibly biased) thoughts with fellow developers out there. But life and work have kept me busy in the past few months, busier than I would like to be.

Anyhow, I am starting a series of posts called “Root of All Evil”. The plan is to write about bad practices I see at work, on the Internet, and smelly code I used to write. I hope to be able to cover the following aspects:

  • What does bad code look like
  • Why is it bad
  • And how it could be improved/refactored

If you happen to care reading my blog, chances are you won’t be contributing too many of those. However, even if they were someone else’s responsibility, it is essential that you I encourage you to step up, and talk him/her into making necessary changes and quitting the habit, perhaps over a cup of coffee or via a formal code review.

Though it is unlikely that I would have the luxury and the time to write weekly as I used to, I will just do my best. This series will be written casually, in Chinese or in English, yes, depending on my mood. So, bear with me and here it goes. View full article »

The issue with boost::decay documentation that I blogged about 10 days ago has been fixed in trunk.

Bit-fu

Did you know, for x is an integer, that -~x yields x + 1 and ~-x yields x - 1?

via: Advanced bit manipulation-fu.

It is true that C++ provides programming constructs those consume more CPU cycles than it would when done without higher level of abstractions. But, hey, that’s the cost of abstractions, why pay when they are not needed?

Stop laying out your C++ design like Java. Avoid inheritance when possible. Don’t make every member function and destructor virtual without really thinking. They not only increase your run time overhead, they boost the complexity (read coupling) of your code like nothing else.

C++ does every C-style stuff the same way as C does. Not to mention it is capable of more compile time computation than C. I just fail to see how C++ could be slower than C in run time, seriously.

I’ve always wondered: What does the “Zw” prefix (of some NT kernel functions) mean?

As it turns out – nothing.

Okay. Asus, this move is not cool.

Perhaps it’s better without you, altogether. Bye.

Cited from: The Register.

In a recent post of Scott Wheeler’s – C and C++ are not the same language. He talked about differences between C and C++, and applications of different programming languages (C, C++, Java, Ruby) in his company.

In the post, Wheeler implemented observer pattern in C, C++ and Java, demonstrating some of his points – including how C and C++ are different from each other, and how C++ and Java are actually more alike.

Though I do agree with Wheeler’s conclusion for the most part, I failed to share his view in C, C++ and Java comparison. IMHO, his observer implementation in C++ is rather old school, or should I say it’s so Java.

View full article »

Giorgio (author of NoScript) apologized and explained things from a somewhat different (i.e. his) perspective.

As Giorgio said himself, it was wrong and there is no excuse. Though, from a user’s point of view, I do not agree with his doings in this instance. However, from a geek’s (i.e. my) point of view, they were not unthinkable.

My take, Giorgio was hacking, not for the greater good obviously, but there was no intention to takeover the world (or helping bad guys doing so) neither. That is if it is his true thinking that he told us.

For now, I am keeping NoScript.