4 ms·
Ask HN: Alternatives to MVC
I'd like to branch out from MVC for my next webapp. What battle-tested alternatives are others using?
Here's a post from 2014, but there aren't any example code bases. https://blog.ircmaxell.com/2014/11/alternatives-to-mvc.html
- quickthrower2 7y agoIt depends on why. Is it for learning purposes, or some other reason? Old school (but battle tested, not great patterns for learning though): * One file (script) per route e.g. classic vanilla PHP. * ASP.NET web forms - tries to make the web like a drag and drop windows forms application. Very nice for basic websites but doesn't scale to well if there are a lot of nested controls. Has this horrible concept called 'viewstate' where you send state about your controls in a hidden form field and post it back. This makes server side "on change" events possible for client side actions. It's horrible because Viewstate size grows quickly for complex forms, and it doesn't feel very web-like or Restful. If you want to create a SPA, then React/Redux and Elm offer interesting patterns, but your server would still need to send data, and I can't think of anything better than an MC (no V!) type of framework for this.
- tabtab 7y agoWhat is a "Restful feel"? I didn't think REST was a UI pattern or style.
- tim333 7y agofrom https://www.codecademy.com/articles/what-is-rest https://www.codecademy.com/articles/what-is-rest >SEPARATION OF CLIENT AND SERVER >In the REST architectural style, the implementation of the client and the implementation of the server can be done independently without each knowing about the other. This means that the code on the client side can be changed at any time without affecting the operation of the server, and the code on the server side can be changed without affecting the operation of the client. which is kind of different from having server side "on change" events
- tabtab 7y agoStill this describes an "under the hood" implementation technique. It doesn't describe a UI method/technique/style in terms of what the end user sees. The end user's perspective is the key to my question. If that wasn't clear, I apologize.
- muzani 7y agoStateless is what I imagine REST to feel like. You do everything with just an API key or token. There's no need to keep trading credentials with the server.
- sansnomme 7y agoA ton of web frameworks are trying to reinvent WebForms using WebSockets e.g. Phoenix LiveView, the new Blazor components in ASP.NET CORE that uses WebAssembly alongside WebSockets to create a unified stack. Unfortunately the whole web builder concept is no longer popular other than for generic sites, those areas are dominated by companies like Webflow, Weebly, SquareSpace, Pinegrow etc.
- deleted 7y ago[deleted]
- tabtab 7y agoMicrosoft has something called Razor Pages that is sort of a hybrid between MVC and Web Forms. It may be a better fit for smaller projects, but is still fairly new. Are you mostly doing CRUD (data-centric), or a more document-centric (CMS-like)?
- davidjnelson 7y agoYou could look into functional reactive programming as in rxjs/rxjava etc (https://medium.com/netflix-techblog/reactive-programming-in-the-netflix-api-with-rxjava-7811c3a1496a https://medium.com/netflix-techblog/reactive-programming-in-...) or command query responsibility segregation (https://microservices.io/patterns/data/cqrs.html https://microservices.io/patterns/data/cqrs.html).
- sebscholl 7y agoI'm ready this book right now, and it's great. https://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612/ref=mp_s_a_1_3?keywords=design+patterns&qid=1565745735&s=gateway&sprefix=design+pattern&sr=8-3 https://www.amazon.com/Design-Patterns-Elements-Reusable-Obj...
- deepaksurti 7y agoIf you haven't, you can look at MVP [1] and [2]. In MVP, by rotating (or twisting) the MVC triad, one can produce an "Observer" based framework that is easy to use and more flexible. Some googling and you may find more literature on the same including comparisons with MVVP. [1] http://www.object-arts.com/downloads/papers/TwistingTheTriad.PDF http://www.object-arts.com/downloads/papers/TwistingTheTriad... [2] http://carfield.com.hk/document/software+design/MVP.pdf http://carfield.com.hk/document/software+design/MVP.pdf
- throwaway5d097 7y ago"View oriented" like https://www.liftweb.net/ https://www.liftweb.net/
- fgonzag 7y agoI'm quite fond of the Ports and Adapters / Hexagonal architecture.
- xaedes 7y agoImmediate mode gui - short imgui. For example the library "Dear imgui". Basically you write imperative paint functions like this example: ImGui::Text("Hello, world %d", 123); if (ImGui::Button("Save")) { // do stuff } ImGui::InputText("string", buf, IM_ARRAYSIZE(buf)); ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
- dragonwriter 7y agoWell, MVVM is a battle tested alternative to MVC.
- arh68 7y agoOne alternative: The Elm Architecture [0] is more like Model-View-Update than MVC. Examples aplenty [1]. [0] https://guide.elm-lang.org/architecture/ https://guide.elm-lang.org/architecture/ [1] https://elm-lang.org/examples https://elm-lang.org/examples