Monday, May 10, 2010

New IDE Features in Visual Studio 2010 for C# Developers

New IDE Features in Visual Studio 2010 for C# Developers: "

After a quick review of C# language features, let’s do the same for the IDE improvements. So, what’s in there for C# developers?


Generate From Usage


This feature greatly improves Visual Studio support for test-driven development (TDD). However, it is useful even if you don’t use TDD at all. It might increase your productivity by simply reducing the number of keystrokes and eliminating repetitive typing. For example, now I can write code like this:




class Program
{
    static void Main(string[] args)
    {
        var test = new SampleClass(firstParameter: 'test', secondParameter: 0);
        test.FirstProperty = 1;
        test.SampleField = 2;
        int value = test.SomeMethod(100);
    }
}

SampleClass doesn’t exist at this moment, so everything is going to be highlighted as an error. But instead of typing all the declarations, I set the cursor on the highlighted error, press CTRL + “.” and have the IDE generate code for me.


image


Visual Studio 2010 can generate classes, constructors, properties, fields, enum members, and methods (and it uses the names of optional parameters from the constructor or method calls). Just look at how much code I didn’t have to write. All this was generated by simply pressing CTRL + “.” several times.




class SampleClass
{
    private string firstParameter;
    private int secondParameter;
    public int SampleField;

    public SampleClass(string firstParameter, int secondParameter)
    {
        // TODO: Complete member initialization
        this.firstParameter = firstParameter;
        this.secondParameter = secondParameter;
    }

    public int FirstProperty { get; set; }

    internal int SomeMethod(int p)
    {
        throw new NotImplementedException();
    }
}

However, sometimes IntelliSense, which is so nice when you’re dealing with already-defined classes, may get in your way when you try this “generate from usage” approach. For example, suppose that I want to add another property to SampleClass and call it First. Since I already defined FirstProperty, IntelliSense autocompletes First to FirstProperty when I type “=”.


To avoid this problem, press CTRL+ALT+SPACEBAR to switch to IntelliSense suggestion mode (as opposed to completion mode). In suggestion mode, IntelliSense is less aggressive – it doesn’t autocomplete member names after you type an equal sign or open parenthesis or something like that. But you are still able to choose an existing member from a list if you need to complete the member name.


image


Check out Generate From Usage and List Members topics on MSDN to learn all the details about this feature.


Call Hierarchy


The new Call Hierarchy window helps you analyze your code and navigate within it. I opened one of the LINQ sample projects that come with Visual Studio. (Click Help and then Samples on the Visual Studio menu to get the list of samples.) I chose the WebServiceLinqProvider sample, since it’s a fairly big one.


Now, to open the Call Hierarchy window, I can put the cursor on any method, property, field, indexer, or constructor, no matter whether it’s a declaration or an actual call, right-click it then and click View Call Hierarchy (or press CTRL+ALT+K). Call Hierarchy is also available if you right-click a member in the Object Browser or in Class View.


image


For me, the biggest advantage of this window is that under the Call To node you can see which members call the selected member, and where those members are. This information is often hard to get and analyze, since member calls are usually scattered across the project.


In the same window, under the Calls From node, you can also see which members the selected member calls. For virtual and abstract members, you can see the overrides.


What’s cool is that you can navigate from this window to the code you want to look at in more than one way. First of all, you can see what the method call looks like in the Call Sites column. You can also see the name of the file that contains this code.


image


Second, you can double-click any method call and Visual Studio will open the method for you.


But if you want to still see the method you are analyzing, there’s third way. Open the Code Definition window and move it so you can also see the code editor and the Call Hierarchy window. (The best place would be a second monitor, and this is now easy to do with all these undockable windows, thanks to the new WPF UI.) Now if you click on a method call (instead of double-clicking), you can see the corresponding code in the Code Definition window, without losing your position in the main editor.


Don’t forget to check out the shortcut menu, which allows you to use such commands as Go To Definition, Find All References, and Add as New Root for each member.


Navigate To


Speaking of navigation improvements, the next cool IDE feature is a quick search tool for symbols. Just press CTRL + “,” (or click Edit and then Navigate To) to see the new Navigate To window. You can search for types, members, and files in this window. Camel-case search is supported as well. Everything is displayed in one result list. In the following screenshot, you can see a class, a constructor, and a file whose capital letters match my search request. And it goes without saying that you can navigate to any item with a simple double-click.


