documentationfor yFiles for HTML 2.6

The Class Framework

yFiles for HTML comes with its own class framework implementation that provides various utility methods for writing robust JavaScript code. It provides a complete type system including classes, interfaces, basic reflection and meta-programming, and modules for building a namespaced class hierarchy, as well as other utilities.

There are only very few cases where you will actually need to use the yFiles class framework. The framework should be compatible with all major popular techniques of creating classes and instances. You may use prototypal inheritance, ES2015 classes, TypeScript classes and other techniques that use the same mechanics for inheritance.

The framework is built on ECMAScript Level 5 and has been designed to be compatible with and behave similar to the ES2015 class keyword. Apart from a few exceptions you can treat the yFiles for HTML class system as if it had been created using ES2015 classes.

The public yFiles for HTML API does not play well with the techniques of “hacking the prototype” or “hacking POJO instances”. You cannot expect your code to be correctly called by the framework if you modify the implementation of a public API member using either of these techniques. This does not affect members that you have declared and which you use yourself, of course.

The API is built around the principles of classes the way most Java and C# developers are already comfortable with. These classes are very similar to classes that can be declared using the ES2015 class keyword and TypeScript. The type system in yFiles for HTML adds to this the concepts of interfaces the way they are know from Java and C# and to a certain degree from TypeScript. Also there is support for building enumerations, attribute classes, and structures.

From a developer’s point of view the API feels like a coherent set of classes. The fact that there are other types involved only plays a role when there is the need to do more sophisticated customizations. For an introductory read you may very well skip the remainder of this chapter and come back later once you find that you need to dig deeper into the API and need to apply those more sophisticated customization techniques.