Thursday, January 22, 2009

[C#, C++] Cascading Constructors

In C# you can call a constructor of your class from another constructor of the same class to do something like this:

class Cake
{
private string name;
private int price;

public Cake(int price, string cakeName)
{
this.name = cakeName;
this.price = price;
//init stuff
}

public Cake(int price):this(price, "Cheesecake")
{
//init other stuff
}
}

Unfortunately there's no way to do this in good old C++, but there are two common ways for simulating a similar behavior:

1) Combine two (or more) constructors via default/optional parameters:

class Cake
{
private:
string name;
int price;

public:
//combines Cake() and Cake("whatever")
Cake(int price, string name = "Cheesecake Giovacchia")
{
this->name = name;
this->price = price;
}
}

2) Use an Init method to share common code:

class Cake
{
private:
int price;
string name;

init(int price, string name)
{
//do crazy common stuff with price and name
}

public:
Cake(int price)
{
this->init(price, "Cheesecake Giovacchia");
}

Cake(int price, string cakeName)
{
this->init(price, cakeName);
}

}

That's about it, I prefer the first solution (the second kinda sucks) but if anyone knows better I am all ears.

I am done sucking for today.

Tuesday, January 13, 2009

Ask a Google Engineer - He Won't Answer

Recently I noticed a very promising initiative on Google Moderator: Ask a Google Engineer.

Geeks are encouraged asking questions to Guido Van Rossum & Co. with no limitation - from "Do you use Google toilet paper" to the infamous interview question "How would you sort 1 million 32-bit integers in 2MB of RAM?".

Turns out most of the question (roughly 1500 in total so far) asked by people (roughly 5000 so far) are silly complaints about how limited is this or why it's not possible to do that in gmail.
 
The rest are pretty much questions studied to impress Mr.Van Rossum with very elaborated Python blabbering or people trying to understand how to find the answers for the questions they are voting. 

But really - where are the answers? There are none (almost). Seen the amount of crap they're getting they're sitting it out to enable questions to be filtered by people votes.

Not exactly a success so far I'd say (maybe also because Google moderator kind of sucks imho)!

Thursday, January 8, 2009

Speed-up Visual Studio Startup!

Who thought getting rid of the splash screen could speed up Visual Studio this much?
Add a /nosplash to the visual studio shortcut target and see for yourself. 

Now, the question would be WHY is it so fast without splash-screen (something dodgy going on there), but this really made my day!

Monday, December 29, 2008

Testers are cool at prime numbers

A software tester, a software developer, and a project manager are told: 
“All odd numbers are prime”
The Developer says:
“Let's see, 3 is prime, 5 is prime, 7 is prime - looks like it‟s true”
The Project Manager says:
“Let's see, 3 is prime, 5 is prime, 7 is prime, 9 is prime, 11 is prime –looks like it‟s true.”
The Tester says:
“That's silly, nine is a non-prime odd number - looks like it's bullshit”

I recently heard this very sad anecdote while attending a lecture about Software Testing. 

Everybody (except maybe a Test Manager) knows the developer would look up prime numbers on google before even trying to answer.

Anyway - here's a good resource about odd prime numbers humour.

Wednesday, December 24, 2008

[Poll] How many development feeds can you take?

To all of you information addicts out there - I was wondering how much information can people take.

At the moment I have 104 active subscriptions on my google reader, mostly development stuff, and I can barely keep up. I do not really read all the stuff that gets posted - I scan with my eyes and if my fast forward algorithm gets some keyword that I am interested in I go back and read the post.

If you add twitter to that there's enough for an overdose of information (but twitter is more about what people are doing and you don't really try to keep up if you don't wanna go mad).

How many feeds do-you/can-you follow (assuming you have a day-job)? Check-out the poll.

P.S. Happy Christmas to all the butchers out there from .NET Butchering 

[POLL RESULT]














kick it on DotNetKicks.com