Skip to main content
Grammar and formatting
Source Link
Matthew Flynn
  • 13.5k
  • 2
  • 41
  • 59

I got into a debate at work today, I hope you can help me to settle it up.

My colleague wantwants to separate UI, Model, DB, and Network as fallowlike so:

Create an API level between UI and controller, that will allow the UI to query all the models in the APP.
There will be another controller that will break the models in to their DB representations(Ex: UserTablesModel, ScoreTableModel...), it will be called DBControler, it will be a singleton and it will also provide some utilities method to query the DB(Ex: insert(tableName, value...).
The ModelTables will use events hub to notify UI with state changes, and they will be updated from the network layer using DBControler reference.

  • Create an API level between UI and controller, that will allow the UI to query all the models in the APP.

  • There will be another controller that will break the models into their DB representations (Ex: UserTablesModel, ScoreTableModel...), It will be a singleton called DBControler and it will also provide some utility methods to query the DB (Ex: insert(tableName, value...).

  • The ModelTables will use events hub to notify UI with state changes, and they will be updated from the network layer using DBControler reference.

I don't like this idea as it creates a coupling between unrelated models in the controller layer. I think it willwould be wiser to allow the UI to have a direct access to Models  (May bemaybe make them singletons) and itsit's up to the model to offer a proper API to access it'sits data as well asand provide an events callback to notify his state change  (no events hub).I I like the part that models need to be directly updated from the network layer.

Also I don't like the name TableModel, I think the DB needs to be a service accessible by the model, one model can access multiple tables.

What is the proper way to work with MVC?

I got a debate at work today, I hope you can help me to settle it up.

My colleague want to separate UI, Model, DB, and Network as fallow:

Create an API level between UI and controller, that will allow the UI to query all the models in the APP.
There will be another controller that will break the models in to their DB representations(Ex: UserTablesModel, ScoreTableModel...), it will be called DBControler, it will be a singleton and it will also provide some utilities method to query the DB(Ex: insert(tableName, value...).
The ModelTables will use events hub to notify UI with state changes, and they will be updated from the network layer using DBControler reference.

I don't like this idea as it creates a coupling between unrelated models in the controller layer. I think it will be wiser to allow the UI to have a direct access to Models(May be make them singletons) and its up to the model to offer a proper API to access it's data as well as events callback to notify his state change(no events hub).I like the part that models need to be directly updated from the network layer.

Also I don't like the name TableModel, I think the DB needs to be a service accessible by the model, one model can access multiple tables.

What is the proper way to work with MVC?

I got into a debate at work today, I hope you can help me to settle it up.

My colleague wants to separate UI, Model, DB, and Network like so:

  • Create an API level between UI and controller, that will allow the UI to query all the models in the APP.

  • There will be another controller that will break the models into their DB representations (Ex: UserTablesModel, ScoreTableModel...), It will be a singleton called DBControler and it will also provide some utility methods to query the DB (Ex: insert(tableName, value...).

  • The ModelTables will use events hub to notify UI with state changes, and they will be updated from the network layer using DBControler reference.

I don't like this idea as it creates a coupling between unrelated models in the controller layer. I think it would be wiser to allow the UI to have direct access to Models  (maybe make them singletons) and it's up to the model to offer a proper API to access its data and provide an events callback to notify his state change  (no events hub). I like the part that models need to be directly updated from the network layer.

Also I don't like the name TableModel, I think the DB needs to be a service accessible by the model, one model can access multiple tables.

What is the proper way to work with MVC?

Source Link
Ilya Gazman
  • 295
  • 5
  • 15

A proper way to work with MVC

I got a debate at work today, I hope you can help me to settle it up.

My colleague want to separate UI, Model, DB, and Network as fallow:

Create an API level between UI and controller, that will allow the UI to query all the models in the APP.
There will be another controller that will break the models in to their DB representations(Ex: UserTablesModel, ScoreTableModel...), it will be called DBControler, it will be a singleton and it will also provide some utilities method to query the DB(Ex: insert(tableName, value...).
The ModelTables will use events hub to notify UI with state changes, and they will be updated from the network layer using DBControler reference.

I don't like this idea as it creates a coupling between unrelated models in the controller layer. I think it will be wiser to allow the UI to have a direct access to Models(May be make them singletons) and its up to the model to offer a proper API to access it's data as well as events callback to notify his state change(no events hub).I like the part that models need to be directly updated from the network layer.

Also I don't like the name TableModel, I think the DB needs to be a service accessible by the model, one model can access multiple tables.

What is the proper way to work with MVC?