image


Reference Highlighting


This is one of those subtle features that just make things better. If you put the cursor on a symbol (method, property, variable, etc.), all instances of this symbol are automatically highlighted in the code editor. You can also navigate from one instance to another within a file by pressing CTRL+SHIFT+UP/DOWN ARROW. How to: Use Reference Highlighting on MSDN describes how you can configure the highlighting color and turn on/off the feature (it’s turned on by default).


image


Box Selection and Multiline Editing


Suppose that you want to change several fields in your class from public to private. And you have a couple dozen of those. Now you change the declaration by typing public just once. Press ALT and then use your mouse or arrow keys to select the box area (in my case, the column that contains the private keywords).


image


Now simply type the new text and it will be repeated on each line. Check out this nice video from the Visual Studio Editor team, which shows more scenarios where this feature may come in handy (adding comments, writing repetitive code, etc.).


Docking Windows and Zoom


I already mentioned that moving Visual Studio to WPF helped to improve multiple-monitor support. In fact, you can undock any window and rearrange everything according to your needs. Dock windows to the edges of the main window, or simply leave them in the middle of the screen if you want.


Another useful feature enabled by WPF is zooming. Press CTRL and use your mouse wheel to enlarge or decrease your font size. The C# team does a lot of presentations, and I can tell you that it’s much easier to give (and see) a demo now.


Extension Manager


If you’re still looking for ways to improve your IDE, try one of the numerous add-ins developed by the community and other companies. In this release, Visual Studio greatly improved its SDK for add-in developers. Also new is the Extension Manager, which helps you to easily download, install, and uninstall Visual Studio extensions. You can get to it by clicking Tools and then Extension Manager.


Now you can search for add-ins online without leaving the IDE. The Extension Manager checks for add-ins and their updates at Visual Studio Code Gallery.


image


What Else?


No, this is not all that’s in there for you. I just mentioned the most popular features that might be useful to any C# developer, no matter what technology or API you use.


There are a lot of subtle improvements that might be hard to notice. For example, error highlighting now works in more places. Another example is IntelliSense, which now supports camel casing and filtering in all of its lists.


Also, a lot of enhancements are specific to certain technologies: Office development, WPF, Silverlight, SharePoint – just to name a few. I also didn’t mention improvements in the debugger or application lifecycle management .


Instead of providing tons of links, I’ll provide just one: Visual Studio 2010 Product Highlights. This document briefly describes major Visual Studio improvements and provides all necessary links to relevant MSDN docs.


P.S.


Special thanks to Kirill Osenkov, Alan Berman, and Mick Alberts for reviewing, editing, and providing helpful comments.

"

Tuesday, May 4, 2010

jQuery: Novice to Ninja

jQuery: Novice to Ninja: "

jQuery: Novice to Ninja is a compilation of best-practice jQuery solutions to meet the most challenging JavaScript problems. In this question-and-answer book on jQuery, you'll find a cookbook of ready-to-go solutions to help breathe life into your web page. All code used to create each solution is available for download and guaranteed to be simple, efficient and cross-browser compatible.


"

Monday, April 26, 2010

Top 10 HTML Snippets

Top 10 HTML Snippets: "

The 10 most used snippets in HTML. Very useful reference for any Web Developer.


