Yanesh Tyagi writes …

November 27, 2009

No return statement in the finally clause, please.

Filed under: .Net, Programming, Technology — yaneshtyagi @ 1:05 am
Tags:

You cannot put return statement in the finally clause because Control cannot leave the body of a finally clause (Compiler error code CS0157)…Why? MSDN says that all statement in the finally clause must execute. MADN also states that

The purpose of a finally statement is to ensure that the necessary cleanup of objects, usually objects that are holding external resources, happens immediately, even if an exception is thrown.

Thus for releasing all locks and hold objects or in other words control cannot leave the finally block before finishing the cleanup task. However, an exception can be occurred in the finally block. And if it is not handled properly, code execution will stop and error is thrown.

Technorati Tags: ,,
Digg This

November 20, 2009

Architecture Definition and Development

Filed under: Programming, Technology — yaneshtyagi @ 3:52 am
Tags:

One of the major challenge I felt as an architect is that client or project stakeholders want everything to be put in the architectural documents. A couple of days ago, I was in the conference with the client’s Project Manager. We were discussing the architecture of the new application, we are going to develop. I have mentioned major classes and components in the rational rose model. But the Project Manager was insisting that I should mention every class  in the model. And as this was not enough, he said that I should not miss any property or method of any class, public or private. And to make the things worst, requirements were not finalized at that time. We were expecting next version of the requirement documents in a couple of days. I had a hard time to convince PM that it’s neither possible not feasible to put so much details in the documents. So, I decided to post my thoughts on this matter.

What should be the depth of architecture?

This is the most challenging question for an architect. At the top level you can decide. For example you can settle down that the use case diagrams, component diagrams, class diagrams and sequential diagrams will do the work for your application. However, the problems comes when you decide depth of these diagrams. I have seen use case diagrams defined from the 30,000 feet to 100 feet.

For example, while looking at the design document for a web project, I found only one use case. This has two actors – webmaster and visitor. And there was only one use case – the application itself. A good example of 30,000 feet altitude view :) .

Anther extreme case was with a windows application with only three forms. And they have defined around 40 use cases for this. Each method was a use case in itself. A good example of 100 feet (or even 10 feet) altitude.

There are many same stories for other diagrams as well. As I stated in the beginning of this post, defining each and every method of each class in a big application is 10 feet altitude. This is neither feasible nor practical. I feel that we should remain at an altitude of 1000 feet to 5000 feet. At this range, we provide the details which are small enough for the management to have a bird’s eye view of the architecture and good enough for the development team to have guidelines to code. This does not bound the developers to the defined architecture – they are free (to certain extent) to showcase their creativity. Having clear understanding of the objectives of the architectural documents makes the decision making easier.

What is the objective of architecture and design document?

There are two types of technical documents – informational and manual. Manuals are supposed to have detailed information about any product, service, or whatever. But informational documents are meant for communication. If you put too much details in an informational document, its will be a waste of efforts. No one is going to read it line by line. Communication should be short and to-the-point. According to easycommunication.info, communication should be “adequate briefing of the recipient”. Notice that they use the word briefing. The same is true for architectural document.

These documents are supposed to communicate main architectural decisions and relationship with major components of the system. They should include only relevant information. If you put all the details in the architectural documentation, it will become a manual of the system and will fail to communicate its core purpose. So, what should be included in the architecture and design documents? This post is getting longer, so I will answer this question in the words of Martin Fowler, the architecture guru.

Do we define everything in the architecture?

Martin Fowler says “Draw a class diagram that shows the important classes in the package but not necessarily all of them”. He further tells that “For each class show only the key attributes and operations, definitely don’t show all of them”.

More of this stuff in the next post. I know you are getting bored.

 

Follow_Me_On_Tweeter_For_BlogTweet_This4

Digg This

August 25, 2009

Keyboard Shortcuts for Windows Live Mail

Filed under: Tips, Web Technology — yaneshtyagi @ 8:40 am
Tags: , ,

I hate using mouse on my laptop. It just slows down my work. If you are also like me, I have some tips for you. Here is a list of keyboard shortcuts for Windows Live Mail.

