Tuesday, May 10, 2016

ASP.NET Core day - BDotnet

Another month, another BDotent community event, but this time it is on latest ASP.NET Core technology and a full day event.
We are not going to miss it. :)
For me all the BDotent events are about getting to know the gist of the topic and leave with enough enthusiasm to explore the remaining details.
One more big thing is Networking, It is always pleasure to meet and know the fellow developers and to share the information on what type of applications we work on, and what all the tools & technologies we are using.
(This time met some of the old buddies, and also made some new friends.)
Overall, it's mainly the experience of being present at the event.
As usual, all the speakers are wonderful in sharing their knowledge, and their enthusiasm conveys us the most. All the topics are very well chosen, like connecting the dots to get the overall picture on the ASP.NET core.
Thank you for all the awesome speakers, and the organizing committee.
It was wonderful to witness the house packed sessions.

My key takeaways from the event are,
  1. As there is an another new framework is out, we shouldn’t jump in and start using it for all kind of applications. We first need to understand our application use cases, then evaluate the options to take the decision.
  2. ASP.NET (Web forms) framework is not going any where. It is very much supported. New features will still be coming out for this. There are lot of application, which are running on ASP.NET framework. (I had a big doubt on the ASP.NET web forms support, glad that it is clarified.)
  3. ASP.NET Web forms is not supported in ASP.NET core. It is very much dependent on System.Web.
  4. POCO controller are very much useful when we do not require all the features from BaseController.
  5. In new framework, Dependency Injection is already integrated, But if require, we can very much plug in any of the third party DI containers.
  6. New web server (Kestrel - cross platform) written from the scratch, for the .NET core.
  7. RC2 is going to be out in mid May, and RTM is going to be released by June end.
  8. Cloud born applications.
  9. Tag helpers, more cleanness, more readability.
  10. ASP.NET core more of modularized, empty project means it’s clearly empty. Whatever we want, we need to add it.
Volunteer : It was my pleasure to help the event in a very small way (being part of the registration process). Thanks Lohith for the opportunity.
some pics,

Wednesday, June 3, 2015

Using statement in C#


using:

Using block/statement is used to free unmanaged resources.

Using statement is translated to three parts,
  • Acquisition
  • Usage
  • Disposal
This resource is first acquired, then the usage is enclosed in a try statement with a finally clause. The object then gets disposed in the finally clause.

using (MemoryStream objStream = new MemoryStream())
{
    objStream.WriteTo(Response.OutputStream);
}

this code gets translated to

MemoryStream objStream = new MemoryStream();
try
{
    objStream.WriteTo(Response.OutputStream);
}
finally
{
    if(objStream !=null)
       ((IDisposable)objStream).Dispose();
}


Objects that implement IDisposable can be used in a using statement. Calling Dispose() explicitly (or implicitly via a using statement) can have performance benefits.

"Code that is using a resource can call Dispose() to indicate that the resource is no longer needed. If Dispose() is not called, then automatic disposal eventually occurs as a consequence of garbage collection." - MSDN

In the below code we can observe the following points,
  • If we use using block along a Customer type, it give a compiler error, saying that "type used in a using statement must be implicitly convertible to 'System.IDisposable'".
  • Same if use with Student type, it does not give any error, because it implements System.IDisposable interface.
Sample code -