Interview Questions Headline Animator

Friday, July 11, 2008

Is Code Folding that bad...?

I am a huge fan of Jeff Atwood and Coding Horror. I usually like his stuff. But I somehow didn't agree too much to his post where he talks about Code Folding (#region). I mean of course I also agree with a few things that he says, so let me put them down here:

 

Things that I do not agree with:

  • "Folding directives are Glorified Comments": We don't fold code to accommodate the editor, we do it to accommodate ourselves. Code folding is more like indexing. I index my code so I know exactly where to go when I am reading it. It is like creating folders for files. I go to a specific file and know I want to check an event handler for example. so I open the Event Handlers Region and reach the exact event handler I require. Besides, I agree that traditional comments are better and more descriptive, but they have a different purpose than #region.
  • "Folding is used to sweep code under the rug": Perspective, perspective... I would call it, "neatly arranging it in a nice closet and closing the doors instead of keeping everything out on an open shelf".
  • "Folding is used to mask excessive length": Nuclear power could cause a nuclear holocaust or it could assist in the creation of an alternative source of power to keep cars running, Air conditioner fans turning and perhaps to achieve warp speed, who knows. Writing short and clean code is a matter of personal discipline just like checking in code into your repository before leaving for home. Even when there were no regions, people did write excessively long and convoluted source code. And #regions wouldn't hide code during inspection or code reviews. Everything would be reviewed when it is reviewed; folded or otherwise. In fact, it might make reviews more convenient. The reviewer unfolds everything and then systematically folds everything that has been reviewed.
  • "Folding can hide deficiencies in your editor": This "scutwork" really helps good programmers to read code. And as I have read somewhere, good programmers read more code than they write. Code folding enables that.

Things that I agree with:

  • "The editor should automatically offer to fold up these common structural blocks to you"
  • "#region is criminally overused"
  • "Code should be written that doesn't need folding to be readable, clear and concise"

 

So Jeff, I love your writing, no questions... And you have a right to your opinions and to what you publish... But be gentle at times man...!

Friday, July 04, 2008

Do it smart: Shortcut Keys

Most interesting short cut keys on Visual Studio 2008:

  • Ctrl + R + R: Rename whatever is selected (Refactoring).
  • Ctrl + K + M: This is to create a new method stub. just call the method as it already exists and then hit the shortcut.
  • Ctrl + ".": Opens the smart tag window and allows you to add Using statements. you can also use it to add a non-existent method into a class. Just call the method as it already exists, click Ctrl + "." and select "Generate Method stub..."

image

  • Alt + Ctrl + E: Most useful. This will open the Exceptions window and let you stop or allow a few exceptions while debugging.

image

  • Ctrl + K + F and Ctrl + K + D: Indents the code properly. so "F" will format the selected code and "D" will indent the entire document.
  • Ctrl + - and Shift + -: Works like the back and forward buttons on the web browser. So if you navigate into a new place using F12 or Shift + F12, you can go back to the original location using this.
  • Ctrl + Tab and then use Arrow Keys: Ctrl + Arrow Keys allow you to take a look at all the windows, tool windows, panels and let you navigate through them. So once you press Ctrl + Tab, it shows you the navigation window. Then you can use the arrow keys to navigate through all the panels windows, etc. You can go up, Down, Left, Right, and you can even see what's in focus.

image

  • F8 and Shift F8: These help you navigate through your search results. Hit it and get surprised.
  • Alt + F6: Moves to the next tool window.
  • Ctrl + F6: Cycles through the MDI child windows one window at a time.

Thursday, July 03, 2008

Funny Behavior of Google Talk

I was booting up my machine. I had just logged in and all the apps were firing up one by one. So I must have fired up something and might be typing into it, when Google Talk fired up in between. So everything that I had imagejust written went into the google talk sign in textbox.

Now, I usually save my user id and password on google talk so it automatically signs in. So, since i had typed in something by mistake into the User ID textbox, the user ID changed. So instead of my real id I had "my" typed into the user id input box. Ideally in a scenario like this, what should happen is it should try to log in and then once it fails, it should quit trying.

What Google talk did instead, is it kept on trying with the same user id and password over and over again, automatically. Now at this point in time, I don't even know something like this is happening in the back ground. So eventually when I come around to Google Talk, I see that the User ID is wrong and the status is "Account Locked". So I type in the correct UserID and I see a CAPTCHA to unlock my account. And interestingly the CAPTCHA doesn't give me an image, but it gives me a long message saying something like, "The service is unavailable at the moment, please try again later". So I wonder what would happen if I type in the entire message as a CAPTCHA input. So I did and interestingly, it solved the CAPTCHA.

Unfortunately all this happened so fast, I didn't take a screen print. Anyways, Now I tried it again. I signed out, typed in "my" into the user id input and tried to log in again. The status showed "Account Locked" which means they had locked out an account whose user id is "my" for trying to sign in with the wrong password more than the specified no. of times. Now I changed the user id to my real user id again and I see the CAPTCHA again, only this time it was a working real CAPTCHA with the image. Now I really wanted to check if this CAPTCHA is a real one or a fake one. Without putting in any input I just clicked Ok and it didn't give me an error message of any sort. It just logged me in.

So there are a no. of issues here:

  1. Log in shouldn't be tried multiple times automatically if the password is wrong. It should wait for User Input
  2. The user id that was locked was "my". After I change the User ID, it shouldn't give me a CAPTCHA because it not my user id that is locked that needs unlocking.
  3. The CAPTCHA should be potent. So the input I give should be properly validated which is not being done in this case. Now this is a special case. but if the CAPTCHA is given it should be validated or it shouldn't be given at all.
  4. In case there are errors and if the CAPTCHA Service is down, it should not show me the error message as a CAPTCHA.

 

So my question is how much would you really pay for a software like Google Talk? Yes I know, there is great power in simplicity. And even though Google talk doesn't provide features like great smileys and stuff, it lets you talk. For free, this is good enough. But how much would you really pay for it? Another question that pops in is would you use a software like this for business communication?

As mentioned in one of the posts, Google gives a lot of importance to the cool factor. Would you really pay for a cool software or a software that could be used for business application? Where's the ROI...? People talk a lot about Google being in competition with Microsoft. I don't really think it stands tall enough.

Wednesday, July 02, 2008

Planning to join Google...? Think again.

Sarang just posted on his blog about this post. And it really impressed me. So I thought it has to be mentioned about on my blog too. I specially like the part where he says that Google's idea of business is to amuse and attract people. And that most of Google's product promote wasted online time.

So this post is about a post that was posted on a Sarang's Blog Post :). Anyways, you should read it yourself.