473,750 Members | 2,194 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3768
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
Jul 22 '08 #2
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
Jul 23 '08 #3
"beegee" <bg*****@gmail. comwrote in message
news:7b******** *************** ***********@z66 g2000hsc.google groups.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
Jul 25 '08 #4
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:

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
3624
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 type="text/javascript">) to run? I'm asking because the following chunk of code (drop down menu that goes to different parts of the page) works without declaring anywhere that it's javascript:
6
2281
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 as computer hardware, configuration, etc... down to the lowest level (e.g. BIOS, assembly language, etc). Anyway, I've obviously got something wrong with JavaScript configuration, files, etc. in Windows 2000, Service Pack 3, because on sites...
21
66845
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 are the other approaches. please advise. thanks!!
136
9437
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
11
2784
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 < or several others, it converts them to html, such as &amp; or &lt; which can sometimes cause my scripts not to work. How can I prevent ASP.NET from doing this? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
10
12804
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 involving variable scope in JavaScript.) I have a lot of code that generates HTML on the fly. This code has tags with id attributes derived from variables. A small example: blah('<span id="' + dev + '_' + mod + '">...</span>');
1
25695
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 bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that variable can only be used in that function. If you were to try to access that variable anywhere else in...
12
8921
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 JavaScripter, can anyone think of anything else. Is anyone familiar with anything similar already done. Things that I am thinking that to provide are:
4
3121
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, context){}, onStopRequest: function(request, context, status){ instream.close(); outstream.close(); listener.finished(this.data);
0
8999
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9338
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.