Wednesday, March 26, 2008

INTEGRITY THROUGH TRUST AND CARING

When I was a freshman at College, I needed to send my oboe through the mail to have some repair work done. I was really worried about mailing it; my first oboe teacher had sold the instrument to me, and I didn’t want it to be damaged. A friend told me that I could insure it through UPS, and directed me to a small neighborhood business called “Touchette” that did UPS insurance. I took the bus downtown, oboe in my lap, and when I arrived at the store the proprietor was very kind and reassuring. He helped me package the oboe as well as possible, and was able to insure it. However, the total cost was $30, and I had only brought $20 with me. My heart sank at the thought of squeezing another bus ride into my hectic schedule when he said. “That’s OK, I trust you. Just give me your name and number, and pay me the rest when you get the chance.” I was astounded. Who had heard of a business owner just volunteering to trust someone like that? That act of kindness stuck in my memory and still reminds me that integrity is built through trust and caring for one another’s needs.

Monday, February 25, 2008

Refactoring your code with VS.NET 2005

Introduction
There are developers who write code and then there are developers who write better code. The difference is obvious. Writing good code is skill that not all developers have. This also implies that this skill can be improved. A part of this skill includes ability to refactor the code that you or somebody else has written. VS.NET 2005 includes a set of features that help you in this regards. This article is going to discuss what refactoring is and how VS.NET 2005 helps you to refactor your code.
What is refactoring?
As a developer all of us write code in one or the other language. Often the code we write is not the best piece of software in terms of its organization, arrangement, readability and structure. When we (or somebody else) review our own code we realize that it needs to be improved or even rewritten at certain places. This process of improving our code is called as refactoring. Note that the term refactoring implies that we are improving the code without changing its intended functionality or meaning.
Some of the common refactoring tasks include:
Changing signature of methods
Renaming variables
Creating interfaces out of existing code
Convert a block of code into a separate method
Refactor menu
Now comes the interesting part. VS.NET 2005 includes a menu called "Refactor" that helps you to perform many of the common refactoring tasks. The following figure shows the Refactor menu and its items.
Renaming variables, properties and methods
Many times it happens that after writing huge amount of code you feel like changing names of variables, properties and methods involved. Common reason being improved readability. The traditional approach is to use "Find and Replace" option from edit menu. Unfortunately our code is not a work document and invoking "Find and Replace" may not prove useful. Moreover chances of accidentally replacing unintended tokens are high (recollect how often you used Ctrl+Z after that mighty Replace All command). The Rename menu option from the Refactor menu helps you do this task easily.
You need to go the variable or property or method name that you intend to change and select "Rename" menu option. This will open a dialog as shown below:
You can enter the new name for the variable, property or method and click OK to change it everywhere. You can also preview the changes before you apply them. The following figure shows the preview dialog. See how you can uncheck the locations where change is going to occur.
Additionally you can control if you want to change the name in comments and string literals.
Extracting a method
Consider a typical scenario. You start coding a lengthy method consisting of some complex sets of algorithms. After completing the method you realize it has become huge and complex enough that other team members can not understand it with ease. Hence, you decide to break it down in multiple small functions. This not only simplifies your code but also improves its readability and maintainability. The "Extract Method" option of Refactor menu does the job for you.
In order to use this menu option you must select a block of code that you want to separate out as a method and then click on the "Extract Method" menu option. The following figure shows the extract method dialog.
Once you enter the name of the new method to be created and click OK it does two things for you:
It creates a new method as per your choice and places all the selected code inside it
It replaces the selected lines with a call to this newly created method
Creating properties that wrap class level variables
Let's accept the fact that many developers have habit of exposing class level variables (fields) to the external world. As per object oriented programming one should allow access to variables only through properties or methods. Such circumstances can be dealt with the help of "Encapsulate Field" option of Refactor menu.
Select the class level variable that you want to wrap inside a property and choose the "Encapsulate Field" option. This will open a dialog as shown below:
You need to enter the property name and decide if you want to update the references to the variable from outside the class or from outside as well as inside of the class. Just like Rename dialog you can preview the changes before applying.
Extracting interfaces
Sometime it happens that after coding a class you realize that there are going to be other classes bearing similar structure but different implementation. This is a perfect case for interfaces and "Extract Interface" option from Refactor menu does the job for you.
You need to be in the class and select "Extract Interface" to pop up a dialog as shown below:
You need to specify the name of the interface, the file name in which to store the interface and the members to be included in the interface. Clicking on OK creates a new file and creates an interface within in. Also, the class from which you extracted the interface is automatically marked to be implementing the interface.
Promoting local variables to method parameters
Another common scenario is converting local variables from a method as method parameters. In this case "Promote local variable to parameter" option of the Refactor menu comes handy. Simply place your custom at the line where you have declared the variable and click on this option. You fill find that the variable now appears as a method parameter and all the calls to the method get updated accordingly. Note that in order for this option to work it is necessary to initialize the variable to some value.
Removing method parameters
They way you may need to promote local variables as method parameters, you may also need to remove some or all method parameters (changes are always unexpected you know). In such cases "Remove Parameters" option from Refactor menu comes handy.
You need to be inside the method whose parameters are to be removed and select "Remove Parameters" option. This will bring a dialog as shown below:
You can then remove the required parameters. The good part is that all the method calls as well as interface definitions will also be updated according to the new signature. As before you can preview changes before applying.
Reorder method parameters
Adding method parameters, removing them is fine. But what about re-ordering them? Don't worry. There is "Reorder Parameters" option that does just that. This option works only for methods with two or more parameters. When selected it opens a dialog as shown below:
You can move the parameters up or down and see the preview as before. As with remove parameter option all the method calls automatically get updated as per the new order of parameters.
Summary
Refactoring is important and common requirement in many development scenarios. VS.NET 2005 provides necessary tools to quickly refactor your code and improve its overall organization, structure and readability

