Tag Info

New answers tagged

0

We can use MVVM to resolve this issue. The Model-View-ViewModel, or MVVM pattern as it’s commonly known, is a UI design pattern. VM takes all logic about preparing model data for UI from VC. Example: You have got model object with some fields, you want to format some of them, make calculation and combine them. In MVC case all that logic located in ...


5

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 ...


2

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, ...


0

The best way is to develop the 2 aspects in different processes and use a form of IPC to communicate between the two. He will develop a "server" process that must define an API for you to use. (You don't have to use the client-server model like this so you could develop in 2 different linked modules, but it helps for testing and also helps to reuse the ...


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, ...


0

If you don't want your users to view the data in the format that is returned by the API to the client side JS, then you can do the client side processing/aggregation on the server itself and return the aggregated data via your API. This way the API will only return the data that the users are allowed to see and your JS framework works just as a presentation ...


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). ...


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 ...


0

Instead of having a single class for the model, the view and the controller I would make them 3 different folders/packages full of multiple classes/views/controllers. That will allow you to bind each button or a group of buttons to a different listener/controller which performs different operations on the Model depending on the listener. One possible ...


0

The MVC pattern was originally formulated before graphical interfaces became commonplace. In that era,it was up to the application to correlate a screen position with a particular button/input field. It was the job of the Controller part of MVC to make that mapping. Nowadays, translating mouse clicks to a press of the correct button (or a key press to a ...


0

The big problem is deciding what is a Model in your application. Usually MVC is used for data presentation/manipulation, and you don't really have any data. You could - for fun (education) - create for example a MathOperationModel that would be exchanged between Server and Client. Implementing typical CRUD (Create Read Update Delete) actions for it etc. ...


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, ...


-1

I think that break into 3 functions like you said is the best alternative, mainly to separate the logic of each user. Here's an example of how this can be made: public function index() { $method = "index" . ucfirst($this->user->role->name); $this->$method(); } private function indexAdmin() { // do stuff } private function ...


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 ...


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 ...


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 ...



Top 50 recent answers are included