Shortcut keys of windows live mail

New Email ctrl+N
New Photo email ctrl+shift+P
Event ctrl+shift+E
News ctrl+shift+W
COntact ctrl+shift+N
Folder ctrl+shift+D
Open ctrl+o
Create New Folder ctrl+shift+D
Print ctrl+P
FInd message ctrl+shift+F
Move to Folder ctrl+shift+V
Delete ctrl+D
View Blocked Image F9
Mark as read ctrl+Q
Mark conversation as read ctrl+T
Mark all as read ctrl+shift+A
Message in HTML Alt+shift+H
Previous Message ctrl+<
Next Message ctrl+>
Next Unread Message ctrl+U
Next Unread Conversation ctrl+shift+U
*Next Unread Folder ctrl+J
Go to folder ctrl+Y
Go to mail ctrl+shift+J
Go to Calendar ctrl+shift+X
Go to COntcts ctrl+shift+C
Go to Feed ctrl+shift+K
Go to News Group ctrl+shift+L
Sync all mail messages F5
Sync everything ctrl+F5
Manage News Group ctrl+W
Reply ctrl+R
Reply to all ctrl+shift+R
Reply to group ctrl+G
Forward ctrl+F
Mark as junk ctrl+alt+J
Flag Message Alt+a+a
Watch conversation Alt+a+t
Ignore conversation Alt+a+i
Save as Alt+f+a
Save attachments Alt+f+v
Save as stationary Alt+f+t
Import Message Alt+f+i+m
Export message Alt+f+e+m
Export Accounts Alt+f+e+a
Find text in the message Alt+e+f+t
Copy to folder Alt+e+o
Empty Deleted Items Alt+e+y
Mark as unread Alt+e+n
Sort by assending Alt+v+b+a
sort by descending Alt+v+b+d
View by conversation

(Note: When you view by conversation, the reading pane comes to bottom. To move reading pane to the right ALT+V+L; ALT+G; Enter.)

Alt+v+v
Expend conversation Alt+v+x
Collapse Conversation Alt+v+a
Mail rules Alt+t+r+m
News rules Alt+t+r+n
Manage feed Alt+t+F
Manage IMAPI folders Alt+t+I
Manage Accounts Alt+t+c
Manage Safety Options Alt+t+t
Forward as attachment Alt+a+d
Add sender to safe list Alt+a+j+s
Add senders domain to safe list Alt+a+j+o
Add sender to block list Alt+a+j+b
Add domain to block list Alt+a+j+d
Create rule from message Alt+a+e
Flag Message Alt+a+f
Recombine Attachments Alt+a+m

Related Posts:

Emoticon Keyboard Shortcut For Live Mail And Live Messenger

Follow_Me_On_Tweeter_For_BlogTweet_This4

Technorati Tags: ,
Digg This

August 21, 2009

Twitter Notify Plug-in for Windows Live Writer

Filed under: Uncategorized — yaneshtyagi @ 5:00 pm

I just installed Twitter Notify plug-in on my live writer. This will send an update to twitter when I will publish this post. Let me test this.

This post is simply to test how it works.

August 18, 2009

Firefox redirects to urlseek.vms.net

Filed under: Technology, Web Technology — yaneshtyagi @ 1:00 pm
Tags: ,

Since last week I was tired with this malware. Whenever, I tried to open some incorrect URL, I first get the error 404 page but within the same moment Firefox redirected me to urlseek.vms.net site.

Suspecting this to be a behaviour of any add-on, I removed all of them. But this did not solve my problem. Then I thought that this may be a virus or some spyware. I have McAfee installed on my laptop. I scanned my laptop thoroughly. But it did not report any infection or other issue.

After little googling, I was confirmed that this is a malware. My McAfee was not able to detect this. I went into different forum and on one of the forum, I found the solution. I needed to shutdown the Firefox and forgot to note down the URL of the forum and name of the person who posted the solution. But the credit goes to that unknown helper.

