Visual studio feeds

All Visual Studio blogs in one place

Subscribe

Enter your email address:

Delivered by FeedBurner

Increase your website traffic with Attracta.com

Google+

Contact

Email:
Subject:
Message:
Anti-spam: How many eyes has a typical person?

Follow us on FB

Search

Introduce Assertion refactoring using Code contracts

AddThis Social Bookmark Button

Code Contracts provide a language-agnostic way to express coding assumptions in .NET programs by offering a number of attributes and helper classes to help formalize any assumptions you make in your code into a contract. A contract can pertain to pre-conditions, post-conditions, assumptions and “object invariants” that enable static contract verification and runtime checking of values.
The Introduce Assertion refactoring recommends making an assumption explicit with an assertion if a section of code is going to make that assumption about the state of the program. You can use code contracts to implement this refactoring in your code. In this
post, we’ll see how to refactor your code to add code contracts for assumptions.
[TestMethod]
public voidTransferDepositsRequestedAmountInTheAccountFromTheCurrentAccount()
{
    var account = new Account(300);
    var accountToTransfer = newAccount();
    account.Transfer(accountToTransfer, 150);
    Assert.AreEqual(account.GetBalance(), 150);
}

public decimal Transfer(Account account, decimalamount)
{
    _accountBalance -= amount;
    account.Deposit(amount);
    return _accountBalance;
}

The code given assumes that the client that calls the transfer method on the current account object passes a valid account object to the transfer method to do the transfer.  
We can prevent the object from being instable by adding assert assumptions as given below.
[TestMethod]
[ExpectedException(typeof(AssertFailedException))]
public voidTransferDepositsRequestedAmountInTheAccountFromTheCurrentAccount()
{
    var account = new Account(300);
    var accountToTransfer = default(Account);
    account.Transfer(accountToTransfer, 150);
    Assert.AreEqual(account.GetBalance(), 150);
}


HTML5 sessions at BDotnet UG Meet – September 1, 2012

AddThis Social Bookmark Button
BDotnet (Bangalore .NET) usergroup is organising its User Group meeting on September 1, 2012. The September 1st 2012 will see some interesting sessions on HTML5. What is BDotnet (Bangalore .NET)? BDotnet (Bangalore .NET) User Group is one of the premier .NET user group for technology enthusiasts targeting Microsoft Technologies. Excellent Sessions / seminars are delivered by various community members that includes Microsoft MVP’s, Microsoft RD’s and also volunteers The sessions that are planned on September 1st include HTML5 – A Whirlwind tour by Lohith HTML5 – What you need to know by Amar Nithyananda This UG meet is scheduled to
be held from 10:30 AM to 1:00 PM (IST) on 1st September, 2012 at Microsoft Signature Building, Bangalore Know more about the event and register here...(Read whole news on source site)

Build Single Page Apps - Part 8 - JavaScript Data Services

AddThis Social Bookmark Button
I love to write code, but that doesn’t mean I want to write the same code over and over again. And I certainly don’t want to have to hunt down all that redundant code when I want to refactor a few pieces of it. That’s why I am a huge advocate for the Single Responsibility Principle (SRP) … or in simplest terms, I prefer to make smaller sets of code that have a primary focus. In JavaScript, that means modules like the ones below. You’ll see examples of modules such as Models, a Data Service and a
Data Context in my upcoming Pluralsight course titled “Building Single Page Apps (SPA) with HTML5, ASP.NET Web API, Knockout and jQuery”. (due to go live on Pluralsight in a week!). You can catch up on the previous posts in this series here: Part 1 - The Story Begins (What is the Code Camper SPA?) Part 2 - Client Technologies Part 3 - Server Technologies (the Data Layer) Part 4 – Serving JSON with ASP.NET Web API Part 5 - HTML 5 and ASP.NET Web Optimization Part 6 - JavaScript Modules Part 7...(Read whole news on source site)

Help my Secondary Tile will not navigate correctly in my Win Phone Application

AddThis Social Bookmark Button
When you are adding the ability to have a Secondary tile to your Windows phone application you may from time to time find the need to debug or mimic the launching of the application via the Secondary tile w/ the correct query string values. Sadly, debugging this via the debugger is not something that I have found out how to do, if it is possible please let me know.  However, I have found another way to get the same result and here is how. Get the exact tile uri used for the secondary tile.
Example: “/views/events/Landing.xaml?Id=1”
Open up
the WMAppManifest.xml page under resources Find the line that looks like this:

Replace it w/ the URI of your secondary tile like this:

Launch the application If you are wired everything correctly your page should load, but if you are trying to debug this it is likely you did not have everything correct.  If you did not do things correctly you should get some sort of runtime error. Hope this helps Till next time,
...(Read whole news on source site)