Sunday, January 20, 2008

Once in America a plane crashed,
only a monkey who was traveling in the plane was left alive.
Fortunately the monkey was intelligent enough to understand our language and reply in actions.
The officials went to see the monkey in the hospital and had a talk with the monkey.

Officer: "When the plane took off what were the travelers doing?"
Monkey: "Tying their belts"
Officer: "What were the airhostesses doing?"
Monkey: "Saying Hello! Good morning!"
Officer: "What were the pilots doing?"
Monkey: "Checking the system"
Officer: "What were you doing?"
Monkey: "Looking for my people"
Officer: "After 10' minutes what were the travelers doing?"
Monkey: "Having beverages and snacks"
Officer: "What were the airhostesses doing?"
Monkey: "Serving the travelers"
Officer: "What were the Pilots doing?"
Monkey: "Handling the steering"
Officer: "What were you doing?"
Monkey: "Eating & throwing"
Officer: "After 30 minutes what were the travelers doing?"
Monkey: "Some were sleeping and some were reading"
Officer: "What were the airhostesses doing?"
Monkey: "Make up"
Officer: "What were the pilots doing?"
Monkey: "Handling the steering"
Officer: "What were you doing?"
Monkey: "Nothing"
Officer: "Just before plane crash what were the travelers doing?"Monkey: "All were sleeping"

Officer: "What were the pilots doing?"
Monkey: "Handling the air hostess"
Officer: What were you doing?
Monkey: Handling the steering!!!! !
No more Questions!!! !!!!!!!!! !!!!!!!! ( to monkey)

IT Guys will never change.....

Two IT guys were chatting in a pub after work. "Guess what, mate," says the first IT guy, "yesterday, I met this gorgeous blonde girl in a bar." "What did you do?" says the other IT guy. "Well, I invited her over to my place, we had a couple of drinks, we got into the mood and then she suddenly asked me to make her feel special" "You're kidding me!" says the second IT guy. "I then I lifted her and put her on my desk next to my new laptop." "Really? You got a new laptop? What configuration?" "It's a 1 GB RAM and mobile internet connectivity card and 180GB HARDDISK..Wi-Fi..DVD-Writer......................"

