Blogs on .NET and LAMP Technologies
There's often more than one correct thing.
There's often more than one right thing.
There's often more than one obvious thing.
--Larry Wall
Sunday, July 12, 2009
Saturday, July 04, 2009
WCF Sessions
In WCF, sessions are seen as group of ordered conversation in oppose to object centric behavior in ASP.NET. If the messages are exchange with same contract and contract specifies the session, a session is established for these messages. Following are the major differences between asp.net session and WCF session.
ASP.NET | WCF |
Session is initiated by the server. | Session is initiated and terminated by the client. |
Ordered processing (Messages are processed in sequence). | Unordered Processing |
Provides general data storing mechanism | No such mechanism |
In simplest form, we can specify session in following way:
[ServiceContract(SessionMode.SessionModeRequired)]
Public interface ICalculator { …}
WCF session has resemblance with local object. So by default, all subsequent requests are handled by same service instance.
Initiating operations are like constructors and Terminating operations are like destructors and requests between these two are like operation called on object.
[ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples", SessionMode=SessionMode.Required)]
public interface ICalculatorSession
{
[OperationContract(IsOneWay=true, IsInitiating=true, IsTerminating=false)]
void Clear();
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]
void AddTo(double n);
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]
void SubtractFrom(double n);
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]
void MultiplyBy(double n);
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]
void DivideBy(double n);
[OperationContract(IsInitiating = false, IsTerminating = true)]
double Equals();
}
For detail: WCF Sessions.
Monday, June 08, 2009
C# 4.0 – the features I like most.
C# 4.0 is coming up with following new features as of its documentation on MSDN now:
- Dynamic lookup (You don't need to worry about type of target; Runtime figures out what exactly the operation means to the object)
- Runtime lookup (Operation is dispatched through reflection at runtime)
- Named and Optional Parameters (default values can be set to function argurments)
- New features in COM Interop – Compiling without PIAs, Omitting Refs, Dynamic Import
- Variance (Automatic assignments where it is safe in case of Generics)
- Covariance (The new IEnumerable and IEnumerator interfaces, now sequence of strings is also sequence of objects; very useful in Linq queries)
- Contravriance (Type parameters can be declared as "in" in Generics; IComparer<object> can be used where we are expecting IComparer<string>)
Though I have been using dynamic languages like python and perl, I really need to explore features of Dynamic lookup. As of developer of so many APIs, I can say that Named and Optional Parameter feature is really cool. It will provides enormous flexibility to API developers as well as API users. Last one is Compiling without PIAs. The developers who have worked on PIA can only know how useful this feature is. It gives big relief from versioning and loading large assemblies.
Wednesday, May 27, 2009
Regular Expression - using back reference in javascript
var test = "personal personal computers and super computers computers";
test = test.replace(/(\w+)\s+\1/g,"$1");
alert(test);
Thanks to Cracki for pointing out difference between back reference and back tracking.
Friday, March 27, 2009
Sixth sense technology
Technology Breakthrough by an Indian !!!!
http://www.ted.com/index.php/talks/pattie_maes_demos_the_sixth_sense.html
Friday, March 20, 2009
.NET String comparison benchmarking
Sunday, March 15, 2009
Regular Expression Cookbook
I have been waiting for this Regex cookbook for long time. I will make sure that I am the first person to get this book from store as soon as it is available.
http://www.amazon.com/gp/product/0596520689?ie=UTF8&tag=slfb-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=0596520689
Thursday, March 05, 2009
IE 8 - New Ajax and DOM storage Features
- New Ajax Navigation
- DOM storage upto 10 MB
- Online/Offline detection in Javascript
- XmlHttpRequest Timeout
http://msdn.microsoft.com/en-us/magazine/dd458804.aspx#id0100180
Wednesday, March 04, 2009
Perl - Find and replace without Regex
my $pattern = '[lerp]+';
my $target = 'this is [lerp]+ perl';
(my $output1 = $target) =~ s/${pattern}//g;
(my $output2 = $target) =~ s/\Q${pattern}//g;
print $output1 , "\n";
print $output2 , "\n";
Ouput:
this is []+
this is perl
Becoming a great writer !!!
When asked to define "great" he said "I want to write stuff that the whole world will read, stuff that people will react to on a truly emotional level, stuff that will make them scream, cry, wail, howl in pain, desperation, and anger!"
He now works for Microsoft writing error messages.