4 ms·
Last month a client asked me to build them a crud form only using old school C# MVC with Razor templates. And by golly it was much harder for me than just doing
by JackMorgan 3y ago
Last month a client asked me to build them a crud form only using old school C# MVC with Razor templates. And by golly it was much harder for me than just doing it in React+Next.
I had some nostalgic notion that MVC was going to be a smooth ride. That all this JS cruft was slowing me down. Then I needed a search bar, then validation, then I kept running into weird surprises with Razor templates. After a month I ruefully concluded I'd have gotten it done a heck of a lot faster just using my usual stack.
I now regret all those times I complained about how much bloat there is in the JS ecosystem. Yes, is it possible to make crud apps with Razor, sure, people do it everyday. But for me, with a project with increasingly complex display logic and validation, I definitely should have tried a little harder to talk them into using Next and TS.
As an aside, I was surprised that getting HMR with C# is kind of a pain. I never figured out how to get it while debugging. So every time I wanted to debug some new issue with the template not sending data right to the controller (which felt like every few seconds of work) I'd have to restart the server and wait 10+ seconds for it to restart and then renavigate to where I was, reenter my form fields, and then try again. After I was done and wanted HMR, I'd have to restart the server again. That extra hassle really started to grind on my patience.
- onli 3y agoThe jump from JS to the microsoft world is always hard. Hell, jumping from anywhere into microsoft environments has to be hard. No surprise that it was a difficult transition if that wasn't in your background so far. The docs alone will cause a culture shock! > But for me, with a project with increasingly complex display logic and validation It always sucks if the requirements are not clear in the beginning, if the dev can't anticipate how they will grow in advance? But what has validation to do with it? That's completely backend, how would that have been easier with React+Next? > As an aside, I was surprised that getting HMR with C# is kind of a pain. Proper systems dynamically interpret their templates on every request in dev mode because of this, like Ruby/Sinatra does.
- tantalor 3y agoWhat is HMR? Is it edit/refresh?
- wickedsickeune 3y agoHot Module Reload, changing the code in a "module" and not having to refresh the whole page.
- threatofrain 3y agoIMO validation / boundary code ought be shared between frontend and backend.
- skydhash 3y agoYou can never trust the client. The only thing that you can do is warning about bad input, aka UI decorations.
- Alano13 3y agoSorry, but what’s wrong with microsoft docs?
- onli 3y agoDidn't necessarily say they is something wrong with them :) Though in this specific case the ones I skimmed did not look very useful, and in general they are organized quite differently than FOSS projects usually organize their code, was my impression so far.
- quest88 3y agoAre you surprised that it took you longer with a tool you don't know compared to a tool you do know? IMO, that should be expected.
- JackMorgan 3y agoMore surprised at how much I'd forgotten and how it can be pretty fussy to use. I had in my mind a nostalgic feeling of it being so much easier and faster.
- url00 3y agoHaving done a similar project this year I completely agree with you. Maybe that's more a statement against Razor than MVC itself - I suspect it's much cleaner/easier to do a trad MPA+MVC-style app in a language+framework combo that is made for it like Rails. I think the reality is that Razor has been left rotting for a while. It still works, and there's nothing that bad about it but the DX is not good, especially compared to modern JS frameworks. It's hard to explain to people who haven't worked with Razor how annoying things like validation are. There is a "happy path" where the different parts of the validation framework all talk to each other, but it's not obvious and the Razor documentation on MSDN is very _not good_. It doesn't help that there's like 5 completely different things all called "Razor/Blazor" and a lot of semantic overlap between them all. Very frustrating to need to sift through so much to find something that feels like it should be easy and well supported.
- JackMorgan 3y agoThis exactly summarizes how this last month has felt. Weird, frustrating issues that are weirdly hard to even find documentation on.