Tuesday, August 31, 2010

Windows Phone Developer Tools Beta (June) Install Issue

If you find that June 2010 installer for Windows Phone Developer Tools (beta) hangs while running imagegen.exe, then check to see if you have an AntiVirus application with AutoProtect features turned on. On my machine, it looked as though Norton AntiVirus’s auto-protect features was blocking imagegen.exe from completing on my machine.

Once I temporarily disabled Autoprotect, the installer ran successfully.

Make Windows load faster – Soluto

Just came across Soluto, installed it and within minutes I was able to shave off 1 minute of a 3 minute load time. Nice and easy interface and it also provides recommendations for common programs.

It just works.

soluto.com

Download Soluto from: mysoluto.com.

Update [09-01-2010] – just ran it on another Windows 7 machine. This time it shaved off 1 minute of a 2:15minute boot cycle. Awesomeness!

Monday, August 30, 2010

BloomBox from BloomEnergy–A solid state energy server

 


An interesting piece that I watched this weekend on BloomEnergy and their invention the BloomBox – a solid state energy server, that allows for electricity generation on premises.

More:

http://www.bloomenergy.com/

http://en.wikipedia.org/wiki/Bloom_Energy_Server

Sunday, August 29, 2010

RSA Animate–HomoEmpathicus

An interesting talk on how empathy has changed our perception about our environment. And how empathy is wired into our brains through mirror neurons. Finally, the animation ends on how our empathy can broaden our identity so that it “extends to think of the human race as fellow sojourners, creatures as fellow beings and the planet as our community” so that we truly can become an empathic civilization.

Words–Shibboleth

From m-w.com:

1. a : a word or saying used by adherents of a party, sect, or belief and usually regarded by others as empty of real meaning <the old shibboleths come rolling off their lips — Joseph Epstein>

1. b : a widely held belief <today this book publishing shibboleth is a myth — L. A. Wood>

1. c : truism, platitude <some truth in the shibboleth that crime does not pay — Lee Rogow>

2. a : a use of language regarded as distinctive of a particular group <accent was…a shibboleth of social class — Vivian Ducat>

2. b : a custom or usage regarded as distinguishing one group from others <for most of the well-to-do in the town, dinner was a shibboleth, its hour dividing mankind — Osbert Sitwell>

More info:

http://en.wikipedia.org/wiki/Shibboleth

Thursday, August 26, 2010

Wednesday, August 25, 2010

How many parameters is too many parameters

Maybe 49 arguments….. ?!!!

49Arguments

It was for a method that was generated using a tool against a database table with 49 fields! Anyways, thought it was way too funny!

Sunday, August 22, 2010

Rex–Regular Expression Exploration

samplesfa

Rex – is an MSR released tool that generates strings based on a regex expression. It’s a great tool for generating input for unit tests as well as output data for mocks. It is also makes it really easy to determine what that complex regex that you downloaded from the internet does or if the regex that you wrote really works or not.

One thing to know is that when you run the tool and if you see output with “\u”, then the tool is outputting unicode data. In this case, just add the /e:ASCII option to the command line to get plan text output.

Apart from the tool being a command line tool, another way you can use Rex is to actually reference it in your code (Visual Studio allows you to reference .exe file – not just .dll files). By doing this, you can use Rex to generate random strings that you can use for mocking or for unit test inputs. (AWESOME!)