Windows 100 Keyboard Shortcuts

Microsoft windows keyboard shortcuts. You might know most of these shortcuts, but probably not all of them. If you have more keyboard shortcuts, please let me know :)
CTRL+C (Copy)
CTRL+X (Cut)
CTRL+V (Paste)
CTRL+Z (Undo)
DELETE (Delete)
SHIFT+DELETE (Delete the selected item permanently without placing the item in the Recycle Bin)
CTRL while dragging an item (Copy the selected item)
CTRL+SHIFT while dragging an item (Create a shortcut to the selected item)
F2 key (Rename the selected item)
CTRL+RIGHT ARROW (Move the insertion point to the beginning of the next word)
CTRL+LEFT ARROW (Move the insertion point to the beginning of the previous word)
CTRL+DOWN ARROW (Move the insertion point to the beginning of the next paragraph)
CTRL+UP ARROW (Move the insertion point to the beginning of the previous paragraph)
CTRL+SHIFT with any of the arrow keys (Highlight a block of text)
SHIFT with any of the arrow keys (Select more than one item in a window or on the desktop, or select text in a document)
CTRL+A (Select all)
F3 key (Search for a file or a folder)
ALT+ENTER (View the properties for the selected item)
ALT+F4 (Close the active item, or quit the active program)
ALT+ENTER (Display the properties of the selected object)
ALT+SPACEBAR (Open the shortcut menu for the active window)
CTRL+F4 (Close the active document in programs that enable you to have multiple documents open simultaneously)
ALT+TAB (Switch between the open items)
ALT+ESC (Cycle through items in the order that they had been opened)
F6 key (Cycle through the screen elements in a window or on the desktop)
F4 key (Display the Address bar list in My Computer or Windows Explorer)
SHIFT+F10 (Display the shortcut menu for the selected item)
ALT+SPACEBAR (Display the System menu for the active window)
CTRL+ESC (Display the Start menu)
ALT+Underlined letter in a menu name (Display the corresponding menu)
Underlined letter in a command name on an open menu (Perform the corresponding command)
F10 key (Activate the menu bar in the active program)
RIGHT ARROW(Open the next menu to the right, or open a submenu)
LEFT ARROW (Open the next menu to the left, or close a submenu)
F5 key (Update the active window)
BACKSPACE (View the folder one level up in My Computer or Windows Explorer)
ESC (Cancel the current task)
SHIFT when you insert a CD-ROM into the CD-ROM drive (Prevent the CD-ROM from automatically playing)
Dialog Box Keyboard Shortcuts
CTRL+TAB (Move forward through the tabs)
CTRL+SHIFT+TAB (Move backward through the tabs)
TAB (Move forward through the options)
SHIFT+TAB (Move backward through the options)
ALT+Underlined letter (Perform the corresponding command or select the corresponding option)
ENTER (Perform the command for the active option or button)
SPACEBAR (Select or clear the check box if the active option is a check box)
Arrow keys (Select a button if the active option is a group of option buttons)
F1 key (Display Help)
F4 key (Display the items in the active list)
BACKSPACE (Open a folder one level up if a folder is selected in the Save As or Open dialog box)
Microsoft Natural Keyboard Shortcuts
Windows Logo (Display or hide the Start menu)
Windows Logo+BREAK (Display the System Properties dialog box)
Windows Logo+D (Display the desktop)
Windows Logo+M (Minimize all of the windows)
Windows Logo+SHIFT+M (Restore the minimized windows)
Windows Logo+E (Open My Computer)
Windows Logo+F (Search for a file or a folder)
CTRL+Windows Logo+F (Search for computers)
Windows Logo+F1 (Display Windows Help)
Windows Logo+ L (Lock the keyboard)
Windows Logo+R (Open the Run dialog box)
Windows Logo+U (Open Utility Manager)
Accessibility Keyboard Shortcuts
Right SHIFT for eight seconds (Switch FilterKeys either on or off)
Left ALT+left SHIFT+PRINT SCREEN (Switch High Contrast either on or off)
Left ALT+left SHIFT+NUM LOCK (Switch the MouseKeys either on or off)
SHIFT five times (Switch the StickyKeys either on or off)
NUM LOCK for five seconds (Switch the ToggleKeys either on or off)
Windows Logo +U (Open Utility Manager)
Windows Explorer Keyboard Shortcuts
END (Display the bottom of the active window)
HOME (Display the top of the active window)
NUM LOCK+Asterisk sign (*) (Display all of the subfolders that are under the selected folder)
NUM LOCK+Plus sign (+) (Display the contents of the selected folder)
NUM LOCK+Minus sign (-) (Collapse the selected folder)
LEFT ARROW (Collapse the current selection if it is expanded, or select the parent folder)
RIGHT ARROW (Display the current selection if it is collapsed, or select the first subfolder)
Shortcut Keys for Character Map
After you double-click a character on the grid of characters, you can move through the grid by using the keyboard shortcuts:
RIGHT ARROW (Move to the right or to the beginning of the next line)
LEFT ARROW (Move to the left or to the end of the previous line)
UP ARROW (Move up one row)
DOWN ARROW (Move down one row)
PAGE UP (Move up one screen at a time)
PAGE DOWN (Move down one screen at a time)
HOME (Move to the beginning of the line)
END (Move to the end of the line)
CTRL+HOME (Move to the first character)
CTRL+END (Move to the last character)
SPACEBAR (Switch between Enlarged and Nor mal mode when a character is selected)
Microsoft Management Console (MMC) Main Window Keyboard Shortcuts
CTRL+O (Open a saved console)
CTRL+N (Open a new console)
CTRL+S (Save the open console)
CTRL+M (Add or remove a console item)
CTRL+W (Open a new window)
F5 key (Update the content of all console windows)
ALT+SPACEBAR (Display the MMC window menu)
ALT+F4 (Close the console)
ALT+A (Display the Action menu)
ALT+V (Display the View menu)
ALT+F (Display the File menu)
ALT+O (Display the Favorites menu)
MMC Console Window Keyboard Shortcuts
CTRL+P (Print the current page or active pane)
ALT+Minus sign (-) (Display the window menu for the active console window)
SHIFT+F10 (Display the Action shortcut menu for the selected item)
F1 key (Open the Help topic, if any, for the selected item)
F5 key (Update the content of all console windows)
CTRL+F10 (Maximize the active console window)
CTRL+F5 (Restore the active console window)
ALT+ENTER (Display the Properties dialog box, if any, for the selected item)
F2 key (Rename the selected item)
CTRL+F4 (Close the active console window. When a console has only one console window, this shortcut closes the console)
Remote Desktop Connection Navigation

