|
Page 3 of 3
Class Diagrams
JavaScript classes, just like C# or VB.NET classes, can be described visually using class diagrams. There are standards such as UML (Unifi ed Modeling Language), that can be used to model classes and the relationships between them. In this book we'll show quite a few class diagrams using the notation used by Visual Studio 2005.
Using this notation, the HelloWorld class shown earlier would be described as shown in Figure 3-2.

Figure 3-2. HelloWorld class diagram
The diagrams to this book follow typical conventions for C# classes, which don't translate to JavaScript exactly. For example, the diagram in Figure 3-2 says that the HelloWorld class has an integer field named hour.
However, JavaScript doesn't support specifying data types for variables or class fields. The data type of the field makes the diagram helpful in specifying the intended purpose and type of the field, but that type isn't used in the actual implementation of the class.
The diagram also mentions the HelloWorld() constructor, which receives an integer parameter. As you know, JavaScript doesn't support "real" constructors. However, by reading the diagram you can tell that the HelloWorld() function receives a parameter named hour, which is supposed to be an integer value.
Appendix A contains more details about the conventions used in class diagrams throughout this book
Trackback(0)

|