Here is some sample code (C#) to generate random phone numbers:

using Rex;

RexSettings settings = new RexSettings(@"^\d{3}-\d{3}-\d{4}$");
settings.k = 10;
settings.encoding = CharacterEncoding.ASCII;
settings.seed = (int)DateTime.Now.Ticks;

var results = RexEngine.GenerateMembers(settings);
foreach (var result in results)
{
Console.WriteLine(result);
}

And here is the output for one run:

312-889-8953
999-741-0638
999-896-9342
898-795-0789
496-589-9259
897-910-1576
899-968-9169
846-098-3822
282-169-8069
883-898-2237

More Info:

Rex on MSR: http://research.microsoft.com/en-us/projects/rex/

Rex on the Web (Pex for Fun): http://www.pexforfun.com/Default.aspx?language=CSharp&sample=RegularExpressions

Pex and Moles for Visual Studio: http://research.microsoft.com/en-us/projects/pex/downloads.aspx (white-box testing tool that uses Rex)

Regular Expression Language Reference: http://msdn.microsoft.com/en-us/library/az24scfc.aspx

Friday, August 20, 2010

WCF – Gotcha! DataContracts and Field Order

If you are trying to test a WCF service and you are attempting to manually call the operation (through a tool like SoapUI), then be aware that WCF expects the in-coming data to be in the order that the Data-Contract was setup.

If you attempt to reorder the data in what seems to be logical to you, then the field that is not in order will not be serialized and will get default data.

So pay attention the XSD and if the type is defined as:

<xs:complexType name="myData">
      <xs:sequence>
         <xs:element minOccurs="0" name="EndDate" type="xs:dateTime"/>
         <xs:element minOccurs="0" name="StartDate" type="xs:dateTime"/>
      </xs:sequence>
</xs:complexType>

Don’t try and send data where you reorder the StartDate and EndDate cause if you do, then StartDate will never get its value.

Note: this is important only when you use tools such as SoapUI that allow you to manually specify the outgoing data to the web-service. Normally serializers in the client will take care of the ordering and you will not have to worry about this issue.

Thursday, August 19, 2010

Tools–Entity Framework Profiler

If you work with Entity Framework (EF) then the EF Profiler can be an indispensible tool for you.

http://efprof.com/

It provides you with a way to inspect the sql statements that are being executed by EF.

Though, its not free and is a little pricey $305. (There is a 1 month trial for it).

Tools: IcoFx–an awesome free icon editor

prevhttp://icofx.ro/

Its free and supports tons of features…. (true color + alpha – was what sold it to me).

Consuming Web-Services from WCF– Issues with IDisposable/using and a workaround

When you use WCF to consume web-services, you typically add a service reference to the web-service, which creates a client class that you use to work with the web-service. The web-service client class is created by deriving from the ClientBase class. If you take a look at ClientBase you will find that it implements IDisposable.
Now if you are familiar with IDisposable, you would think that you should be using the “using” block to ensure that the WCF client gets correctly disposed. (MSDN: using statement)
As a rule, when you use an IDisposable object, you should declare and instantiate it in a using statement. The using statement calls the Dispose method on the object in the correct way, and (when you use it as shown earlier) it also causes the object itself to go out of scope as soon as Dispose is called. Within the using block, the object is read-only and cannot be modified or reassigned. – extracted 08-18-2010.
But unfortunately, that is not true when working with WCF. (MSDN: Avoiding Problems with the Using Statement). The problem is that when dispose is called on a WCF client it can throw an exception, and that might leave the connection open. (One scenario where this can manifest itself is with a WS connection – wsHttpBinding -, where the client needs to connect to the server when it is trying to close the connection. In this case, an error can occur upon the call to Close and one might have to call Abort to ensure that the connection is closed).
According to the MSDN article, this is how one should close a WCF client connection.
try
{
...
client.Close();
}
catch (CommunicationException e)
{
...
client.Abort();
}
catch (TimeoutException e)
{
...
client.Abort();
}
catch (Exception e)
{
...
client.Abort();
throw;
}

The only problem with the above code is that if you have to do this every-time you need to call a web-service operation, it will lead to really ugly code. Further more, I like the using statement, because I can group a set of web-service operation calls and call them all together within the using statement, thereby having to open the connection and close it only once – making for more efficient code. (This can be important if you typically need to make many calls to the web-service, where if you had to open and close the connection each time – you would notice a performance degradation). And it centralizes the code for consuming web-services correctly.
So here is my implementation. It’s a class the implements IDisposable and correctly implements the Dispose method – so that it does not throw an exception at the end of the using block and it closes the connection even if an exception is thrown on a Close call (through the Abort call).
Here is the code:
using System;
using System.ServiceModel;
public class ServiceClient<TI, TClient> : IDisposable
where TI : class
where TClient : ClientBase<TI>, TI, new()
{
private TClient _client;
private bool _objectHasBeenDisposed = false;

/// <summary>
/// 
/// </summary>
/// <param name="tclient">WCF Proxy Client</param>
public ServiceClient(TClient tclient)
{
_client = tclient;
}
/// <summary>
///Provides access to the underlying connection object
/// </summary>
protected TI Client
{
get
{
return _client;
}
}

/// <summary>
///
/// </summary>
/// <typeparam name="TIn"></typeparam>
/// <param name="action"></param>
/// <param name="argument"></param>
protected void Invoke<TIn>(Action<TIn> action, TIn argument)
{
bool callWasSuccessful = false;
try
{
action(argument);
callWasSuccessful = true;
}
catch (CommunicationException)
{
CloseConnection(true);
}
catch (TimeoutException)
{
CloseConnection(true);
}
finally
{
//shutdown the connection in case of an error.
//also by disposing it - subsequent calls on this object will also fails
if (!callWasSuccessful)
CloseConnection(true);
}
}

/// <summary>
/// 
/// </summary>
/// <typeparam name="TIn"></typeparam>
/// <typeparam name="TResult"></typeparam>
/// <param name="func"></param>
/// <param name="argument"></param>
/// <returns></returns>
protected TResult Invoke<TIn, TResult>(Func<TIn, TResult> func, TIn argument)
{
TResult returnVal = default(TResult);
bool callWasSuccessful = false;
try
{
returnVal = func(argument);
callWasSuccessful = true;
}
catch (CommunicationException)
{
}
catch (TimeoutException)
{
}
finally
{
//shutdown the connection in case of an error.
//also by disposing it - subsequent calls on this object will also fails
if (!callWasSuccessful)
CloseConnection(true);
}
return returnVal;
}

/// <summary>
/// 
/// </summary>
/// <typeparam name="TIn1"></typeparam>
/// <typeparam name="TIn2"></typeparam>
/// <typeparam name="TResult"></typeparam>
/// <param name="func"></param>
/// <param name="argument1"></param>
/// <param name="argument2"></param>
/// <returns></returns>
protected TResult Invoke<TIn1, TIn2, TResult>(Func<TIn1, TIn2, TResult> func, TIn1 argument1, TIn2 argument2)
{
TResult returnVal = default(TResult);
bool callWasSuccessful = false;
try
{
returnVal = func(argument1, argument2);
callWasSuccessful = true;
}
catch (CommunicationException)
{
}
catch (TimeoutException)
{
}
finally
{
//shutdown the connection in case of an error.
//also by disposing it - subsequent calls on this object will also fails
if (!callWasSuccessful)
CloseConnection(true);
}
return returnVal;
}

/// <summary>
///
/// </summary>
public void Close()
{
CloseConnection(false);
}


#region private members
protected void CloseConnection(bool disposeObject)
{
if (_objectHasBeenDisposed) return;

if (disposeObject)
_objectHasBeenDisposed = true;

try
{
if (_client != null)
{
if (_client.State != CommunicationState.Faulted)
_client.Close();
else
_client.Abort();
}
}
catch (CommunicationException)
{

}
catch (TimeoutException)
{

}
catch (Exception)
{
throw;
}
finally
{
if (_client != null)
_client.Abort();
}

_client = null;
}
#endregion
#region IDisposable Members

/// <summary>
///
/// </summary>
public void Dispose()
{
try
{
CloseConnection(true);
_objectHasBeenDisposed = true;
}
catch  //Dispose should swallow all errors.
{
}

}

#endregion
}

And here is how you use the class. (Assuming the web-service client implementation class is called “CalculatorClient” and the interface class that it implements is called “ICalculator”)
public class myClient : ServiceClient<ICalculator, CalculatorClient>
{
public static void Demonstrate()
{
using (myClient client = new myClient())
{
// Demonstrate a successful client call.
Console.WriteLine("Calling client.Add(4.0, 5.0);");
double addValue = client.Invoke<double, double, double>(client.Client.Add, 4.0, 5.0);
Console.WriteLine("client.Add(4.0, 5.0); returned {0}", addValue);
}
}
}

Here is what you need to observe:
1. The Invoke method is overloaded to call different types of methods with different number of arguments (0,1 and 2). If you need more arguments – then overload it with other Func types.
2. The invoke method uses the correct pattern to call the WCF operation and hence makes sure that the connection is cleaned up correctly even if an exception occurs.
3. To test the above code here is what you need to do:
- Create a wcf web-service with an interface called ICalculator with a method “double Add(double d1, double d2)”.
- make the wcf web-service use a wsHttpBinding. (connection problems are not easy to recreate with basicHttpBinding).
- in the Add method call the following method: “OperationContext.Current.Channel.Abort();” – this will cause a fault when the Add method is called from the client.
- inside the using block shown above, throw an exception right before the end of the using block. a try catch block should catch the exception outside the using block. (code is shown below).
try
{
// Create a new client.
using (myClient client = new myClient())
{
Console.WriteLine("Calling client.Add(3.0, 2.0);");
double d = client.Invoke<double, double, double>(client.Client.Add, 3.0, 2.0);
Console.WriteLine(d);
throw new OperationCanceledException("Normally if there was an exception when you call Add, this exception will be swallowed by the end of the using statement");
}
}
catch (OperationCanceledException operationCanceledException)
{
Console.WriteLine(operationCanceledException);
Console.WriteLine(operationCanceledException.Message);
}

Tuesday, August 17, 2010

Google Search–Cheat Sheet

http://www.google.com/help/cheatsheet.html

site:
Search only one website
example: admission site:www.stanford.edu
(Search Stanford Univ. site for admissions info.)

[#][#]
Search within a
range of numbers
example: DVD player $100..150
(Search for DVD players between $100 and $150)

link:
linked pages
example: link:www.stanford.edu
(Find pages that link to the Stanford University website.)

info:
Info about a page
example: info:www.stanford.edu
(Find information about the Stanford University website.)

related:
Related pages
example: related:www.stanford.edu
(Find websites related to the Stanford University website.)

+sock
Only the word sock, and not the plural or any tenses or synonyms

~auto loan
loan info for both the word auto and its synonyms: truck, car, etc.

define:computer
definitions of the word computer from around the Web.

red * blue
the words red and blue separated by one or more words.

Monday, August 16, 2010

Microsoft Biology Foundation

via http://mbf.codeplex.com/:

The Microsoft Biology Foundation (MBF) is a language-neutral bioinformatics toolkit built as an extension to the Microsoft .NET Framework, initially aimed at the area of Genomics research. Currently, it implements a range of parsers for common bioinformatics file formats; a range of algorithms for manipulating DNA, RNA, and protein sequences; and a set of connectors to biological web services such as NCBI BLAST. MBF is available under an open source license, and executables, source code, demo applications, and documentation are freely downloadable.
The source code and development of MBF is managed on this CodePlex site, but all downloads are hosted on the Microsoft Research site here:http://research.microsoft.com/bio/.

via http://research.microsoft.com/en-us/projects/bio/:

Tools available:

  • Microsoft Biology Foundation
  • The Microsoft Biology Foundation (MBF) is a language-neutral bioinformatics tool kit built as an extension to the Microsoft .NET Framework. It implements a range of parsers for common bioinformatics file formats; a range of algorithms for manipulating DNA, RNA, and protein sequences; and a set of connectors to biological web services such as the U.S. National Center for Biotechnology Information’s Basic Local Alignment Search Tool. MBF is available under an open-source license, and executables, source code, demo applications, and documentation are freely downloadable.
  • ShoRuntime for MBF
  • a library that delivers advanced math and graphing capabilities on the .NET platform
  • Microsoft Biology Tools
    • Microsoft Research Biology Extension for Excel
    • Add-in that provides a simple, flexible way to work with genomic sequences, metadata, and interval data in an Excel workbook by exposing the features and functions of the Microsoft Biology Foundation.
    • Microsoft Research Sequence Assembler
    • Sequence Assembler is a proof-of-concept-application that demonstrates the use of the Microsoft Biology Foundation, the .NET Framework, the Windows Presentation Foundation, and Microsoft Silverlight for bioinformatics research. The MBF Sequence Assembler uses rich user interface elements to enable the visualization and manipulation of genomic data.

Xconomy - Microsoft Builds Open-Source Tool for Biologists Drowning in Data, an ‘On-Ramp’ for Customers Who Pay

Video tutorial given at the Microsoft eScience Workshop in 2009 at Carnegie-Mellon University: http://research.microsoft.com/en-us/um/redmond/events/escience2009/17961/lecture.htm. This tutorial is based on an early version of the code, but gives a good introduction and high-level overveiw of the architecture.

Ads–At&T BlackBerry


The song is Everyday by Buddy Holly.

Saturday, August 14, 2010

ASP.Net–Persistence options–A Review

ASP.Net provides 5 locations to store your application data:

  1. Application
  2. Session
  3. ViewState
  4. Cache
  5. Context

Session and ViewState get used quite a bit by Asp.Net developers. Application and Cache probably get used the next most often and Context is probably the least used by developers. Here is a quick review and basic of these in app storage mechanisms.

Important: there are other storage mechanism also available for your consideration, like: Cookies, QueryStrings, HiddenFields, etc. These are all storage mechanisms available to all web-applications. I am discussing only Asp.net specific options here. Also on the server side – there is the option to store data to databases, etc. Again – this post discusses mechanism for storing short lived data – data that isnt required across application life-times.

Application:

Scope: Available across all sessions, i.e., to the entire application (caveat: it is available to all sessions running on the same server).

Lifetime: Application. Data is lost when the application shuts down.

Considerations: When inserting data – you must do so in a thread safe manner.

MSDN: http://msdn.microsoft.com/en-us/library/ms178594.aspx

Session:

Scope: Available to only the current user session

Lifetime: Session. When the session expires the data is lost. Important to realize that InProc session-state is available only on the server that processed the request. Other types available that persist data to a database or xml, that allow the session state data to be available across servers.

Considerations: Need to be aware of memory load your session data might be putting on your web-server. If sessions are long running and data is large – you potentially run the risk of your application running out of memory.

MSDN: http://msdn.microsoft.com/en-us/library/ms178581.aspx

ViewState:

Scope: Available to only the current user

Lifetime: Page. Provides a mechanism to store information to the page – so that the data is available across multiple requests to the same page.

Considerations: The other options discussed on this page are all server side options. ViewState is a client-side data storage option. Important to be aware that storing data to the view state will increase the size of the page that is sent to the user’s browser (as its stored in a hidden-field on the page). This will lead to longer trip times (server to client and client to server). As data is sent to the user – security is a consideration: data could be viewed by user or could be modified. View State can be encrypted and validated to work around these issues. Never use View State to store anything that should not be viewed by the end-user, even if you are using encryption and validation.

MSDN: http://msdn.microsoft.com/en-us/library/system.web.ui.control.viewstate.aspx

Cache:

Scope: Available to the entire application, i.e., across all sessions

Lifetime: Volatile and non-deterministic. Data removed according to expiration policies set when adding data to Cache or when .Net determines memory is running low for that application.

Considerations: Never assume data that was saved to the cache will be available later. Always check for null value. Cache stores data using weak references – allowing it to discard the data when expiration occurs or when memory loads dictate it.

I love the cache – because it takes on the responsibility of handling timers and when to discard data stored within it. I typically use the session key appended to the key name to store session specific data to the cache – taking advantage of the Cache’s cleanup capabilities. (If you do go down this route, it is important to make use of Session_OnStart and Session_OnEnd events to clean up the cache – so that data is not inadvertently shared between users when session ids are reused). Another option is to use a “UserId” from your database (if you have one), to store user specific data to the Cache – this way you do not have to worry about problems arising from reuse of SessionIds.

Also, a little known fact is that even though the Cache object is found in the System.Web namespace, the Cache object is available for you to use even in your WebForms applications.

MSDN: http://msdn.microsoft.com/en-us/library/system.web.caching.cache.aspx

References:

Asp.Net State Management Options: http://msdn.microsoft.com/en-us/library/z1hkazw7.aspx

Thursday, August 12, 2010

A simple scheme for checking for JavaScript in a browser

Do you need a simple way for detecting if JavaScript is enabled in the browser and to notify the user that JavaScript is disabled.

Here is a simple method that I came across:

It uses JQuery and CSS. The idea is to have a JSMessage div with static text that specifies that Javascript is disabled in the browser. You then use Jquery to hide the div. If Javascript is enabled the message goes away, otherwise the message is seen by the user. The CSS helps in displaying the message prominently to the user.

Below is a screen shot of the site in IE:

image

Here is the source code:

HTML, using GeSHi 1.0.8.8
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
    <title>JavaScript Browser Test Sample</title>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js"></script>
        <style type="text/css">
                #jsMessageContainer
                {
                        text-align: center;
                        width: 100%;
                        z-index: 100;
                        position: absolute;
                        margin-top: 45px;
                }
                #jsMessage
                {
                        padding: 10px;
                        background-color: #FFFFE1;
                        width: 400px;
                        border: solid 3px #CCCCCC;
                        top: 20px;
                        margin: auto;
                        text-align: left;
                }
                #jsMessage .exclamation
                {
                        float: left;
                        margin: 10px;
                }
        </style>
</head>
<body>
    <div id="jsMessageContainer">
        <div id="jsMessage">
            <p>
                <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/f0/Error.svg/497px-Error.svg.png" width="50px" class="exclamation" />
                JavaScript is required for running this website.
                                Instructions for fixing it........
            </p>
        </div>
    </div>
    <script type="text/javascript">
        $("#jsMessageContainer").hide();
    </script>
</body>
<h1>Hello World</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tincidunt lacus odio, at commodo neque. Aliquam ac felis magna, et placerat dui. Fusce fermentum, diam et congue rhoncus, ligula erat hendrerit magna, vel molestie augue velit vel ipsum. Mauris in erat mauris. Maecenas semper, sapien quis pretium ullamcorper, felis est posuere sapien, volutpat imperdiet enim magna at tortor. Praesent a nisi enim. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam varius varius libero sit amet dapibus. Cras sed purus id sem bibendum accumsan. Mauris aliquam hendrerit aliquam. Mauris adipiscing congue nulla id pellentesque. Cras feugiat placerat quam, sed commodo lacus fringilla nec. Cras tempus lorem ut massa consequat accumsan. Suspendisse id urna nibh. Fusce mauris quam, imperdiet nec bibendum a, euismod at eros. Quisque accumsan orci vel eros bibendum id sollicitudin turpis adipiscing.
<html>

Visual Studio 2010 and .NET Framework 4 Training Kit

http://www.microsoft.com/downloads/details.aspx?FamilyID=752CB725-969B-4732-A383-ED5740F02E93&displaylang=en

Learn about:

  • C# 4
  • Visual Basic 10
  • F#
  • Parallel Extensions
  • Windows Communication Foundation
  • Windows Workflow
  • Windows Presentation Foundation
  • ASP.NET 4
  • Windows 7
  • Entity Framework
  • ADO.NET Data Services
  • Managed Extensibility Framework
  • Visual Studio Team System

Channel 9: http://channel9.msdn.com/learn/courses/VS2010/

Setting up database enteries for Asp.Net membership in shared hosting scenarios

A good blog post on setting up a Sql-Server database in a shared hosting scenario so that you can use Asp.Net membership: http://misfitgeek.com/blog/aspnet/adding-asp-net-membership-to-your-own-database/

Wednesday, August 11, 2010

WCF 4–New Feature–Default Configuration

Until recently I had worked only with WCF upto version 3.5. So recently when I came across a configuration file which only had this information in it, I was perplexed to say the very least:

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>


What was missing from the web.config file were the endpoint and behavior definitions. But the service worked correctly. Very perplexing indeed.

And then I found out that in WCF4, the .Net team added a new feature called default configuration. The goal of default configuration was to make it easy to create a basic web-service (as easy as it was to create a web-service using the ASMX file – a .Net 2.0). Which is why the above configuration section doesn’t have any settings for endpoints or behaviors – they are being setup by default configuration.

For more information about Default Configuration read:

MSDN: A Developer's Introduction to Windows Communication Foundation 4

Code-Magazine: New Features in WCF 4 that Will Instantly Make You More Productive

Sunday, August 08, 2010

JustCode free offer for MSDN subscribers

Telerik is offering its code refactoring tool “JustCode” for free to MSDN subscriber for the next 3 months (August 1st, 2010 to October 31st, 2010).

http://www.telerik.com/community/promos/msdn-justcode.aspx

I have been using ReSharper 4.5 for a while now and have been pretty happy with it. On my newest machine with 4gb of RAM it works fast and I never felt like it slowed Visual Studio down for me. But ReSharper 4.5 works only with Visual Studio 2008 and my next project is going to be using Visual Studio 2010, so I might just get a chance to work with JustCode and see how well it works and with a free license, the entire team can be using it.

Friday, August 06, 2010

WCF Best Practices–Versioning

Operations

Adding new operations is a non-breaking change.

Removing an operation is a breaking change.

Adding, changing or removing a parameter for an operation is a breaking change.

Extending contracts: A good practice is to use inheritance on your interface to extend it and add new operations. You setup the service to use the new inherited interface. This allows old clients to continue using the service and new clients to use operations available in the inherited interface.

Data-Contracts

The schema WCF produces for data contract types makes no provisions for versioning.

It is generally a good idea to consider your data-contracts as immutable once they are published.

Though, adding a new member to the data-contract is considered a non-breaking change.

Removing a member from the data-contract is considered a breaking change only if strict schema validation is desired. (This is the recommended way of looking at data-contracts)

Changing the type or name is considered a breaking change.

Changing the name or namespace of a data-contract is a breaking change.

Changing the IsRequired field from false to true is a breaking change.

Enumerations

Adding or removing an enumeration member is considered a breaking change.

Changing the name of an enumeration member is breaking change (unless you use the “EnumMemberAtttribute” attribute).

Data-Contract Equivalence

For data contracts to be equivalent, they must have the same namespace and name. Additionally, each data member on one side must have an equivalent data member on the other side. In addition, data members must have the same name on both side and they must represent the same type of data (data contracts must be equivalent).

 

 

Other best practices:

Specify {Name, Namespace, and Action}

By default, the name of a service contract is the name of the interface. The default namespace is http://tempuri.org and each operation’s action is "http://tempuri.org/contractname/methodname".

The best practice is to explicitly specify the name, the namespace for the service contract, and the action for each operation. (This avoids using "http://tempuri.org" and prevent interface and method names from being exposed in the service’s contract).

[DataContract(Name = "MyData",
Namespace = “http://www.aggregatedIntelligence.com/WCF/2010/06/MyService”)]
public class MyDataClass
{ [DataMember(Name=”FirstName”)] public string FirstName{...} }

The above definition will allow you to change the name of the class or the FirstName property and not cause any issues to client consumers as the Name and DataMember have been fixed by the attributes.

References:
Service Versioning: http://msdn.microsoft.com/en-us/library/ms731060.aspx
Data-Contract Versioning: http://msdn.microsoft.com/en-us/library/ms731138.aspx
Data-Contract Equivalence: http://msdn.microsoft.com/en-us/library/ms734767.aspx
Best Practices – Data Contract Versioning: http://msdn.microsoft.com/en-us/library/ms733832.aspx
Data-Contract Names: http://msdn.microsoft.com/en-us/library/ms731045.aspx
Types supported by the DataContractSerializer: http://msdn.microsoft.com/en-us/library/ms731923.aspx
Collection types in Data Contracts: http://msdn.microsoft.com/en-us/library/aa347850.aspx

Thursday, August 05, 2010

Ten tech-enabled business trends to watch

via McKinsey Quaterly.com

  • Trend 1: Distributed cocreation moves into the mainstream
    • Trend 2: Making the network the organization
      • Trend 3: Collaboration at scale
        • Trend 4: The growing ‘Internet of Things’
          • Trend 5: Experimentation and big data
            • Trend 6: Wiring for a sustainable world
              • Trend 7: Imagining anything as a service
                • Trend 8: The age of the multisided business model
                  • Trend 9: Innovating from the bottom of the pyramid
                    • Trend 10: Producing public good on the grid

                    Read more at: http://www.mckinseyquarterly.com/High_Tech/Strategy_Analysis/Clouds_big_data_and_smart_assets_Ten_tech-enabled_business_trends_to_watch_2647?gp=1

                    Wednesday, August 04, 2010

                    Advice for common mistakes that startups make

                    From BigThink.com: Advice from BaseCamp founder Jason Fried.

                    http://bigthink.com/ideas/21552

                    How-To: Turn off ReSharper hint to use “var” when possible

                    In my opinion it is the most annoying hint that ReSharper puts me through and the first thing I try to figure out how to turn off once I install it. (Especially when you start using ReSharper on an existing project – this error will start popping up all over the place).

                    To turn it off: Go to ReSharper ==> Options ==> Node “Inspection Severity” under Code Inspection and setup as shown below.

                    Resharper-TurnOffVar

                    Sunday, August 01, 2010

                    Windows Workflow, VS 2010 and the Toolbox

                    imageIs your toolbox for Windows Workflow broken in VS 2010? (Toolbox does not show the categories, or the items within them or the toolbox items are all disabled).

                    First make sure you have a workflow document open.

                    If that simple mistake didn’t fix your issue, then close Visual studio and browse to the following folder:

                    %USERPROFILE%\Local Settings\Application Data\Microsoft\VisualStudio\10.0

                    Delete the files with extension “.TBD” in this folder. (These files are hidden and if you cant see them you will need to turn on the ability to view hidden files in Windows Explorer). Restart VisualStudio and your toolbox will be rebuilt after which you should have your WF toolbox items available (at least this did it for me).

                    Choosing a Democratic candidate for the Aug 2010 Primaries–Issues

                    Here are links to where each candidate stands on different issues:

                    Michael Bennet: http://bennetforcolorado.com/issues/
                    Andrew Romanoff: http://www.andrewromanoff.com/pages/issues

                    The Voter Guide (A Denver Post site) is a good resource for comparing candidates: http://www.thevoterguide.org/v/denver10/index.do.
                    Below is a comparision that I retrieved from that site on August 1st, 2010. The VoterGuide site is very comprehensive and I suggest that you visit it to get up-to date information as well as more information on these candidates as well as other races.

                    Comparison of Michael Bennet and Andrew Romanoff

                    With the expected deficit this year at $1.3 trillion -- and the total debt at $12 trillion -- what would you cut out of the federal deficit besides earmarks, which compose only $15.9 billion of $1.4 trillion in discretionary spending? And what would be your expected savings from those cuts?

                    1. Michael Bennet: I have already been a leader on several measures that would save hundreds of billions in discretionary spending, including: • A non-partisan debt commission that will put all spending on the table, and make cuts as necessary to secure a sound fiscal future. • Caps to discretionary spending and a limit on the size of the deficit. • A requirement that Congress pay for what it spends. • A requirement that unused TARP funds go toward deficit reduction. • Eliminating wasteful spending.
                      Andrew Romanoff: We should subject every part of the federal budget to the same scrutiny we apply in Colorado. We can reduce medical expenses and improve outcomes by increasing the use of health information technology and shifting from a fee-for-service model to a value-based formula. Restructuring the delivery of health care could save billions of dollars per year. Before we send troops into harm’s way, we should provide them with a well-defined mission, a clear exit strategy, and the resources to succeed.

                    2. If the economy continues to falter, I would support additional stimulus spending on infrastructure in order to preserve jobs.

                      Michael Bennet: Supports
                      Andrew Romanoff: Supports

                    3. What, if anything, can Congress do to address unemployment?

                      Michael Bennet: We should pass extended unemployment insurance for Coloradans who can’t find work. We must also pursue policies that encourage small business growth and the expansion of industries that will create jobs. I am leading efforts to cut taxes and increase lending for Colorado’s small businesses. I also support long term tax incentives for the development of renewable energy. Colorado’s is uniquely positioned to lead the country in job growth and I support making sure we fulfill that potential.
                      Andrew Romanoff: Ease access to credit and capital, especially for small businesses. End tax breaks for companies that ship jobs overseas. Rebuild our infrastructure. Negotiate and enforce trade agreements that provide a level playing field, instead of forcing American workers and manufacturers to be undercut by countries that violate human rights, degrade the environment, manipulate their currency or close their markets to our goods and services. Provide opportunities for lifelong learning and job training.

                    4. Do you support elimination of entire federal agencies or departments as part of budget balancing?

                      Michael Bennet: Opposes
                      Andrew Romanoff: The candidate chose not to mark a box

                    5. If you answered yes to the question above, which departments would you eliminate, what are the expected savings, and how would those responsibilities be handled?

                      Michael Bennet: NA
                      Andrew Romanoff: For most families, balancing the budget is a matter of common sense. In our state government, it’s also a constitutional requirement. The legislature I led fulfilled that obligation every year. To make revenues and expenditures match, we should be willing to evaluate every function of the federal government. Programs or agencies that no longer serve the purposes for which they were established should be reformed or eliminated; departments that can be consolidated should be.

                    6. Health care reform legislation should be repealed.

                      Michael Bennet: Opposes
                      Andrew Romanoff: Opposes

                    7. How would you shrink or expand the health reform act as passed in order to improve it? What additional steps, if any, would you like to see Congress take to address the issue?

                      Michael Bennet: Two provisions to reduce costs that I fought for during the debate over health care reform remain worthy of passage. First, I introduced a failsafe amendment during the debate that would have required Congress to make changes to the health care law if it failed to meet its cost saving projections. Second, I fought hard for the inclusion of a public option in the legislation to expand patient choice, and to help hold insurance companies accountable for providing affordable, quality coverage.
                      Andrew Romanoff: I will fight to add a public option; remove the insurance industry’s antitrust exemption; and address the forces that are driving up health care costs. To bring down costs, improve outcomes and reduce medical errors, I believe we should: • shift from fee-for-service to a reimbursement formula that rewards quality of care; • expand the use of health information technology; and • increase access to prevention and early intervention programs. I also support a universal not-for-profit model.

                    8. The Social Security retirement age should be increased as one part of ensuring solvency for the program.

                      Michael Bennet: Opposes
                      Andrew Romanoff: The candidate chose not to mark a box

                    9. The Social Security tax should be expanded above the current ceiling of $106,800 income.

                      Michael Bennet: Opposes
                      Andrew Romanoff: The candidate chose not to mark a box

                    10. Congress should pass the Employee Free Choice Act.

                      Michael Bennet: The candidate chose not to mark a box
                      Andrew Romanoff: Supports

                    11. If you disagree with the previous question, please specify which sections you do not support.

                      Michael Bennet: There currently is no EFCA bill before the Senate and I am frustrated by the complete win-loss mentality on this issue coming from business and labor groups. Our goal should be to create a course that is more positive for both sides and that: (a) allows our economy to grow; (b) rectifies the past failures to enforce the NLRA, and; (c) protects workers from intimidation and protects the ability of workers to bargain collectively.
                      Andrew Romanoff: I believe the change regarding an employer’s ability to call an election would not be necessary if the election period were shortened and the other provisions of EFCA were adopted.

                    12. Global warming is occurring, is largely from human causes and will have wide-ranging negative impacts on the U.S. climate.

                      Michael Bennet: Supports
                      Andrew Romanoff: Supports

                    13. A new energy bill should combat global warming through ideas like “cap and trade” pollution limits or a tax on all carbon-based fuels.

                      Michael Bennet: Supports
                      Andrew Romanoff: Supports

                    14. Federal wilderness areas in Colorado should not be expanded along the lines of what is included in the “Hidden Gems” proposal.

                      Michael Bennet: Opposes
                      Andrew Romanoff: Opposes

                    15. I support a national Renewable Energy Standard.

                      Michael Bennet: Supports
                      Andrew Romanoff: Supports

                    16. The president's proposal to begin troop withdrawals from Afghanistan by July 2011 is realistic.

                      Michael Bennet: Supports
                      Andrew Romanoff: Supports

                    17. The 1996 federal Defense of Marriage Act, which defined marriage as between one man and one woman, should be not be overturned.

                      Michael Bennet: Opposes
                      Andrew Romanoff: Opposes

                    18. The military should keep its "Don't ask Don't Tell" policy in place.

                      Michael Bennet: Opposes
                      Andrew Romanoff: Opposes

                    19. Immigration reform legislation should include a “path to citizenship” for illegal immigrants currently residing in the United States so long as the pass criminal background checks and pay back taxes.

                      Michael Bennet: Supports
                      Andrew Romanoff: Supports

                    20. As part of immigraiton reform, all illegal immigrants should be required to leave the U.S. and apply for legal entry.

                      Michael Bennet: Opposes
                      Andrew Romanoff: Opposes

                    21. President Barack Obama was born in the United States.

                      Michael Bennet: Supports
                      Andrew Romanoff: Supports

                    22. If you would like to post a video response to the question, "What are the chief differences between you and your primary opponent?" You may do so here.

                      Michael Bennet: Candidate response is not yet available.
                      Andrew Romanoff:

                    23. Would you support mandatory cuts to discretionary spending, and at what level? Should defense spending be cut?

                      Michael Bennet: Yes. As I mentioned above, I introduced legislation to cap the deficit at 3% of GDP and that contains mandatory limits on discretionary spending. I have also repeatedly voted to cap discretionary spending.
                      Andrew Romanoff: I support performance- or outcome-based budgeting. As speaker of the House, I directed our budget committee to set measurable goals for state government and hold agencies accountable for meeting them. The federal government should follow the same path. I support a strong national defense. That means modernizing our weapons systems, preparing our troops to address new threats, and improving cybersecurity. It does not mean funding projects the Pentagon neither needs nor requests.

                    24. Other than faith, family and friends, name three things you couldn't live without?

                      Michael Bennet: Spicy beef jerky, books and humor.
                      Andrew Romanoff: My dog, Colorado’s sunshine, and a sense of humor.

                    25. Complete this sentence. Most people are surprised to find out that I ...

                      Michael Bennet: love to build and repair things and have a woodworking shop in my garage.
                      Andrew Romanoff: am old enough to vote.

                    Other sites:
                    VoteSmart
                    : http://www.votesmart.org/election_congress_state.php?state_id=CO