Fix to the problem:

  1. Go to the following folder (on windows system) C:\Program Files\Mozilla Firefox\extensions. On other machines, you may go down to the folder where Firefox is installed and then go to the extensions folder within the Firefox folder.
  2. The will be a Search Settings (or search@settings) folder in within the extension folder. Delete this folder. If some access error is occurred, shut down the Firefox (close all open Firefox windows) and try again.
  3. Run the Firefox again and type some gibberish URL. If you are seeing normal page load error page, or the Google search page (if you have Google toolbar installed), you problem has been fixed.
  4. If the problem still persist, shut down the Firefox again and delete whole extensions folder. You may loose some of your settings but you problem will be fixed.

Follow_Me_On_Tweeter_For_BlogTweet_This_For_Blog

August 1, 2009

Google Toolbar stopped working with Firefox 3.5 – Fix

Filed under: Technology, Web Technology — yaneshtyagi @ 12:16 pm
Tags: ,

Just updated my Firefox from 3.0.12 to 3.5.1 version. Initially things seem to be smooth but soon I realized that Google Toolbar is not working. You press any button on the toolbar and nothing happened. It only displays a tiny callout icon on the screen at the mouse pointer position and it disappeared as you move mouse. I tried to click this icon but nothing happened.

Then I googled about the issue. There were many posts on the Mozilla support site but nobody has mentioned any fix. Then I got one link of Google’s support site. In the forum, somebody suggested to uninstall and re-install the toolbar. I did exactly and it worked. And the good thing is that I retained my custom settings of buttons. Seems that Google stores these settings on it’s servers.

So here are the steps to uninstall and reinstall the Google Toolbar:

  1. Open Add-ons dialog window of Mozilla Firefox. From the menu bar click on the Tools and select Add-ons.  This will open Add-ons window.image image
  2. Click on the Extensions tab. (image )
  3. Choose Google Toolbar for Firefox. You may need to scroll down the window.
  4. When you select the Google Toolbar, its row expands and shows you three buttons. Click on uninstall. This will uninstall the Google toolbar and then prompt you to restart the Firefox.
  5. Restart your browser. Click on the restart link on the Add-ons window. You can also close the window and then close your browser.
  6. When your browser is opened (or you may need to open Firefox again if closed manually), make sure that Google toolbar is not there.
  7. Open the Add-ons window again (see Step 1).
  8. Click on the Get Add-ons button. (image )
  9. In the search box type “Google Toolbar” and hit Enter.
  10. It will show you many search results. Select Google Toolbar from the search results. You me need to scroll down the window.
  11. Click in the Google Toolbar row. The row will expend and provide you a button “Add to Firefox”. This button is usually at the extreme right on the window. Sometimes you may have to scroll the window to the right.
  12. Click on the “Add to Firefox” button.
  13. When prompted, click on the install.
  14. Restart Firefox.

And you are done. Your Google Toolbar will now work fine.

 

Technorati Tags: ,

February 18, 2009

Charting Your Life

Filed under: Uncategorized — yaneshtyagi @ 9:20 am

Today I discovered Uladoo (pronounced yoo-LAH-doo). This is a nice charting utility which gathers data from twetter. Uladoo converts data from then creates chart and displays in the form of am image. You can use Uladoo to keep track of you coffee consumption or calories taken or weight loss program etc. You need to send a tweet (as many as you like) to @Uladoo and it updates the chart. You can browse the chart going to the Uladoo.com. It generates a URL for your chart which you can share with your friends and family members. You can even share this chart with your doctor.

How Uladoo Works:

You need to tweet Uladoo and it automatically updates the chart, if it exists. If the chart  does not exist, Uladoo creates on. For example, I send following tweet to create my coffee consumption chart

@uladoo coffee consumed 3

Then number 3 tells that I have consumed three cups of coffee from morning. Next time, when I will have another cup of coffee, I will tweet

@uladoo coffee consumed 1

and my chart will be updated. I can see this chart here.

How can you make Uladoo work for you:

You can make Uladoo work for you. First decide what you want to chart. It may be your cigarette consumption, number of calls you made to your girl friend/boss/client, lunch expenses, number of calories you take, your wife’s daily expenses etc. Some people track their daily exercise, pull-ups and push-ups.

 

Happy charting…