CTRL+ALT+END (Open the m*cro$oft Windows NT Security dialog box)
ALT+PAGE UP (Switch between programs from left to right)
ALT+PAGE DOWN (Switch between programs from right to left)
ALT+INSERT (Cycle through the programs in most recently used order)
ALT+HOME (Display the Start menu)
CTRL+ALT+BREAK (Switch the client computer between a window and a full screen)
ALT+DELETE (Display the Windows menu)
CTRL+ALT+Minus sign (-) (Place a snapshot of the active window in the client on the Terminal server clipboard and provide the same functionality as pressing PRINT SCREEN on a local computer.)
CTRL+ALT+Plus sign (+) (Place a snapshot of the entire client window area on the Terminal server clipboard and provide the same functionality as pressing ALT+PRINT SCREEN on a local computer.)

Internet Explorer navigation
CTRL+B (Open the Organize Favorites dialog box)
CTRL+E (Open the Search bar)
CTRL+F (Start the Find utility)
CTRL+H (Open the History bar)
CTRL+I (Open the Favorites bar)
CTRL+L (Open the Open dialog box)
CTRL+N (Start another instance of the browser with the same Web address)
CTRL+O (Open the Open dialog box, the same as CTRL+L)
CTRL+P (Open the Print dialog box)
CTRL+R (Update the current Web page)
CTRL+W (Close the current window)