Visual Studio 2012 Backwards Compatible with 2010

AddThis Social Bookmark Button
For the first time in Visual Studio history, you can open a Visual Studio 2010 project with Visual Studio 2012, save it, and open it again in Visual Studio 2010. They are backwards compatible! If you want to use the new features of the Visual Studio 2012 editor on your current solution before the other members of your team, you can. You can open it and edit it in VS 2012 and they can open it and edit it in VS 2010. I started using VS 2012 back in February 2012, even through the rest of my team
were using VS 2010.  I was able to check in/out from TFS without impacting the other members of the team using VS 2010. The only issues I ran into were: The Visual Studio 2010 Database project is not compatible with VS 2012. But VS 2012 lets you decide to NOT upgrade it. It then looks like the screen shot below. Office 2007 projects are not compatible with VS 2012. They won't open and appear similar to the database projects. I often have VS 2010 and...(Read whole news on source site)

It's Been a While

AddThis Social Bookmark Button
The news about the orphaning of Silverlight hit me like a rock. I dove head first into Silverlight/MVVM a few years ago and had begun to feel like I could bend it to my will. I was disappointed, unhappy, and just sad about this news. Pair that with a very bad case of "empty nest" syndrome (I really miss my daughters!), and I was too low to get excited about creating a blog post. A few weeks ago, I began to feel the weight of this depression ease. After having some fun with a preview of VS
2012, a European trip with my immediate family, a week in Wisconsin with my extended family, and a long week-end at Comic-Con with my oldest daughter, I was starting to feel normal again. (See the Comic-Con pictures here.) I'm glad to be back here, in the blog-sphere.
...(Read whole news on source site)

Be the Next Microsoft Employee Finale

AddThis Social Bookmark Button
Here’s a little fun … … Are you the next Microsoft employee? Here is the final episode of Be the Next Microsoft Employee, where the winner gets the grand prize -- a job at Microsoft.   It really happens too – the winner started July 30th, 2012.  Check out the finale episode of Be the Next Microsoft Employee: (Note – If the video doesn’t play for you, try watching directly on YouTube at Be the Next Microsoft Employee.) It’s a great little video.   One of the contestants even poses the question –
“To Azure? … or Not to Azure?” If you think just being technically strong is the name of the game, that’s not so. I couldn’t help but think of shtick by comedian Mitch Hedberg where he complains that to be a comedian, you have to be more than a comedian to be successful. “So you're a comedian, but can you act? … It's like asking a cook, OK, so you're a chef, but can you farm?” I liked this comment by judge, Tim DiMarco: “In addition to technical skills, your ability to...(Read whole news on source site)

Using OData in Windows 8 Apps for Windows 8 RTM

AddThis Social Bookmark Button
The following is an excerpt from Chapter 6 of my book, Building Windows 8 Apps with C# and XAML. The Open Data Procotol (OData) is a web protocol used for querying and updating data. It is a REST-based API built on top of Atom that uses JSON or XML for transporting information. Windows 8 applications have native support for OData clients once you download and install the client from: http://go.microsoft.com/fwlink/?LinkId=253653 To access OData services, you simply add a service reference the same way you would for a SOAP-based web service. A popular OData service to use
for demonstrations is the Netflix movie catalog. You can browse the service directly by typing http://odata.netflix.com/catalog/ into your browser. In most browsers you should see an XML document that contains various tags for collections you may browse. For example, the collection referred to as Titles indicates you can browse all titles using the URL, http://odata.netflix.com/catalog/Titles. The Netflix project (available from Chapter 6 in the download available at http://windows8applications.codeplex.com) shows a simple demonstration of using this OData feed. The main URL was added as a service reference the same way the weather service was added in...(Read whole news on source site)

What is Inversion of control and why we need it?

AddThis Social Bookmark Button
Most of programmer need inversion of control pattern in today’s complex real time application world. So I have decided to write a blog post about it. This blog post will explain what is Inversion of control and why we need it. We are going to take a real world example so it would be better to understand. The problem- Why we need inversion of control? Before giving definition of Inversion of control let’s take a simple real word example to see why we need inversion of control. Please have look on the following code. public class class1 {
private class2 _class2; public class1() { _class2=new class2(); } } public class class2 { //Some implementation of class2 } I have two classes “Class1” and “Class2”.  If you see the code in that I have created a instance of class2 class in the class1 class constructor. So the “class1” class is dependent on “class2”. I think that is the biggest issue in real world scenario as if we change the “class2” class then we might need to change the “class1” class also. Here...(Read whole news on source site)

Home