January 20, 2009

Configuring Live Writer for weblogs.asp.net

Filed under: Technology — yaneshtyagi @ 7:02 pm

This is the step by step guide to configure your Live Writer to use with your blog account at weblogs.asp.net.

Step 1: On the menu bar, select Weblog -> Add weblog account. This will display Add Weblog Account dialog shown below.Choose ‘Another Weblog Service’ and click on next.

image

Step 2: The next screen allows you to configure writer to work with your weblog. Enter the URL of your blog in the ‘Weblog Homepage URL’ text box. (For example, my URL is ‘http://weblogs.asp.net/yaneshtyagi’. Enter your username and password in the respective text boxes. Make sure that ‘Save my password’ checkbox is checked. (You can later change this setting using the ‘Edit Weblog Setting’ from the Weblog menu option). Click Next.

image

Step 3: If you have provided correct credentials, following screen will be displayed. This screen may take some time depending on the speed of your internet connection. Your Live Writer is now trying to connect to your weblog account and then it will detect the settings.

image

Step 4: The next screen will allow you to select weblog provider.  Select ‘Community Server’ from the list of providers. Enter the following address in the ‘Remote posting URL’ text box and then press Next.

http://weblogs.asp.net/metablog.ashx

image

Step 5: The next screen will ask you if you want your Live Writer to detect the style of your weblog. To do so, Live Writer sends a temporary post and then deletes this post. You can safely choose this option as this temporary post will never be published or visible to the readers of your weblog.

If you choose to allow Live Writer to detect your weblog’s style, it will format your post in the style you have chosen in you weblog, as you type in the Live Writer. This is useful because you can see the look and feel of your post without publishing it.

You may also opt not to allow Live Writer to send temporary post. In this case, it will not detect the style. This will have non effect on your post once you have posted (published) it.

Note: You can configure Live Writer to use many weblogs such as blogger, wordpress or msn spaces at the same time. You can then choose the weblog, on which you want to post, at the time of publishing the post.

December 2, 2008

Dynamically applying CSS based on browser’s resolution

Filed under: Technology, Web Technology — yaneshtyagi @ 11:12 am

Sometimes we need to change the layout of the page based on the resolution of the client machine or browser. For example, in one web site, I was required to change the position of the navigation bar. If the page is displayed in 800×600 mode, navigation bar has to be displayed on the right hand side. In case of 1024×768 resolution, it has to be on the left hand side. Even the appearance, font and background color, has to be changed for each position. So I did this using the JavaScript and CSS.

This post describes how to change the CSS based on the resolution of the browser. This is a step by step walk through.

Step 1 – Create CSS for 800×600 resolution

Create a new CSS file and name it 800.css. This CSS file will have styles for the 800×600 resolution. For this example I have chosen the background color as green and position of navigation bar on right hand side. Copy and paste (or type) the following code into this file and save this.

body{ background: #FF9999;}

.navbar{ float:right;}

 

Step – 2 Create CSS for 1027×768 resolution

Create another CSS file for the 1024x768 resolution and name it as 1024.css. 

I have chosen the background color to be red and position of the navigation bar on the left hand side.

The code for this file is as below:

body{     background: #99FF99; }

.navbar{     float:left; }

 

Step – 3 Create HTML File

Create a HTML file. This HTML file will import both the style sheets i.e 800 and 1024.

The code for this file is given below.

<HTML>

<HEAD>

    <TITLE>Dynamic Layout</TITLE>

    <link rel="stylesheet" type="text/css" href="800.css" id="800">

    <link rel="stylesheet" type="text/css" href="1024.css" id="1024">

</HEAD>

<BODY>

    This is the test for dynamic layout.

    <div class="navbar">

        <a href="#"> Navbar Link 1</a><br />

        <a href="#"> Navbar Link 2</a><br />

        <a href="#"> Navbar Link 3</a><br />

        <a href="#"> Navbar Link 4</a><br />

    <div>

</BODY>

</HTML>

 

Don’t forget to provide the Ids in the link tag. These Ids will be used in JavaScript to apply particular CSS. In the Body there is a div which displays the navigation bar. Class ‘navbar’ is applied on this div.

 

Step – 4 Insert JavaScript to handle resolution

The trick to change the CSS at client side is implemented through the JavaScript. Insert the below code into the ‘head’ section of HTML file created in the step 3.

<script type="text/javascript">

    if (window.innerWidth <= 800){

        document.getElementById("1024").disabled=true;

        document.getElementById("800").disabled=false;

    }

    else{

        document.getElementById("800").disabled=true;

        document.getElementById("1024").disabled=false;

    }

</script>

Window.innerWidth is JavaScript that provides the width of the browser window that is available to the HTML page. Based on the value of innerWidth property, I have enabled the desired CSS file and disabled the other.

 

The complete file should look like:

<HTML>

<HEAD>

    <TITLE>Dynamic Layout</TITLE>

    <link rel="stylesheet" type="text/css" href="800.css" id="800">

    <link rel="stylesheet" type="text/css" href="1024.css" id="1024">

    <script type="text/javascript">

        if (window.innerWidth <= 800){

            document.getElementById("1024").disabled=true;

            document.getElementById("800").disabled=false;

        }

        else{

            document.getElementById("800").disabled=true;

            document.getElementById("1024").disabled=false;

        }

    </script>

</HEAD>

<BODY>

    This is the test for dynamic layout.

    <div class="navbar">

        <a href="#"> Navbar Link 1</a><br />

        <a href="#"> Navbar Link 2</a><br />

        <a href="#"> Navbar Link 3</a><br />

        <a href="#"> Navbar Link 4</a><br />

    <div>

</BODY>

</HTML>

 

Save all the files and run the HTML File. Now change the resolution and run the file again.

October 21, 2008

Getting Browser Information and Capabilities in ASP.Net

Filed under: .Net, Programming, Web Technology — yaneshtyagi @ 7:40 am
Tags:

While developing a web site or web application, one need to keep in mind the features supported by different browsers. This is very unfortunate that there is no industry standard in the browser market. Fortunately ASP.net provides HttpBroserCapability class to determine the browser type and features supported by the browser.

The browser property of request object returns the object of HttpBrowserCapability object. This object has several properties which provide the information about the browser type, version and features supported by this.

Following C# code explains how you can use HttpBrowserCapability class to fetch browser information.

private void btnBrowserInfo_Click(object sender, System.EventArgs e)
{
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = “Browser Capabilities\n”
+ “Type = “                    + browser.Type + “\n”
+ “Name = “                    + browser.Browser + “\n”
+ “Version = “                 + browser.Version + “\n”
+ “Major Version = “           + browser.MajorVersion + “\n”
+ “Minor Version = “           + browser.MinorVersion + “\n”
+ “Platform = “                + browser.Platform + “\n”
+ “Is Beta = “                 + browser.Beta + “\n”
+ “Is Crawler = “              + browser.Crawler + “\n”
+ “Is AOL = “                  + browser.AOL + “\n”
+ “Is Win16 = “                + browser.Win16 + “\n”
+ “Is Win32 = “                + browser.Win32 + “\n”
+ “Supports Frames = “         + browser.Frames + “\n”
+ “Supports Tables = “         + browser.Tables + “\n”
+ “Supports Cookies = “        + browser.Cookies + “\n”
+ “Supports VBScript = “       + browser.VBScript + “\n”
+ “Supports JavaScript = “     +
browser.EcmaScriptVersion.ToString() + “\n”
+ “Supports Java Applets = “   + browser.JavaApplets + “\n”
+ “Supports ActiveX Controls = ” + browser.ActiveXControls
+ “\n”;
txtBrowserInfo.Text = s;
}

I have placed one button on the aspx page and named it as Browser Information. The id of the button is btnBrowserInfo. On the click event of the button, I wrote the above code.

I also placed a TextBox on the page and named it as txtBrowserInfo.

First I initialized an HttpBrowserCapability object named browser with the Request object’s browser property. I fetched the different property of browser and concatenate these into a string variable. Finally I displayed the concatenated string into the text box.

kick it on DotNetKicks.com

Next Page »

Blog at WordPress.com.