Blogroll

If you failed (because I am) to use Git bash all the time just to look cool and geeky, the following article will help you to add GitExtensions support. So you will be able to call them right from your Git bash or posh-git.

So my daily usage looks like the following:

#will open diff dialog

git ex viewdiff

#will open commit dialog

git ex commit

#will open GitExtensions start page

git ex

UPDATE

You can use the following PowerShell script to do all the stuff for you:

Our team has recently updated to TortoiseHg 2.0 and everybody were frustrated with the update that came with it regarding shelving. Sometimes you simply can’t unshelve your files, while keep receiving the following message “1 out of 1 hunks FAILED”:

Solution

If you are aware of what I am talking about here is the quick fix for you:

Add following lines

[patch]

eol = auto

into the next file

%userprofile%\mercurial.ini

Enjoy!

Why it happens?

It’s because of EOL handling problems when running mecutial under Windows, this line enables patch to fix it.

That’s why we subconsciously always looking for this complexity. And this is where things become interesting. Its often a challenge for programmer to prevent himself from overarchitecting and overcomplicating solutions. It can become a real problem for smart guys. As far as I am smart =) this is a real challenge for me too.

What should we do?

I propose a simple solution – convince yourself that keeping thing as simple as possible is a bigger challenge than making them complex. Following the KISS (“Keep it simple, Stupid!“) principle is a very difficult task itself.

It is very easy to make things complex when you are smart, but it is unbelievable hard to keep them simple.

I’ve seen both used in C# and in JavaScript, but it was always interesting why last one is much more popular in JavaScript and first one in C# and C++. Now I have the answer:

Putting braces on the same line after statement prevents from doing silly JavaScript mistakes, possible thanks to ECMASrcipt standard.

It states the following:

Certain ECMAScript statements (empty statement, variable statement, expression statement, do-while statement, continue statement, break statement, return statement, and throw statement) must be terminated with semicolons. Such semicolons may always appear explicitly in the source text. For convenience, however, such semicolons may be omitted from the source text in certain situations. These situations are described by saying that semicolons are automatically inserted into the source code token stream in those situations.

When calling Bar() function you will see “undefined” and then “8” . This happens because JavaScript is too smart and put semicolon after first return statement (predicting your intent, that is actually should be a marketing slogan), so your anonymous object declaration will never be executed. Why? Here is a little intriguing pause and some dummy text that takes a little more time to read… And finally the answer is: “For convenience”, as told us by ECMA. Enjoy and don’t forget to feel convenient =)

Recently I was watching a video from Uncle Bob (aka Robert Martin) about craftsmanship and ethics in which he was saying the following:

Do not pass boolean parameters to a method or I’ll find you!

Why? Cos you probably won’t understand following lines of code:

this.DeleteCustomer(true); //what does it mean "true"?
//or even more triky
this.HiglightText(true, false, false);

So while looking on above method calls you will need to hover your mouse or press some hotkeys to get information about signature and actual meaning of parameters. And it works only if you are watching you code through IDE. Boring isn’t it?

Lets assume that first method has the following signature:

public void DeleteCustomer(bool onlyMarkAsDeleted);

Instead of doing this I prefer split this method on two, where each one is more explicit:

this.DeleteCustomer();
this.MarkCustomerAsDeleted();

This is possible only if you own the code, so you are able to perform such refactoring. In other case I prefer to go with one of the following ways:

Define a local variable with a meaningful name and make value assignment right in method call:

My name is Anton Vinogradenko, I am from Ukraine. I’ve just gotten your book (CLR via C# 3rd) from Amazon and I’m very impressed with its Foreword, so I want to ask you to translate it into Russian and post on my recently opened blog (http://restuta.net). Thanks!