{ Blog }

Adventure with Application Development

  • 3 reasons why I love ReSharper

    Tags: Visual Studio, ReSharper

    ReSharper is a renowned productivity tool developed by JetBrains that makes Microsoft Visual Studio a much better IDE. It   brings smart C# code analysis, editing, highlighting and refactoring features to .NET developers. ReSharper extends much of its support to VB.NET, build scripts, ASP.NET, XML, and XAML files. All features are available in mixed solutions where different projects use .NET Framework, .NET Compact Framework, Silverlight, as well as other frameworks and tools from the Visual Studio ecosystem.
     
    I have hardly ever used an add-on with Visual Studio while using it more than decade or so. I never felt an urge to use one and always believed that Visual Studio is one of the best IDE present in the market, in fact it is. Fortunately or unfortunately, our team decided to throw away the (outdated and self-proclaimed) coding standard we were using. This led to a search to find a better tool which can help us a team in doing so. ReSharper came as one of the top search result in Google. Not sure because of relevance or as a sponsored result, but that’s a different story.
     
    Having said so, I have been using this add-on (trail version) for almost three weeks now and simply cannot believe how I managed to do without. It is certainly addictive. Apart from all the features JetBrains has listed on their website, here are 5 reasons why I love ReSharper:

    • Conventions: One of the most striking and handy feature. As a developer, I don’t really have to bother and remember the naming conventions. ReSharper helps me and signals any deviation as I type my code. This means, no longer I have to create lengthy documents and indoctrinate new programmers about the conventions we use as a team.
      A definite PLUS while doing code reviews. All those deviations should have already been taken care of by the developer himself and if not it will just strike through immediately while you are at it.
    • Code Editing Helpers: Another magical feature. I had this project where someone had written a NICE nested foreach loop. I noticed that ReSharper had few suggestions to it. It suggested that a better Linq statement can be used instead of loop. And not only has it suggested, it does it for you. Pretty handy as feature even if you want to learn new, better ways and syntax to write code.
    • Code Smells:  This is how they market the feature. But it really works. ReSharper can tell you if there is a possible NULL reference exception. Very handy when you have a lot of junior developers working on the team. This is one of those scenarios which is most likely to happen if the developer has made an assumption on his own.

    Apart from that here are my general observations:

    Good:

    Suggests good coding practices as we type
    Good refactoring support
    Supports xml files also for refactoring
     
    Bad:
    Seems to take a lot of resources
     
    Features personally liked:
    greys out unused using statements and variables in the editor
    suggestions to convert string literals to constants when used with hard coded values
    suggests naming conventions for namespaces, variables etc.
    suggestions to change the scope of variables to inner most code block
    suggestion to use object initializers
    suggestions for possible exceptions in code
    and a lot more

  • CodeProject Most Valuable Professional for 2013

    Tags: CodeProject, MVP

    After a painful start and a root canal treatment already in the first week of the year, something fruitful happened. Just got an email from CodeProject that I'm being nominated for Most Valuable Professional (MVP) for 2013. Thanks to CodeProject and all the fellow community members for support and appreciation.

    A complete list of 40 CodeProject MVPs this year is available at:

    http://www.codeproject.com/script/Awards/MVPWinners.aspx

     

    From Code Project Newsletter:
    Each year we have a tradition of awarding the members who have worked the hardest, helped the most, and given their all for the community. There are two main categories: those who write articles and those who help in the forums and in Quick Answers. You, our members, vote for these articles, for their answers, you download code that's been posted, bookmark articles and "accept" an answer as the right one. Each small activity adds to the contributors points tally and at the end of the year we have a list of the brightest and the best.

  • A Google Doodle for my own birthday

    Tags: Social, Google Doodle, Birthday

    That was a big surprise this morning when I logged on to my computer. Though, I haven't set Google as my home page on Internet Explorer (Yes, I still use IE :), but as a (bad) habit directly type the google.com. There was a colleague standing next to me, and after looking at Google Doodle, I told him that it looks like some great guy also happens to be born on the same date as of mine. And by the time I hovered over the Doodle, it was really a big fat surprise, Google had customised the doodle for my own birthday with alternate text 'Happy Birthday Manas!'.

    Frankly, quite impressive.

    Hey Google, Many thanks for remembering!!! ;)

     

    P.S. : Dear facebook, twitter: Were you sleeping this morning or just not bothered about it?

  • Why you should use Visual Studio for SharePoint Development

    Tags: SharePoint, Visual Studio, Best Practices

    Microsoft has significantly improved the tools available to developers and implementers for SharePoint 2010. The two primary tools, SharePoint Designer 2010 and Visual Studio 2010, have evolved into first class power user, site owner, and developer tools that target different audiences.

    Microsoft SharePoint Designer is a specialized HTML editor and web design freeware for creating or modifying Microsoft SharePoint sites and web pages. It is a part of Microsoft SharePoint family of products.
    SharePoint Designer features focuses on designing and customizing Microsoft SharePoint websites. For instance, it includes SharePoint-specific site templates.

    Visual Studio 2010 is the primary development environment for all custom code and resource development for SharePoint 2010. Developers can also use a new project template that can rebuild a solution by importing an existing solution package (.wsp) file. Visual Studio 2010 provides a new extensibility model named the Managed Extensibility Framework (MEF), and a SharePoint 2010 project system API. Using this framework and API, developers can extend and customize Visual Studio 2010.

    Benefits of using Visual Studio

    1. Workflows created in Share point Designer can be exported and imported to visual studio but the other way around is not possible.
    2. When developing solutions for SharePoint using Visual Studio, there is nothing special if you are targeting SharePoint. All of your sources files are handled as they normally are when you are using a version control system.
    3. You can use Visual Studio to group related SharePoint elements into a Feature. Next, you can create a SharePoint solution package (.wsp) to bundle multiple features, site definitions, assemblies, and other files into a single package, which stores the files in a format needed by SharePoint to deploy the files to the server.

    References
    http://msdn.microsoft.com/en-us/library/gg512102.aspx#bk_spdevtools
    http://msdn.microsoft.com/en-us/library/ms253064.aspx
    http://msdn.microsoft.com/en-us/library/ms181368.aspx

  • Accessing C# Variables in JavaScript

    Tags: C#, ASP.Net, JavaScript

    Introduction

    So often I come across this question on various forums that 'How to access the variables/properties from C# in Javascript?'. And this is one of the scenarios which you are (most) likely to come across if you are writing an ASP.Net application.

    For most beginners, it might get confusing as they start wondering how to pass on information from a server side variable to client side.

    Solution

    The one shortcut we used to used during the (good old) ASP days, and which still works in ASP.NET is to declare a public property in codebehind. Let us say we declare a string variable firstName in codebehind.

    public string firstName = "Manas";
    public string lastName = "Bhardwaj";
    

    Now, we can access this in aspx page/javascript like this:

    <script>
        var myName;
    	function GetMyName()
        {
    		myName = <%=this.firstName%> + ' ' + <%=this.lastName%>;
    		
    		alert(myName);
        }
    </script>
    

    To do it nicely, you can use RegisterClientScriptBlock. RegisterClientScriptBlock accepts the following parameters:
    Type: The type of the client script to register.
    key: The key of the client script to register.
    script: The client script literal to register.
    addScriptTags: A Boolean value indicating whether to add script tags.

    string script = string.Format("var myName = '{0} {1}';", firstName, lastName);
    if (!ClientScript.IsClientScriptBlockRegistered("myScript"))
    {
        ClientScript.RegisterClientScriptBlock(typeof(_Default), "myScript", script, true);
    }
    

    Once done, the variable 'myName' is available at the client side (javascript in aspx page) and can be accessed like:

    <script>
        function GetMyName()
        {
    		alert(myName);
        }
    </script>