0

I am working on sorting out my Javascript code. Currently I have views implemented without any Model or collection. Now I working on separating Model from View. So for this transformation, I am planning as follows:

         View --->  X  <--- | ---> Server
          <  Client side  >

Assumptions:

  1. View will not have any data that is to be loaded form server.
  2. X will talk to server and get the required data. Then X will fire event.
  3. View will listen to events and update themselves accordingly.
  4. X is not an exact replica of some entity on server. X will just take those entities/ data from server and then View can request this data from X.
  5. There will be exactly one X for each View.

Now question is -- What is X called?
Options -- Model, Controller, ViewModel, Presenter, or anything else.
Or Is this very crude thing which can not have terminology?

2
  • So X and View will be client-side based?
    – Daniel
    Commented Feb 15, 2013 at 19:39
  • @Daniel - Yes, both are on client side. Basically javascript. So X is a guy sitting on client side and talking to server for data.
    – akp
    Commented Feb 15, 2013 at 19:41

2 Answers 2

1

X is most commonly called a ViewModel. Controllerless MVVM is what your implementation most closely resembles.

If your view is handling the events from X, it's similar to Model-View-Binder, kind of like Knockout.js, maybe without the declarative style.

I wouldn't worry so much about what it's called. Worry about how/if it works.

0

As far as I know, you're not following any of the MV* patterns (yet).

In (very) loose terms:

  • A View is strictly for presenting information and receiving input from the user.
  • A Controller, Presenter, or ViewModel may have business logic as well as being the go-between for the Model and the View.
  • A Model is a representation of the system's data. It might be a direct access to the data store, or it might go through a data access layer instead.

"Model" is the closest layer that X seems to be approaching. The Model layer does not need to be a direct representation of the information in the data store. It just needs to present the data in alignment with the application / business domain.

You may find Martin Fowler's article on GUI Architecture worth reading. Please note that he has updated the MVP pattern and moved it into two patterns, but you'll run across that while reading through his site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.