Article
Picking a Stack for the .Net Framework
Sometimes when working with a new client at Fresh, they know they want to use the .Net Framework for their site or web application, but they are not sure exactly which configuration or “stack” would work best. While the .Net framework started out with a small set of options, it has grown enormously over the past 10+ years. I’ve been fortunate enough to dabble in most of its offerings for both web and desktop apps. Through it all, I’ve pieced together my favorite “stack” for my application development, which I like to call the ZANS Stack.
The ZANS Stack (named somewhat in honor of Dr. Seuss) contains the following components:
ZA – Zurb Foundation for Applications
Zurb Foundation for Applications (or ZFA) is a newly released front-end application framework. It was built using a “mobile first” approach to responsive design and has been constantly improving itself. ZFA gives you lots of controls out of the box for developing your interface and can easily be extended and customized to fit your needs. ZFA is also built using AngularJS as it’s scripting base. I’ve been amazed at how AngularJS is structured to easily bind application data from APIs (and other sources) and update the display with little work. A lot of the “visual candy” that you get through jQuery (and plugins) can be implemented using AngularJS as well. Tasks that often took me a couple of days to implement and verify can now be done in one. Both ZFA and AngularJS are relatively new in the development world, but they are built by solid companies who are committed to their continued development.
One particular benefit of using ZFA in a .Net environment is that ZFA is built using a standard bower/gulp model for building and managing it’s resources. .Net resource development relies upon NuGet for its package management. While this is helpful for resource and back-end libraries, this has caused problems with managing front-end/display libraries. By leveraging the new Task Runner extension available in Visual Studio 2013, you can truly separate your front-end development from your back-end development, and still do all of your work within Visual Studio in a single project file. A great example of setting up Task Runner can be found here.
N – .Net WebAPI Model
Web-based applications are rapidly evolving more into an API type model. By making your application API-based, you remove a lot of the additional work needed to create a mobile or desktop versions of your application. You can simply build your front-end code and have the API perform most of the “heavy lifting” operations. The .Net WebAPI platform allows you to quickly build an API for your application that is REST compliant and can easily handle token-based authorization when you need to protect certain portions of your application. Visual Studio also provides some wonderful scaffolding for WebAPI controllers, including scaffolding against Entity Framework models or to query/output using the OData standard. This will save you even more time when getting a new app off the ground.
S – SQL Server
SQL Server is the most readily supported back-end database for the .Net framework. It easily handles 99% of your application needs, until you get into a scenario where a document database (such as RavenDB) will be more beneficial for your application. I prefer to use the Entity Framework – Code First library to map my database tables to objects within my code. This exposes the LINQ query model that allows me to build out queries in a “code readable” format and leverage lambdas, enumerable types, and other .Net features on top of my standard SQL queries. It also enables database migrations, which allows me to automate database changes and upgrade/downgrade the database on demand.
Beautiful Modularity
By having the stack built out this way, you can easily separate all pieces within the application within your typical MVC (model, view, controller) architecture. Your designers can create a fabulous layout with the Zurb framework. Your front-end developer can use the power of AngularJS to make the application fast and functional. Your back-end developer can build the WebAPI to service the application and allow it to easily expand to mobile apps or third party applications as needed. Your data designer can model out the database and make changes whenever necessary, since data migrations can be upgraded (or downgraded) on demand. Naturally, you can mix and match these duties as your team size demands.
This approach also allows you to swap out technologies in the future if the needs demand. Entity Framework can interface with a MySQL or RavenDB database with minor changes. You can change your front end to a standard Razor front-end syntax and still interface with the WebAPI. While it would take a little more work, you could also change out your middle tier to use PHP, as long as your WebAPI methods retain the same name and you have the proper drivers to interface with your database.
There you have it, a .Net stack that is powerful, elegant, and easily interchangeable to meet your needs.