Archives
-
Strategy Pattern Using Delegates (Func)- www.Hands-On-Coding.net presentation on Dec 14, 2010
Strategy Pattern using Func
An alternative to using Strategy pattern using interfaces is Strategy Pattern using delegates.
• Create a class with all the different strategies.
public class Calculator
{
public static int Add(int num1, int num2)
{
return num1 + num2;
}
public static int Subtract(int num1, int num2)
{
return num1 - num2;
}
public static int Multiply(int num1, int num2)
{
return num1 * num2;
}
public static int Divide(int num1, int num2)
{
return num1 / num2;
}
}
• Test the code.
int a = 100;
int b = 50;
Func<int, int, int> calculate = Calculator.Add;
int sum = calculate(100, 50);
calculate = Calculator.Subtract;
int difference = calculate(100, 50);
calculate = Calculator.Multiply;
int product = calculate(100, 50);
If you are new to the syntax, Func. Func is like a delegate that in the above case takes the first two ints as input and outputs the int (third).
Another cool way of using Func is using lambda expressions.
Func<int, int, int> calculate;
calculate = (x, s) => x + s;
We could do the above in a single line itself. But what it means is changing the strategly on the fly. Func is a pretty cool feature that reduces a lot of the delegate code we had to write in .NET 2.0. Happy coding ! -
Strategy Pattern - www.Hands-On-Coding.net presentation on Dec 14, 2010
Content Missing!
-
Dallas day of dot net
We are putting together a great conference together at Microsoft Conference in Dallas. It's Dallas Day of Dot Net. Www.jointechies.com
We have 3 different tracks. Beginners' track which is more hands on, intermediate track and expert track We plan to incorporate the hottest dot net topics for discussion.
Ayende is flying in from Tel Aviv. Our speakers include 3 from Microsoft, 2 authors, 4 open source contributors, 5 MVPs, 3 architects and the list is growing. 55% of the registrants as of now are from outside the state. I will keep updating from time to time.
You can use 'ChanderDhall' as the discount code Thus is an additional discount code over the early bird discount code. All proceeds go towards a cancer patient For more information contact info@jointechies.com
Thanks to our sponsors:
Matrix's Dallas Day of dot net's main sponsors. Platinum sponsors also include Telerik and DevExpress. Caffeine sponsors: Comsys. Volunteer Gift Sponsors: TekSystems. Golds Sponsors: Head Spring Systems and ITalent. Gift sponsors: Oreilly and Pluralsight.
If you'd like to sponsor the event please email mailto:info@jointechies.com -
Nhibernate: Component set to null if all component columns are null
This post is in regards to the post I saw unanswered on Nhibernate forums since Mon Feb 12, 2007 1.
-
Playing with Expression Trees Part 1
I recently looked into an extremely powerful low-level tool that makes C# rise high among the contemporary languages - Expression Trees.
-
Fluent Nhibernate No persister for: <ClassName>
I got this error while working on the following class.
-
Composition vs Aggregation
Composition and aggregation both are different forms of association. If an association is more like a 'is a' relationship, both of these are more like a 'has a' relationship. It is more like a whole/part relationship or an owner/owned relationship. For example, an automobile has an engine or the other way round, engine is 'a part of' an automobile. What's the difference?
-
Asp.Net MVC2 and Azure - Dallas Tech Fest
It was great presenting at Dallas Tech Fest on Asp.Net MVC on Azure. However, this is the dilemma I have to go through unfortunately still. In a show of hands before the talk starts I still find majority of the audience not knowing about either of the technologies. So, I have to make my talk more dynamic so that I don't keep the audience guessing. This usually takes the talk in a direction that is really good for most of them. However, for the ones who know both I always run short of time to cover everything I had. In this talk, it was fun explaining how the partitioning guidelines for Azure Table Storage. I shall blog about it soon as I had a good feedback about the guidelines and it was pointed out that my recommendations have not been made on the web by others. That will be my first web contribution since I have been contributing only through talks and want to start reaching out a wider audience.
-
DataServiceRequestException was unhandled by user code. An error occurred while processing this request.
Make sure you please read the previous blog post on StorageException otherwise this would not make sense. Once we change the code in the constuctor and forget to change the table name this exception would occur. This exception occurs usually when
-
Exception of type 'Microsoft.WindowsAzure.StorageClient.StorageClientException' was thrown.
Sometimes even if we have the fabric running and the role manager is up, we get an exception of this sort.
-
3P's (Principles, patterns and performance) of Software Development Dallas Dot Net User Group.
I recently presented this talk on Jun 9th at Microsoft Offices, Las Colinas. This talk dives deep into the algorithmic analysis and problem solving to get the best preformance using the powerful C# language. It focussed specifically on improving performance on Asp.Net websites. It talks about YDN guidelines to make your websites perform faster.
At the same time techniques to demonstrate how to write modular code without affecting performance were shown. I shall be blogging separately on these topics pretty soon. -
Azure Table Storage C# Sig Dallas July 1st, 2010.
Tonight I presented at Improving Offices, Dallas. It was a great crowd with some really good questions on Azure. This talk went from Introduction of Azure Table Storage to the best practices in Windows Azure. We discussed the guidelines for addressing the issues of limited provision of indexing in Azure. I shall be blogging on it pretty soon as I don't think there is enough insight currently on partitioning data well.
-
Azure Table Storage Austin Code Camp
Just moved to my new blog. I am trying to upload all my presentations here starting from Austin Code Camp, this year. For presentations earlier to this, please email me or follow links at twitter @csdhall.