Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
    
So X and View will be client-side based? –  Daniel Feb 15 '13 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 Feb 15 '13 at 19:41

2 Answers 2

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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