Some of these you are probably familiar with, but some of them you just can’t always remember off the top of your head. So I deicided to make a reference place.



  1. Comments in HTML
    <!-- this is a comment in html -->


  2. Embed Flash
    <object type="application/x-shockwave-flash"
    data="the_flash_file.swf"
    width="0" height="0">
    <param name="movie" value="the_flash_file.swf" />
    <param name="quality" value="high"/>
    </object>


  3. HTML Table Markup
    <table>
    <thead>
    <tr>
    <th></th>
    <th></th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td></td>
    <td></td>
    </tr>
    </tbody>
    </table>


  4. Form HTML Elements
    <form id="form_id" action="" method="post">
    <fieldset>
    <legend>The Form</legend>
    <div>
    <label for="text_field">Text Field</label>
    <input type="text" id="text_field" name="text_field" />
    </div>
    <div>
    <label for="password_field">Password Field</label>
    <input type="password" id="password_field" name="password_field" />
    </div>
    <div>
    <label>Radio Buttons</label>
    <input type="radio" name="button" value="1" /> Button 1 <input type="radio" name="button" value="2" /> Button 2
    </div>
    <div>
    <label for="checkbox">Checkbox</label><input type="checkbox" name="checkbox" id="checkbox" value="checkme" />
    </div>
    <div>
    <label for="select_choice">Dropdown:</label>
    <select name="select_choice" id="select_choice">
    <option value="Choice 1">Choice 1</option>
    <option value="Choice 2">Choice 2</option>
    <option value="Choice 3">Choice 3</option>
    </select>
    </div>
    <div>
    <label for="textarea">Textarea:</label>
    <textarea cols="40" rows="8" name="textarea" id="textarea"></textarea>
    </div>
    </fieldset>
    </form>


  5. HTML5 Page Structure
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Your Website</title>
    </head>
    <body>
    <header>
    <nav>
    <ul>
    <li>Your menu</li>
    </ul>
    </nav>
    </header>
    <section>
    <article>
    <header>
    <h2>Article title</h2>
    <p>Posted on <time datetime="2009-09-04T16:31:24+02:00">September 4th 2009</time> by <a href="#">Writer</a> - <a href="#comments">6 comments</a></p>
    </header>
    <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
    </article>
    <article>
    <header>
    <h2>Article title</h2>
    <p>Posted on <time datetime="2009-09-04T16:31:24+02:00">September 4th 2009</time> by <a href="#">Writer</a> - <a href="#comments">6 comments</a></p>
    </header>
    <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
    </article>
    </section>
    <aside>
    <h2>About section</h2>
    <p>Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
    </aside>
    <footer>
    <p>Copyright 2009 Your name</p>
    </footer>
    </body>
    </html>


  6. Embed Code for Quicktime
    <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
    codebase="http://www.apple.com/qtactivex/qtplugin.cab"
    width="200" height="16">
    <param name="src" value="movie.mov" />
    <param name="autoplay" value="true" />
    <param name="pluginspage" value="http://www.apple.com/quicktime/download/" />
    <param name="controller" value="true" />
    <!--[if !IE]> <-->
    <object data="movie.mov" width="200" height="16" type="video/quicktime">
    <param name="pluginurl" value="http://www.apple.com/quicktime/download/" />
    <param name="controller" value="true" />
    </object>
    <!--> <![endif]-->
    </object>


  7. Embed code for Windows Media
    <object type="video/x-ms-wmv"
    data="movie.wmv"
    width="320" height="260">
    <param name="src"
    value="movie.wmv" />
    <param name="autostart" value="true" />
    <param name="controller" value="true" />
    </object>


  8. Meta RedirectThis allows you to redirect the page using meta tag. Setting content to 0 for immediate redirect.
    <meta content="5;url=http://redirectto.com/" http-equiv="refresh" />


  9. Force IE8 to render as IE7 (meta)This code will force IE8 to render your page as IE7.
    <meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible" />


  10. Open link in new window
    <a href="http://google.com" target="_blank">This link will open in new window/tab</a>



"

Wednesday, April 21, 2010

What’s Your Twitter Influence?

What’s Your Twitter Influence?: "


How do you know if all your work to build a Twitter following is paying off?  When it comes to what you’re really trying to accomplish on Twitter, the bottom line is “influence.”  In other words, do people listen to what you have to say, and do they follow your recommendations?  If the answer is yes, then you have influence.  Why does that matter?  If you have influence, you’re driving traffic.  Sometimes that traffic is to 3rd-party content, and sometimes it’s to your site – and sometime it results in making you some cash.  So the truth is, influence = money.


But how do you know your level of influence?  Well, of course you can look at how many hits you’re getting from Twitter, and you can see retweets of your posts.  That will give you some idea of whether or not you’re influencing your followers.  It’s only part of the picture though, and it’s difficult to take that information and set meaningful goals.  After all, how do you set a goal without a benchmark?  If only there was a tool you could use that would measure your Twitter influence, compare it with that of others on Twitter, and give you numbers you could use to set targets.  The good news is there are a few such tools!  Which one is right for you?  That might be a hard question to answer.  As there are wide variations in how each one works and the results you’ll see, which tool you use will come down to personal preference.  To help in making the decision, here is a rundown of the top 4 Twitter influence measurement tools:


