Dependency Injection in .NET Core 2.0

Not easy! But it was not impossible! Yes, I am talking about my first book as co-author titled Dependency Injection in .NET Core 2.0.

The Start

First page was not easy. I am taking about my first book’s first chapter’s first page. I was not able to find ideas on how to start writing. In fact, I cried for sometime. But as usual, I motivated myself and accepted the challenge. I am not that kind of person who is scared of failures.

The Strategy

No doubt that I had experience in writing and I like that a lot, but writing articles, blogs is totally different than writing a book. That is what I learned after completing the book. After a lot of confusion, I started to design a well defined strategy to deal with the situation.

The steps were:

  1. Make a note of outline of first chapter.
  2. Now, forget about the book.
  3. Search for articles, blogs and videos on the topics related to first chapter based on the outlines.
  4. Make important points and draw diagrams to understand the concepts.
  5. Now start writing on the topics with the information gathered.

Interesting, isn’t it.

I started to enjoy this process and gradually completed the first chapter. Likewise, followed the same steps for other chapters as well.

The Outcome

Hard work always pays off. I was not the only one who was working hard. There were many techies and editors involved in the background along with my co-author.

Mr. Gaurav Arora, who is my mentor and guide, challenged me with this project. My editors Mr. Lawrence Veigas and Miss. Tiksha Sarang, who are very talented and friendly, did an amazing job in rectifying the mistakes and suggested improvements time to time.

The outcome was beautiful and the cover looked like below:

Tadit Dash Dependency Injection in .NET Core 2.0

About the Book

.NET Core provides more control than ever over web application architectures. A key point of this software architecture is that it’s based on the use of Dependency Injection as a way to properly implement the Dependency Inversion principle proposed in the SOLID principles established by Robert C. Martin.

With the advent of .NET Core, things have become much simpler with Dependency Injection built into the system. This book aims to give you a profound insight into writing loosely-coupled code using the latest features available in .NET Core. It talks about constructors, parameter, setters, and interface injection, explaining in detail, with the help of examples, which type of injection to use in which situation. It will show you how to implement a class that creates other classes with associated dependencies, also called IoC containers, and then create dependencies for each MVC component of ASP.NET Core. You’ll learn to distinguish between IoC containers, the use of Inversion of Control, and DI itself, since DI is just a way of implementing IoC via these containers. You’ll also learn how to build dependencies for other frontend tool such as Angular. You will get to use the in-built services offered by .NET Core to create your own custom dependencies.

Towards the end, we’ll talk about some patterns and anti-patterns for Dependency Injection along with some techniques to refactor legacy applications and inject dependencies.

What You Will Learn

  • Understand the concept of DI and its implications in modern software construction
  • Learn how DI is already implemented in today’s frameworks.
  • Analyze how DI can be used with current software to improve maintainability and scalability.
  • Learn the use of DI in .NET Core
  • Get used to the possibilities that DI offers the ASP.NET Core developer in different scenarios.
  • Learn about good practices and refactoring legacy code.

How to get the Book?

Book is available on Amazon with two formats Kindle and Paperback. Also available on Publisher’s (Packt’s) site with Ebook and Paperback formats. Links are given below.

Amazon.comhttps://www.amazon.com/Dependency-Injection-NET-Core-loosely-coupled-ebook/dp/B01N2W8IEN/ref=sr_1_3?ie=UTF8&qid=1510939068&sr=8-3&keywords=dependency+injection+in+.net

Amazon.inhttps://www.amazon.in/Dependency-Injection-NET-Core-2-0/dp/1787121305/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=&sr=

Packthttps://www.packtpub.com/application-development/dependency-injection-net-core-20

Feedback

Techies are loving the book as I am getting reviews from different sources. Moreover, I am getting reviews in mail and social media.

I would be grateful to you if you feed in your comments about the book on Amazon.com. Don’t hesitate to ask me questions by adding comments below. Share with your friends and colleagues.

Thanks for reading the blog. Have a nice day ahead. 🙂

 

 

 

 

Advertisements

Top Features of ASP.NET vNext

Of course, as the name suggests, it is the upcoming version of ASP.NET.

At a Glance…

