473,748 Members | 9,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Class diagrams for javascript

Hello All,

is there any handy tool to generate class diagrams for javascript? I
have tried JS/UML, but it generates always an empty diagram.
--
Xu, Qian (stanleyxu)
http://stanleyxu2005.blogspot.com
Jun 30 '08 #1
6 3211
Thomas 'PointedEars' Lahn <Po*********@we b.dewrites:
Xu, Qian wrote:
>var Utils = {}
Utils.somethin g = function() {...}
....
BTW, as `Utils' cannot be used as a constructor reference, it should be `utils'.
Well, there is the precedent of "Math" :)

/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 30 '08 #2
Thomas 'PointedEars' Lahn wrote:
Xu, Qian wrote:
>var Utils = {}
Utils.somethin g = function() {...}

Why, I wonder how you would set up *inheritance* *easily* with *that* pattern.

BTW, as `Utils' cannot be used as a constructor reference, it should be `utils'.
This is a static class library.
For inheritance, I use

function TDescent(/*args*/) {
TBase.call(this , /*args*/);
//...
}
TDescent.inheri tsFrom(TBase);
Function.protot ype.inheritsFro m = function(parent Class) {
this.prototype = new parentClass;
this.prototype. constructor = this;
this.prototype. __parentClass = parentClass;
return this;
}

It works perfect for me.

>I found an eclipse based tool "aptana". It can parse my code properly,
but no class diagram generation.

But what would/could you need this for?
I want to make some nice class diagrams for my thesis. aptana is an
excellent web-app editor.
--
Xu, Qian (stanleyxu)
http://stanleyxu2005.blogspot.com
Jul 1 '08 #3
"Xu, Qian" <qu******@stud. tu-ilmenau.dewrite s:
For inheritance, I use

function TDescent(/*args*/) {
TBase.call(this , /*args*/);
//...
}
TDescent.inheri tsFrom(TBase);
Function.protot ype.inheritsFro m = function(parent Class) {
this.prototype = new parentClass;
this.prototype. constructor = this;
this.prototype. __parentClass = parentClass;
return this;
}

It works perfect for me.
I would question the line
this.prototype = new parentClass;
It means that you run the "parent" construcor function twice:
once in this line, and once in the actual constructor using "call".

It would be more correct to clone the parentClass prototype, i.e.,
this.prototype = clone(parentCla ss.prototype);

where clone is defined as something like:
function clone(object) {
function Cloner(){};
Cloner.prototyp e = object;
return new Cloner();
}

/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 1 '08 #4
Lasse Reichstein Nielsen wrote:
I would question the line
this.prototype = new parentClass;
It means that you run the "parent" construcor function twice:
once in this line, and once in the actual constructor using "call".

It would be more correct to clone the parentClass prototype, i.e.,
this.prototype = clone(parentCla ss.prototype);

where clone is defined as something like:
function clone(object) {
function Cloner(){};
Cloner.prototyp e = object;
return new Cloner();
}
Thanks for your advise. ^^)

--
Xu, Qian (stanleyxu)
http://stanleyxu2005.blogspot.com
Jul 1 '08 #5
Xu, Qian wrote:
Thomas 'PointedEars' Lahn wrote:
>Xu, Qian wrote:
>>var Utils = {}
Utils.somethi ng = function() {...}
Why, I wonder how you would set up *inheritance* *easily* with *that* pattern.

BTW, as `Utils' cannot be used as a constructor reference, it should be `utils'.

