Tag Info

New answers tagged

0

I see two antagonistic design "forces" (which are not exclusive to controllers): cohesiveness - controllers should group related actions simplicity - controllers should be as small as possible to manage their complexity From cohesiveness point of view, all three actions (login, logout, registration) are related, but login & logout much more than ...


0

Controllers are usually created for a certain resource (an entity class, a table in the database), but can also be created to group together actions that are responsible with a certain part of the application. In your examples, that would be a a controller that handles the security for the application: class SecurityController { // can handle both the ...


0

It still belongs in a model, just not a view model. Since MVC assumes you are working in the UI they omit a "V"... View-Model View Controller, VMVC does not have the same ring to it. If your application is trivial, your view model and business model can be the same thing, and that's okay. But it sounds like you application is past that point. public class ...


0

If the "userManager" exposes separate methods for setting the email, the password, etc. then it is explicitly exposing a model in which partial failure is possible and to be expected. Sure, you can roll your own rollback mechanism as Snowman suggested, but I think it would be easier (more pragmatic perhaps?) to just add the ability to your "userManager" ...


1

You need to use a memento. At each step you look at the previous state and store it in a temporary object. If at any time there is a failure that requires rolling back, you simply look at each memento and restore the original state. This should normally be done as a LIFO stack to ensure changes are undone in reverse order. Note the term "roll back" here: ...


0

Inheritance I have used inheritance before as a solution for passing common data to many of the same pages (user, role, event tracking/logging, profile information, and other data). This is convenient in some cases, but not always ideal. For instance, you may add profile data to the base model for pages where they can add their email address, or display ...


0

MVC is a separation of concerns, hence, your controllers should never be in your Views folder (and vice versa). If I were you, I'd simply create a folder "Library" and "Hostel" in your project root. Then add a "Controllers" and "Views" folder for each. I suppose both share the same Models, so I'd put these in a separate folder in the root. If you really ...


2

You're almost there... Putting the REST between the view and the controller would be the right choice. That means that your view, i.e. a javascript code, will send REST calls to your server, which process those calls in the appropriate controller (then the models and etc.). In addition this controller would be responsible for the response back to the ...


0

Consider this a blend of two basic MVCs (this assumes you know the basic MVC). First, deeper MVC pair is: M = model C = controller V = view model Second, upper MVC pair is: M = view model C = collapsed / minimal / interspersed (OnSuperButtonClicked is part of it) V = view. With this separation, of course view from one triad cannot access model, nor ...


0

Consider the model being just data. It doesn't make choices, and it doesn't know how to render. A product can be a model. A list of products can be a model. A bundle containing the list of products, the cart and the information about the current user is a model. The last model from the list corresponds to the data you need to render the page, but it ...


3

The main problem that I see is that with the top approach, your website needs to be able to accept requests from mobile, as opposed to the services. That seems like something the website should not have to worry about. In particular, it implies either your website has a bunch of "pass-through" logic to duplicate the API of the services, or the website is ...


1

A Frontend-Controller should collaborate with a Router and a Dispatcher to decide based on the (HTTP) request against the application which concrete Action has to be executed and then dispatches it. Depending on how detailed a design is, some Controllers work without Routers and they do the routing their own or the routing is implicit in the design how the ...



Top 50 recent answers are included