Thursday, May 27, 2010

Generic Singleton

****

What was I thinking, if I use any regular class here, it will not be singleton as you could always new() up an instance.

****
Once and for all, I am going to settle with this implementation of singleton.

https://www.assembla.com/code/TechnologyAndMe/subversion/nodes/Singleton
(Download complete source using a SVN client from http://subversion.assembla.com/svn/TechnologyAndMe/Singleton )

Singleton is now as easy as:
var instance = Singleton<SomeOtherClass>.Instance;

Tuesday, May 18, 2010

Agile Estimation

I have created this document describing how to estimate for agile projects :
http://docs.google.com/View?id=dm24bwn_37hkjw97ff

Please provide your feedback and you are more than welcome to contribute your ideas/experiences.

Sunday, May 16, 2010

Downside of LINQ

 

  1. Operators like Orderby are greedy, when used execution is no longer lazy.
  2. You have to pay more attention to LINQ queries for remote data
  3. If you use Count on LINQ query and also use the same query in foreach, then you end up iterating over the dataset twice.
  4. no edit and continue support

Wednesday, May 05, 2010

Why should you use LINQ


What are the benefits of using LINQ?

  • Lazy evaluation
  • Parallel execution using PLINQ
  • Abstraction – declarative – only tells what is required, not how to get it
  • Because of extension methods – you can apply LINQ on anything
  • Works with any LINQ provider

Saturday, May 01, 2010

REST vs SOAP

 

REST

SOAP

Simple HTTP next DCOM
not transport neutral transport neutral
  message based security
only CRUD operations CRUD + more
can scale ?
broader reach and interoperability ?
std format using GET,PUT,POST,DELETE format is SOAP envelope,header,body
no need for WSDL  
data format can be JSON or XML  
easy to version and evolve ?
bookmarking and caching can be done cannot be done
Cloud computing people are using REST ?

SOAP is typically used in enterprise scenarios as middleware and most of the operations are pretty much CRUD operations.

Why REST :

  • if you only do HTTP
  • if you don’t need WS* and web Security(SSL) is good enough
  • Simpler than SOAP , uniform, comparable

Why SOAP :

  • if you need message based security – banks
  • your services are middle ware rather than public web services(web facing)
  • your services are local to enterprise

My post here tells you what REST is, however that is the most common understanding of REST, the definition goes beyond it, ex.

  • that resources be self-describing
  • complete object should be provided to POST/PUT instead of key value pairs of updates
  • collection of resources should be resource that represents a collection of other resources

World wide web is a RESTful system. Does your browser (the client) know whether it’s displaying a banking website or a casual game? Nope, it just utilizes standard media types (HTML, CSS, Javascript) to compose and represent the data. You don’t have to know the specific URL you’re looking for on a website so long as you know the “starting place” (usually the domain name) and can navigate there.

So REST is an ingenious and flexible way to allow for the consumption and traversal of network-available information. What it’s not, however, is a very good roadmap toward building APIs for web applications.

webHttpBinding - REST in WCF (Part 3)


Now we know that using [WebGet] we can get a resource based on URI. This is just the GET verb of HTTP, we also have other Verbs – PUT,POST,DELETE. To use these verbs WCF has the [WebInvoke] attribute.

However we cannot allow anyone to PUT,POST,DELETE our resources, so we will typically have some authentication process before we can allow this. This is achieved by reading and writing to the HTTP context. It can also be used to control caching, set content type, etc.

Taking the .svc Out of REST
WCF Services hosted in IIS use the .svc extension. This does not follow common REST URI naming practices. For example, the service in Part 1 and 2 is accessed using the following URI:
http://localhost/TimeService.svc/Now?GMT=1
You can remove the .svc extension by using an ASP.NET HttpModule (with IIS 7.0 only) to call HttpContext.RewritePath to modify the URI. This would allow the URI to take the following form: http://localhost/TimeService/Now?GMT=1


Technorati Tags: ,

webHttpBinding – REST in WCF (Part 2)


In Part 1, the service was exposed as /Now?GMT=5, now the solution is updated to handle request such as /GMT/5

Download the complete solution using an SVN client from here

[OperationContract]
[WebGet(UriTemplate = "/GMT/{GMT}")]
string GMT(string GMT);