Klout Twitter tool logoBecause Klout is integrated into some other Twitter tools, such as CoTweet, it is considered by many to be the leader in this sector.  Klout will give you a score, from 1-100, based on 25 different measurement criteria.  The score represents both the size and strength of a person’s sphere of influence on Twitter. Higher scores represent a wider and stronger sphere of influence. The size of this sphere is calculated by measuring true reach (engaged followers and friends vs. spam bots, dead accounts, etc.). Strength of influence is calculated by tracking interactions across your social graph to determine the likelihood of someone listening to or acting upon any specific message.  A nice feature of Klout is that it places you into one of four categories (Connector, Persona, Casual, or Climber) and gives you a snapshot of other people who are likely to influence you or to be influenced by you.


Klout Twitter tool screen shot



Twitalyzer Twitter tool Twitalyzer’s site claims they are the Social Media industry’s most popular, most widely used analytics application, used by over 400,000 people.  The site offers a full range of analysis tools and benchmark reports for you to set goals and track your progress.  Because they realize this can all be a little overwhelming, they’ve put together a ton of free information, including videos and a useful, often-humorous 51-page e-book, about how to use the site and what it takes to optimize your Twitter efforts.  They make no bones about saying their service is not for the casual user but for the person who is looking to use Twitter to build a business.  Bottom line, if you’re super serious about Twitter and want a tool that will look at your efforts from every possible angle and give you a huge chunk of useful information, Twitalyzer is the tool for you.


Twitalyzer Twitter tool screen shot


Tweet Level Twitter tool logoThe folks at TweetLevel are very upfront about the fact that this whole “Twitter Influence” thing is not an exact science.  In fact, on their site, they say, “This tool is still in beta. Even though we believe that it goes a great way to understand and quantify the varying importance of different people’s usage of Twitter, by no means whatsoever do we believe we have fully solved the ‘influence’ problem. What we would appreciate is your views, your feedback, advice and criticism is crucial in helping us understand social media measurement.”  That said, they do a pretty good job of breaking down your Twitter status into some useful information.  Just enter your Twitter user name, and they’ll give you a plain English report of how you’re doing in four areas: Influence, popularity, engagement, and trust.  TweetLevel also provides some good tips on how to use Twitter more effectively.


Tweet Level Twitter tool screen shot



TwitterGrader Twitter tool logoAnother cool free product of Hubspot, TwitterGrader is the most simple of the tools on this list.  You won’t get tons of analytics or in depth reports from TwitterGrader.  Instead, this site will give you a grade, from 1-100, and a rank among all Twitter users.  The thing about this tool is that it’s cool to see where you rank, but the usefulness of that information is limited.  So, check it out, but maybe use one of the other three tools to move your Twitter campaign into overdrive.


TwitterGrader Twitter tool screen shot



Again, measuring your Twitter influence isn’t an exact science, but that doesn’t mean it can be ignored, if you’re concerned about optimizing your Twitter marketing efforts.  So, start using one or more of the above tools, and you should be well on your way to improving your influence and making the most of Twitter.




"

Sunday, April 18, 2010

Free Ultra-light Calendar/Date Picker jQuery Plugin

Free Ultra-light Calendar/Date Picker jQuery Plugin: "

CalendarPicker is a free ultra-light calendar/date-picker jQuery plugin. It looks different from all the others, supports multiple languages, and allows fast movement across months and years. This approach might not suitable for every context, but I am sure someone will find it useful.

CalendarPicker enables mouse wheel to change dates; it is enabled on years, months and days bars. Calendar picker is released under MIT license.

date-picker

Requirements: jQuery Framework
Demo: http://bugsvoice.com/applications/bugsVoice/site/test…
License: MIT License

Sponsors

Pixmac: Stock Photos, Royalty Free Pictures and Images



"

Thursday, April 15, 2010

Software Tools For Programming Board Games

Software Tools For Programming Board Games: "


FlexibleRules is a set of software tools and framework intended to simplify programming board games.


It is currently under development by Fulvio Frapolli at the Dept of Informatics, University of Fribourg. It’s got a GUI, API, and all the rest of the works, and rules can even be changed during game play.

"

Visual Studio 2010 Released

Visual Studio 2010 Released: "

It's a big day at Microsoft today as Visual Studio 2010 officially releases. There's a lot going on with this release and I thought I'd do a big rollup post with lots of details and context to help you find your way to the information and downloads you're looking for.

