OdeToCode IC Logo

MVC 5 In Retrospect

Thursday, June 13, 2019

I've been in the guts of an ASP.NET MVC 5 application lately and have some more perspective on the improvements we take for granted in ASP.NET Core.

Oslo in Oil

  • Tag helpers are far easier to read and write compared to HTML helpers. There were days when I wanted to give up on Razor views, but tag helpers make the Razor engine second to only JSX in terms of smoothness. Of all the different techniques I've used to dynamically generate HTML, JSX and TSX are by far my favorites, and I think that’s because JSX took the approach of embedding the declarative language inside the imperative language (HTML inside of JavaScript). Embedding in the other direction, as Razor and others have done (language X inside of HTML), always seems to create scenarios with awkward syntax.

  • It is refreshing to work with a framework that embraces dependency injection, like ASP.NET Core. ASP.NET MVC danced around DI and provides a hook for a central dependency resolver, but you always have to wonder if something might not work because you’ve strayed outside the lines.

  • The artificial separation between ASP.NET MVC and the ASP.NET Web API was unfortunate and unpleasant, but follows Conway’s law.

  • The startup logic for an ASP.NET MVC application is difficult to follow. There is code in global.asax and three or four other files in the App_Start folder. I haven’t been a big fan of how ASP.NET Core applications organize startup logic (see opinion 7 and 10), but even the worst examples are far better than the MVC approach.

  • Applications built before attribute routing was popular have the worst API routes.

  • Front end builds were easy and fast when all you had to do was bundle and minify jQuery and a few other files.

  • The scaffolding tools in MVC 5 are far ahead of the scaffolding tools for ASP.NET Core. Not only are the older tools considerably faster, but they tend not to throw exceptions as often as the ASP.NET Core tooling. Hopefully, ASP.NET Core will catch up.


Comments
Gravatar John Marsing Friday, June 14, 2019
- TSX & JSX never heard of it, interesting - ASP.NET Core scaffolding it's worthless to me, what's up with that? - Tag Helpers, I was very excited when this came out. Great to use the built in ones, but I have yet to build one myself. I've tried but it has way to much ceremony or something, can wrap my head around how to build them. I almost wish there was a wizard that could scaffold out the beginings of one, oh well. - I also like View Component, it's better than what was used in MVC 5 (can't remember what it was called) - Really like Razor Pages and how it allows features like the work around Nuget package you developed pre RP Anyway, thanks for the blog
Friday, June 14, 2019
Your comment about front end builds makes me think about how commonplace npm, nodejs, and gulp are now. If you are using npm to resolve gulp then you need a plethora of things installed including nodejs, python, and C++ build tools, and all of very specific versions with other settings or env. vars to ensure the correct versions are resolved. God forbid you have an old project you can't upgrade which needs specific older versions while also supporting other projects that need newer versions. The node_modules folder is scoped to the solution but these external tools are scoped to the machine. This creates lots of opportunities for devs to have unique machine specific problems with obtuse npm or C++ compilation error messages that require a senior basically sit with them and go thru all the troubleshooting to determine what tool/version is the source of the issue. Then run specific troubleshooting commands like gulp. A couple years ago it was common to be able to pull a project from source control, do a juget restore and build, and all dependencies resolved successfully. MVC had good options for *.less compilation that were pure .Net tools resolved thru nuget. Now many frameworks hace moved off *.less and if you need to properly inject variables into the css compilation then you need gulp because it's the only thing up to date and supporting the features things like bootstrap 4 is using.
Comments are closed.