Book review: A Brief History Of Time

Is it weird that my first book review is about a physics book instead of a book about computer science? Maybe. I think it is really important to look into different sciences in order to learn their approaches on solving problems. (And to be honest I thought it would look really cool to lie at the beach and read Stephen Hawking).

Stephen Hawking gives a short overview of the entire world of physics in chronological order. He explains everything from Isaac Newtons discovery of Gravity to his own work in the field of Black Holes. As someone who was always interested in physics and graduated from school doing my Abitur (German High School Diploma) in physics, this book felt like a reiteration of my complete knowledge of physics including everything from classical physics as Newton described it to modern physics based on Einsteins theory of general relativity.

Of course the book does not go into detail (after all it is a brief history), but explains how a physical theory is created based on observation and either proven or simply assumed to be true. These assumptions make up most of todays theoretical physics.

I find it fascinating how people spend all their lifes thinking about problems of theories that are after all based on assumptions. Not my world though. The book is really interesting and easily readable for people without a physics diploma (like me). It lacks details in rather important parts of the book (like the theory of general relativity or paulis exclusion principle).

I’ll give it a 7/10, because after reading the book I put it down and it made me think about it for a good hour. Isn’t that what a good book is supposed to do?

Why you should not use hungarian notation in modern programming

Okay, first of all a little backstory: I work on a ~15 year old C++ project (oldest code I’ve seen was from 1998). In our project we try to use hungarian notation. As a member of the team I swallow my pride and use that notation aswell.

We recently upgraded to Visual Studio 2015 and got a couple hundred new warnings of “local variables shadowing class members”. Looking at the code, most warnings were correct. But more importantly it got us to look at very old code.
Some local variables were named with the prefix “m_” indicating that they were member variables. Some floats had the prefix “n” indicating integer variables.

Let’s take a look at the most important parts of the hungarian notation and why I think it’s unnecessary.

Prefix USAGE Example Comment
m_ Member variable m_size This is by far the most common prefix in our source code.
n Number variable (usually int or long) m_nRowCount
f Floating point variable (usually float or double) fDistance
b Boolean variable bIsChecked
ctrl Usually used for GUI-Control elements ctrlEditBox I have actually never seen this outside of our code base.

Lets take a look at this variable:
m_unRwCnt
As the name suggests, this variable is an member variable of the type unsigned integer and represents the number of rows in some container. Now the question I’m asking is: Does this name say that much less?
RowCount
Well it’s a count of rows… What sense does half a row make? It’s obviously some sort of integer value. Does a negative amount of row make sense? No? Then it must be unsigned aswell! There are two more pieces of information left. Its scope and its length (integer or long). The scope of a variable should be visible by a glance at the code. As Robert C. Martin suggests, methods should be as short as possible in order to satisfy the Single Responsability Principle (SRP). Therefore it is never unclear whether a variable is local or comes from a greater scope. The length of the variable? What do I care? (Okay I’ll admit, im some rare cases e.g. pointer casting, this might be an important bit of information.)

Now lets look at the options a modern IDE offers us. When hovering over a variable we get all information about its scope and its type. So where does that put us? We can always get type and scope information of a variable when we are unsure and we don’t even have to click. And more importantly, when we don’t need it, it doesn’t clutter the code.

TL;DR:
The hungarian notation clutters the code and does not add any information the IDE doesn’t already offer. Meaningful names clear out any doubts about the scope of a variable.

Why this site exists

Hey guys,
well it was back in 2012 during a job interview that I was first asked whether I have a website. My answer was “No, why would I need one?”. Until recently I still felt that way. And yet today I’m writing this.

What changed?
Well… I’m done with my bachelor’s, I have 1.5 years of work experience and it’s now been more than 5 years since I’ve first hit a big green “COMPILE”-button. I’ve come across a variety of problems, which I have mainly solved mainly through the internet. I think It’s time to give something back.

I hope you guys find some interesting piece of knowledge on this webiste. Maybe a book review, maybe a solution to a problem I’ve come across, maybe just my opinion on a critical topic. Enjoy.