This is a static class library.
No, it is not. As is said twice before now, there are no classes. So there
are also no static classes.
TDescent.inheri tsFrom(TBase);
Function.protot ype.inheritsFro m = function(parent Class) {
this.prototype = new parentClass;
this.prototype. constructor = this;
this.prototype. __parentClass = parentClass;
return this;
}
I use a similar pattern but there is still no class. If TDescent() was used
as a constructor (with `new') an object would be created that inherits from
another object (the object TDescent.protot ype refers to) through its
prototype chain, not from a class. And the other object again inherits from
yet another next object in its prototype chain, which supposedly inherits
from the object that Object.prototyp e refers to. (There you have the
fundamental difference between class-based and prototype-based inheritance.)

With your code, you are setting up the following prototype chain:

new TDescent() ---new TBase() ---... ---Object.prototyp e

When it should have been

new TDescent() ---TBase.prototype ---... ---Object.prototyp e

That is, with the current pattern TDescent objects inherit from a newly
created TBase object (not only with the properties they inherit from their
prototype, TBase.prototype , but with any modifications made to them in the
TBase() constructor). This can have undesired side-effects:

function TBase(foo)
{
if (!foo) this.bar = 42;
}

TBase.prototype = {
constructor: TBase
};

Now, since you essentially use

TDescent.protot ype = new TBase();

all objects created with the constructor `TDescent', like

var o = new TDescent();

would have the `bar' property although it is not defined in TBase's
prototype object.

Hence Lasse's correctly recommending (again) to "clone" the prototype object
instead, IOW inserting a dummy object with no additional properties in the
prototype chain that has TBase.prototype as its prototype:

new TDescent() --new Cloner() --TBase.prototype --...
--Object.prototyp e
For inheritance, I use

function TDescent(/*args*/) {
TBase.call(this , /*args*/);
//...
}
This is a constructor for an object in which another constructor is called.
No classes here.
>>I found an eclipse based tool "aptana". It can parse my code properly,
but no class diagram generation.
But what would/could you need this for?

I want to make some nice class diagrams for my thesis. aptana is an
excellent web-app editor.
The quality of Aptana is not under discussion here. The languages you are
writing your code in (ECMAScript Ed. 3 implementations ) simply do not use or
provide class-based inheritance. You can emulate that to a certain degree,
but it will never be the same. A simple example:

var o = new TDescent();
o.answer = 42;

Now `o' has a property named `answer' although you would misguidedly
probably say it is an "instance of the class TDescent".

<http://javascript.croc kford.com/inheritance.htm l>
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Jul 1 '08 #6
Thomas 'PointedEars' Lahn wrote:
Xu, Qian wrote:
>TDescent.inher itsFrom(TBase);
Function.proto type.inheritsFr om = function(parent Class) {
this.prototype = new parentClass;
this.prototype. constructor = this;
this.prototype. __parentClass = parentClass;
return this;
}

I use a similar pattern but there is still no class. [...]

With your code, you are setting up the following prototype chain:

new TDescent() ---new TBase() ---... ---Object.prototyp e

When it should have been

new TDescent() ---TBase.prototype ---... ---Object.prototyp e
Sorry, should have been

new TDescent() --TDescent.protot ype --TBase.prototype --...
--Object.prototyp e
[...]
Hence Lasse's correctly recommending (again) to "clone" the prototype object
instead, IOW inserting a dummy object with no additional properties in the
prototype chain that has TBase.prototype as its prototype:

new TDescent() --new Cloner() --TBase.prototype --...
--Object.prototyp e
Should have been

new TDescent() --TDescent.protot ype --new Cloner() --TBase.prototype
--... --Object.prototyp e
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jul 1 '08 #7

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

Similar topics

2
4716
by: Irlan agous | last post by:
Hello all, I suppose many people use unl for modeling. Does anybody know a free good uml tool to make sequence diagrams, from the use cases? I have use cases described, but i need a tool that can put them into a sequence diagram Irlan
6
34169
by: Clay Beatty | last post by:
When you create database diagrams in Enterprise Manager, the details for constructing those diagrams is saved into the dtproperties table. This table includes an image field which contains most of the relevant infomation, in a binary format. SQL Enterprise manager offers no way to script out those diagrams, so I have created two Transact SQL components, one User Function and one User Procedure, which together provide a means to script...
4
2382
by: clintonG | last post by:
I'd like to know about application(s) or the name by which the following process is referred which would allow a business analyst to enter the following statements which when submitted would result in the generation of class library members... "Are you an individual person not working?" if no, ask "have you ever worked for an employer?" if no, ask "Are you thirteen years of age or younger?" ...
0
1069
by: Ole Hanson | last post by:
Hi In the java-world (Eclipse IDE), it is possible to create Class Diagrams from your code and enter this into the documentation (called JDoc). JDoc is simular to NDoc, but to my knowledge NDoc does not support insertion of images into the final chm-files? How can one generate class diagrams (in VS.NET 2003!) and insert these into the chm-files?
3
2483
by: Alberto | last post by:
I have the professional version of visual studio 2005 and I'd like to know if I can create associations between classes in the classes diagram. Thank you.
6
4704
by: Paul McGuire | last post by:
Back in the mid-90's, Kees Blom generated a set of railroad syntax diagrams for Python (http://python.project.cwi.nl/search/hypermail/python-1994q3/0286.html). This pre-dates any Python awareness on my part, but I'm sure this would have been version 1.3 or something. For those who are not familiar with railroad syntax diagrams, they show a grammar's syntax using arrows and blocks, instead of BNF - here's an excerpt from the Python...
5
1829
by: __PPS__ | last post by:
Hello all, I was working on someone else's code to implement some classes. The task seemed to be simple and I was confident that I won't spent alot of time on that task... But! I've already spent more time to integrade old working code with new design than it would take me to write it all from scratch! so... after having tons of headaches I desided to figure out what's wrong with the design (or me) and why it's all so complicated.
5
2336
by: bob | last post by:
Hi, I'm looking for a tool (preferable with a gui but thats not essential) that will generate my class header and .cxx file. i.e. I tell the tool that my class is to have attributes x,y,z, of type a, b, c etc. and it will generate the header and .cxx... i.e. essentially to save me time each time I have to add a new class to my project. I'm on windows with borland c++ builder.
4
2156
by: Ole Nielsby | last post by:
In the old ages when I was taught Pascal, the manual had nice syntax diagrams. Each grammatical structure was shown as round boxes connected by arrows, with a model railway look, with the boxes representing either lexical tokens or other diagrams (i.e. terminals/nonterminals). They seemed very intuitive because you could toot-toot one finger along the rails in the book while moving another finger over your code. Does anything similar...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4599
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
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
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
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
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.