Visual Studio 2010 and .NET 4

Download Visual Studio 2010

First, if you want it, go download Visual Studio 2010 now. If you're an MSDN Subscriber or WebSiteSpark/BizSpark member, you can download the final release now. If not, you can download a free trial or one of the free Express editions.

I'm running the free Visual Web Developer 2010 Express on my netbook. You can install ASP.NET 4, ASP.NET MVC 2, and Visual Web Developer 2010 Express really quickly with the Web Platform Installer.

There's an excellent page on MSDN that's cherry-picked and categorized the best VS2010 content, but I've included my own list below.

What's new in Visual Studio 2010 and .NET 4?

Buttloads. Here's the things I'm digging most.

Also, there's a FREE e-Book called "Moving to Visual Studio 2010" that you might want to check out. It's an excerpt of a larger book that'll be coming from MSPress later this summer. It takes a interesting approach as it has three parts, moving from VS2003, moving from VS2005, and moving from VS2008. It's clever, actually. You start in the book on the version that you're currently on. If you're not familiar with versions like VS2008, you start at the beginning. Otherwise, you jump ahead. When you're done, you're ready to move to VS2010.

MSDN and Visual Studio 2010

When a new product launches, MSDN launches with updates and new features of its own. Here's a few things the folks at MSDN have been doing to support the launch.

  • Better MSDN Search - Most people likely use a search engine to search MSDN, but if you do search from within MSDN, there are a number of new improvements. You can refine by source, saying only search blogs, or only search the library. There's also an OpenSearch provider so you can search the MSDN Library directly from within Windows itself.
    XDocument - Search Results in MSDN
    MSDN Search also includes Metadata from the results to help you find right thing. For example, if a search turns up a CodePlex project, I can see type-specific details within search results:
    MSDN Search
  • MSDN Subscriber Downloads Improvements - There's been lots of UX improvements including as-you-type filtering as well as filtering by platform (x64, etc) and language. I will very likely not need to download Quechua Windows, so now I don't need to see it.
  • MSDN Library in Lightweight and ScriptFree - You can choose between three flavors of MSDN Library, Classic (the one with the treeview on the side), Lightweight (what I use) or ScriptFree. ScriptFree is great for mobile devices, and it's lightning fast anywhere. Lightweight is the new default and I like it because it features community annotations made to the library prominently on the left side as well as a tabbed interface for code sample languages. I blogged a preview of this work last year and included some charts and graphs showing the improvements in speed worldwide.
    XmlNode Class (System.Xml) - Windows Internet Explorer
  • Integration of all VS sites - There were too many developer "centers" on MSDN and folks were getting lost. Many centers have been conflated into a clearer, more logical layout. The Visual Studio, Team System, and VS Extensibility Centers were merged into the single Visual Studio Center. There's a lot more focus on discoverability in the Visual Studio Center.
  • Video Improvements - There's thousands of How Do I? videos on MSDN and they tell me they are improving the backend, the player and the metadata around them. The player is larger now, you can share videos from MSDN on your favorite social networking site, rate them, leave comments, and explore related videos.
  • Profile Activities - User Profiles are integrated between sites and you can see your activity and points as you move through the system. For example, here's Arnie Rowland's profile. You can see his activity in the forums and galleries as well as his ranking and points as a community contributor.

Other Cool Stuff Happening Today

I'd hate to have this little nugget get buried in the deluge of VS2010 goodness.

  • Microsoft Surface Logo The Surface Toolkit for Windows Touch BETA goes out today. Check out http://www.surface.com under Technical Resources and the Surface Blog for more details. This toolkit is a set of controls and sample code that let WPF developers create cool multi-touch enabled experiences with the cool "Surfacey" controls that the only folks with Big Ass Tables have been able to use. This is exceedingly cool because it not only makes it WPF devs can make better multi-touch apps for Windows Touch PCs but it acts as a jump-start for the next version of Microsoft Surface. It will integrate with Visual Studi0 2010 and give you new project and item templates and a dozen new controls like the ScatterView and SurfaceInkCanvas. This is a cool thing, so I'll be talking about it soon, as will Pete Brown.

Lots of great stuff going on today. Have fun!



© 2010 Scott Hanselman. All rights reserved.



"