The next version of ASP.NET has been redesigned from the ground up. It has been designed to provide you with a lean and composable .NET stack for building modern cloud-based apps. The Applications will be faster as well as modular and consume less memory. .NET vNext is the next major release of .NET Framework. .NET vNext will have a cloud optimized mode, which will have a smaller clone of the Framework as compared to the full .NET Framework. ASP.NET vNext will build on .NET vNext.

Overview of ASP.NET vNext

Overview of ASP.NET vNext


Let’s explore some of the features of ASP.NET vNext.

No more System.Web !!!

Could you imagine ASP.NET without System.Web.dll !!! Yes, it’s happening now in the new Version. This dll makes the .NET applications slower and also consumes higher memory. Therefore, there’s no Web Forms in vNext, but Web Form development will continue to be supported in Visual Studio. MVC, Web API and Web Pages have been merged into one framework, called MVC 6. This will follow common programming approach between all these three i.e. a single programming model for Web sites and services. ASP.NET vNext includes new cloud-optimized versions of MVC, Web API, Web Pages, SignalR, and Entity Framework.

First Class Citizen is NuGet

Microsoft’s new strategy is…

“mobile-first, cloud-first”

As a result, the vNext Apps can use a cloud-optimized runtime and subset of the .NET Framework. You will be astonished by the fact, this subset of the framework is about 11 megabytes in size compared to 200 megabytes for the full framework. This is because the .NET Framework is composed of NuGet Packages.
Can you guess what I am going to write next? Yes / no !!! Okay, let me tell you. As the Cloud Optimized Framework is just a composition of NuGet packages, so control is with you. You can select and add the NuGet package, that is necessary for your Application. No need to have the whole Framework added to the App, while you are not even using 10% of it. No unnecessary memory, disk space, loading time, etc. For instance, if your App implements Dependency Injection, then include it, otherwise not.

New Development Experience

Time Elapsed Shown on the Go

Now, in Visual Studio, you can see how much time a particular method or code line takes to execute.

Time Elapsed in Visual Studio

Time Elapsed in Visual Studio

Save and Refresh, no Build

Change code files, don’t build again. Go to browser and refresh. Will it work? Answer is Yes, with vNext. This is a very interesting and time saving feature. As a developer, we know the pain of building the App again and again for any simple change. Now, in vNext, we don’t have to. This is the power of new Open Source Roslyn compiler, which compiles code dynamically. You can even use Notepad or any Text Editor to directly edit the files and just save to see the change. That means we can now build ASP.NET Web Apps without Visual Studio. But Visual Studio provides the best development experience. See the video below to see how this works.

Even, you can now edit code on the go using Visual Studio Online (“Monaco”).

Update Code in vNext

Update Code in vNext

Open Source, Cross Platform

As I mentioned that, we can build projects without Visual Studio, this implies that .NET vNext is open source and cross platform. It can run on Mono, on Mac and Linux. Everything is available at .NET Foundation and Github. You can Follow and Contribute.

vNext Cross Platform

vNext Cross Platform

Dependency Injection

Dependency Injection is built into vNext. All of the vNext components like MVC, Web API, SignalR, Entity Framework and Identity will use the same Dependency Injection.

Side by Side Deployment

Framework is with you, so forget System Admin !!!

For upgrading your App to the latest Framework, you always request your System Administrator or Network guy to install the new Framework, so that you can consume that. In the next generation of .NET world, no need to do that. Framework itself comes as NuGet Package and gets included to the project you create. Microsoft would deliver updates for the package and your App can directly get the latest Framework changes. That also means, you can have multiples Apps on a Server, running different .NET Frameworks. Isn’t it interesting !!!

Application is insulated from Server’s Framework Changes

Application on the Production Server would not have any deployment issues further, as it won’t be affected by Server’s Framework patch level. That is because, the Application itself has the NuGet Package of certain Framework level attached with it. Even if the Framework on Server changes, it cannot affect the Applications.

But where to start?

There are many more life changing things coming in this new version. Below are the resources you can refer to explore more.

Join Hands with the Team

If you have any questions, suggestions, then you can directly work with the team. Below are the platforms you can use to use.