Tag Info

Hot answers tagged

4

The key in understanding MVC lies in the separation of the responsibilities, as MVC is simply SRP applied to UI code. It separates what data has to be displayed, from how to display it, from how to handle screen events. But an important (and often missed) detail of the original definition of MVC is that it was designed for a far more granular level. For ...


4

This is rather strange, although the answer depends on the language/framework you use, since different languages/frameworks have different approaches of MVC. In general, you won't use one controller from another one since: Controllers usually return a result of a type intended to be used by the MVC framework. This result contains a lot of information you, ...


3

Just some thoughts. (Mandatory disclaimer: use of the information for purposes other than strictly personal use or entertainment, or use for purposes that may harm safety or cause loss of assets or life, is strictly forbidden.) Since I'm not certain about what you mean by "entity", I will just list the properties (model and behavior) a person (who can ...


3

In larger applications, you will benefit from further modularisation beyond MVC. The model can be broken down into: Domain objects - like Student or Course that you mention Data access objects (DAO) - code to load/save domain objects Service layer - business logic that operates on domain objects People often forget about the DAO layer because if you're ...


3

I use MVC in both. Yes the views server-side are very simple, but that's ok. Still nice to have separation of concerns for all the usual reasons.


2

Then just don't make a public API. Make your web server build the HTML in the back-end and simply return it as a whole. KISS. If you want to build a HTML/JS front-end that calls public JSON/whatever REST services, there will be hundreds of ways to call the services directly┬╣, even it means to simulate a browser (which is really not as hard as it sounds). ...


2

Wouldn't it be simpler to pass the callback to connection.query around? // model function listCountries(limit, offset, callback) { // SQL is just an example connection.query('SELECT * FROM countries LIMIT 1', callback); } // controller var Country = require('./country.model'); exports.index = function(req, res) { var limit, offset; ...


1

I also prefer strongly-typed views with dedicated ViewModels. To get around the problem you are seeing I sometimes construct my ViewModels like: public class UserCarsViewModel { public User User { get; set; } public List<Car> Cars { get; set; } public bool SomeCalculationIDontWantToHaveToDoInRazor { get { return _some mildly ...


1

You will probably need three tables: User tables with a primary key and the usual first name, last name etc Roles table with roles specific to your application (eg Administrator, Power User, User, read only) UserRoles with the user primary key, roles primary key, date created, date last modified, enabled (NUMBER (1) default 1 with check constraint that this ...


1

To your specific question in terms of code: A good idea would be to use the facade pattern to have a single point of access to the model from the controllers, so you can always call the facade and don't have to think about how his model logic will deal with the request internally, or which classes he will use. Furthermore, if MVC is done correctly the model, ...


1

One technique (using Event-Based Systems with a Mediator): I take advantage of the Mediator Pattern quite a bit -- one way to control event-flow is to instantiate different Mediator objects per-module, and pass only a specific Mediator to each module (as a, or in a sandbox) -- this will allow each module to only communicate through that specific medium, ...


1

It is helpful to distinguish two types of access control: Vertical - functions that some users can access and some users cannot. For example, anyone can view the home page, but only admin can ban a user. Horizonal - functions that multiple users can access, but the data is segregated. For example, everyone can access "inbox" - but they see only their own ...


1

It helps to make a distinction between: Helpers - support code that is not aware of your model, e.g. date formatting. Services - support code that is aware of your model, e.g. bills credit card, updates user record, sends user email I'm not quite sure which of these you mean by "library". Anyway, following your terminology, I suggest this chain: router ...



Only top voted, non community-wiki answers of a minimum length are eligible