Javascript MVC example(s) wanted

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aaron Gray

    Javascript MVC example(s) wanted

    I am after opend source small, middle or large example programs thay use MVC
    pattern coded Javascript.

    Many thanks in advance,

    Aaron



  • Peter Michaux

    #2
    Re: Javascript MVC example(s) wanted

    On Jul 22, 8:27 am, "Aaron Gray" <ang.use...@gma il.comwrote:
    I am after opend source small, middle or large example programs thay use MVC
    pattern coded Javascript.
    The traditional Smalltalk MVC does translate to JavaScript reasonably
    easily. Whether or not a naive translation is a good idea is a big
    question. I don't think it is.

    Having a Data Access Layer (DAL) to encapsulate all the
    XMLHttpRequests is a good idea. This layer is the only layer that
    knows anything about HTTP or any other types of communication. This
    layer can do some processing on the returned data from the server to
    comply with the DALs stated API.

    Having a Model layer is a good idea. This is the only layer that talks
    with the DAL. The model layer knows business logic and implements the
    observer pattern.

    The part of MVC that causes me pause in the browser is the VC
    distinction. I don't really think they are very clearly separated. The
    main issue is how the strategy pattern part of MVC will be
    implemented. Because JavaScript objects are dynamic, you can replace
    property function-values of an object. This is something you cannot do
    in Java for example. I don't know about Smalltalk. So in JavaScript
    instead of replacing a reference in the view layer to a controller
    object, you can just replace a particular function of the view object
    itself. Also I don't find I take advantage of the strategy pattern
    part of MVC frequently.


    I usually design a program as

    DOM
    =============== ============
    Widget |
    ------------| bootstrap.js
    Model |
    ---------------------------
    DAL
    =============== ============
    Server


    The bootstrap.js file starts the feature testing, calls the Model to
    populate itself, calls the widgets to start themselves and sends
    references where the widget should insert itself in the DOM and
    references to models the widget should observe.

    It isn't so important that the layers do what the the traditional
    "MVC" says they should. What is important is that each layer does what
    its documentation says it does. For a very simple little widget the
    three JavaScript layers could all be combined into one object.

    Colin Moock's "Essential ActionScript 2.0" has a good discussion of
    MVC. The best one I have read. The code is not in JavaScript, of
    course, and he is very keen on classes but it is an indication of how
    programmers will likely start writing code with ECMAScript 4. I won't.
    The site of all those interface definitions. Ugg. You can download
    that code from his site. Chapter 18 and some chapters around it will
    likely be your interest.

    "MVC" doesn't seem to be a big thing in browser scripting. That could
    mean it isn't very useful or comes in such a different shape it is not
    called "MVC". I think that usually MVC is just too heavy for the
    requirements in the browser.

    Peter

    Comment

    • beegee

      #3
      Re: Javascript MVC example(s) wanted

      On Jul 22, 11:27 am, "Aaron Gray" <ang.use...@gma il.comwrote:
      I am after opend source small, middle or large example programs thay use MVC
      pattern coded Javascript.
      >
      Many thanks in advance,
      >
      Aaron
      TIBCO, http://www.tibco.com/devnet/gi/getting_started.jsp, has an MVC
      javascript framework (free). Check it out. While I agree for the most
      part with Peter Michaux's comments, there are certain problems in
      maintaining a large site with many coders that an MVC javascript
      framework solves. Features get added to pages that sometimes cause
      three or four different inputs to update or read from the same data
      object. If the original page is written using MVC, this is quite
      maintainable. Else it becomes a labyrinth, a Rube Goldberg machine
      that is extremely painful to trace.

      So, a very light MVC javascript framework can be written that can't be
      written in other languages due to the javascript features Peter
      mentioned (recursion helps too). TIBCO has an interface builder and
      it's framework is not lightweight but may help you in writing your
      own.

      Bob

      Comment

      • Aaron Gray

        #4
        Re: Javascript MVC example(s) wanted

        "beegee" <bgulian@gmail. comwrote in message
        news:7bcc8794-3113-4d09-867f-a56adec5e44e@z6 6g2000hsc.googl egroups.com...
        >On Jul 22, 11:27 am, "Aaron Gray" <ang.use...@gma il.comwrote:
        >I am after opend source small, middle or large example programs thay use
        >MVC
        >pattern coded Javascript.
        >TIBCO, http://www.tibco.com/devnet/gi/getting_started.jsp, has an MVC
        >javascript framework (free). Check it out. While I agree for the most
        Not quite what I was looking for.

        Thanks anyway,

        Aaron


        Comment

        • Todd Wade

          #5
          Re: Javascript MVC example(s) wanted

          On Jul 22, 11:27 am, "Aaron Gray" <ang.use...@gma il.comwrote:
          I am after opend source small, middle or large example programs thay use MVC
          pattern coded Javascript.
          Jemplate, a javascript implementation of perl's Template::Toolk it:



          It is very flexible and can be used in many more ways than the page
          above indicates.

          trwww

          Comment

          Working...