473,394 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

Jul 22 '08 #1
4 3750
On Jul 22, 8:27 am, "Aaron Gray" <ang.use...@gmail.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
Jul 22 '08 #2
On Jul 22, 11:27*am, "Aaron Gray" <ang.use...@gmail.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
Jul 23 '08 #3
"beegee" <bg*****@gmail.comwrote in message
news:7b**********************************@z66g2000 hsc.googlegroups.com...
>On Jul 22, 11:27 am, "Aaron Gray" <ang.use...@gmail.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
Jul 25 '08 #4
On Jul 22, 11:27 am, "Aaron Gray" <ang.use...@gmail.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::Toolkit:

http://search.cpan.org/~rkrimen/Jemp...ib/Jemplate.pm

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

trwww
Jul 29 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Andrea | last post by:
Hi everyone, I am in the process of learning javascript and have a question on location.href. Does javascript always require the <script language = "javascript"> (or script...
6
by: Alex Rast | last post by:
First of all, this is not a programming question. I'm a user, not programming in JavaScript. I'm not, however, a novice user or even a power user - I certainly know programming intimately as well...
21
by: strutsng | last post by:
<input type="file"> only allows the user to browse for files. How about "browse for folder" dialog? Can html/javascript do that? I couldn't find any syntax for that. If not, please advise what...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
11
by: Nathan Sokalski | last post by:
I add several JavaScript events (onchange, onkeypress, etc.) to Controls using the Add method of the Attributes collection. However, if the JavaScript code contains certain characters, such as & or...
10
by: John Passaniti | last post by:
(Note: This is not the same message I posted a week or so ago. The problem that prevented my previous attempt to work was a silly error in the template system I was using. This is a problem...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
12
by: pantagruel | last post by:
Hi, I'm thinking of making a WScript based JavaScript library, I can think of some specific non-browser specific scripting examples that should probably make it in, like Crockford's little...
4
by: Joe Hrbek | last post by:
Could someone help me translate to something that would close to it in python? The anonymous functions are giving me problems. var dataListener = { data : "", onStartRequest: function(request,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.