on 30 October 18
When we look around in today's world, what we see is devices all around. Devices from mobiles to tablets to computers surround us and now the world is talking about internet of things. IOT means communicating between devices where each device will provide some relevant information to other so as to provide a customer with highest level of service. Example can be a Phone providing information about the user reaching home in around 10 minutes so that the AC can switch-on itself.
So here, when we can speak about communication or talk about internet and with internet; comes a world that suddenly seems much smaller than it is. Websites and applications are the main medium/interface using which people share and get information with each other. So how do this happen? To make a website we need a platform that is robust and reliable enough to handle huge traffic (people coming in to view website), should deliver better performance, provide enterprise level security and importantly should have minimal up time(time from development to production).
What to choose and why?
The MVC architecture
MVC architecture is loosely coupled. This means that the server is only concerned about the data that it needs to send to client and then its client's responsibility to handle that, as it wants. Hence, every single entity has a predefined role. One more advantage of this is that anytime we can replace the whole entity without even disturbing the other. Example: Suppose we have used Jquery to handle the rendering logic of the webpage but then later we found that React or Angular serve the purpose better so we can easily replace the client side logic with ours and it will not require a single code change at server logic. Since the server, side is just concerned about the data that the client passes it to process and the data that it needs to send.
MVC also had its own demerits even though it is a great architecture. Now with the evolution of MVC6 most of the demerits that MVC5 had are resolved the architecture is further enhanced to improve the performance and stability of the application that is built. MVC6 along with ASPNET 5 has taken a pick from best of various other technologies like Python, Nodejs so that it can provide a one-stop solution to the problems in hand.
The major advantages of MVC6 are as follows:
- The time has gone when we use to say that only Microsoft servers run Microsoft technologies. ASP.NET 5 is built to support Linux distros and MAC OS as well.
- Another major feature is use only what you need i.e. everything now is a middleware so we can now plug-in a piece of code that we want to run for a request. This means that we will only register the features that we need and the MVC will load them on startup. Hence, a performance improvement since we are only running what we need. If we do not need sessions for our website, we will not add them to our start-up and hence will save our processing of sessions middleware.
- Dependency Injection is a built-in feature of the framework. What does this mean for us? This means that now our application is more loosely coupled and testable. Using dependency injection we inject dependencies at runtime, since these dependencies are resolved at runtime we can easily replace them without changing the core functionality of the project. Example: We have a class say Price Calculator, which implements IPrice that calculates and returns a price for our product, but now we need to provide discount on certain days of the year. So suppose we implement a different class say Discount Calculator which will host the logic of calculating the discounted amount and then just need to replace the configuration to load one class on special days and replace it with other on the other days (Very vague example but just to give you a gist of it).
- ASPNET now has core framework which means that now if the underlying machine does not have the .net framework then too its fine. The ASPNET 5 will be built as a complete deployable package, which would contain the whole 11 MB framework and the rest of libraries to support our application. Also this means that now we can run two different .net frameworks on a single machine as both run on their own app domains which was not possible until now. Hence no need of IT team approval now as we need not change the server configuration to support the new framework as it is a self-contained entity.
- All the configuration files are now in json. What is the advantage of this? Advantage is that json format consumes far less space than xml when we consider huge files. Also reading a json file is much faster than an xml file. In the end, it means better performance for the application.
- One major feature is that now we do not use System. Web for Http Context. Also now, the Http Context will hold about 2kb of data instead of 30kb. This means further performance increase as now we would have to process far lesser data on every request. Also far, less data would be transferred between method calls this in turn enhances performance.
- MVC till now did not had a perfect replacement for user control that we use to have in web forms, but now with the introduction of View Components it has provided a solution. View Components act like mini controllers with better separation of concerns and usability. They are invoked like calling a function.
- The crucial part is, it's also open source.
Apart from the features mentioned above there are also list of features that are currently in process, hence will update the article as and when they come into picture. Also there is some document management like library that is built which is taken as a reference from python.