Category Archives: JS++

JS++ | The ‘final’ Modifier

In the context of virtual methods discussed in the previous section, the ‘final’ modifier allows us to form an even more correct specification. When applied… Read More »

JS++ | Subtype Polymorphism

Subtyping describes type relationships, and subtype polymorphism enables operations defined for supertypes to be safely substituted with subtypes. Concretely, imagine the relation between a ‘Cat’… Read More »

JS++ | Virtual Methods

As we mentioned in the previous section, if we want runtime polymorphism, using casts can lead to unclean code. By way of example, let’s change… Read More »

JS++ | Upcasting and Downcasting

Now that we understand both subtyping and static versus dynamic polymorphism, we can learn about upcasting and downcasting. Upcasting and downcasting is based on type… Read More »

JS++ | Inheritance

So far, the only type of animal we’ve defined is a cat (via the ‘Cat’ class). Our ‘Cat’ class also requires us to name our… Read More »

JS++ | Constructors

In our cat example, we’ve been able to instantiate our cat and provide a name separately. However, it may be desirable to require the cat… Read More »

JS++ | Getters and Setters

In our previous example, we defined a ‘setName’ method that sets a class ‘name’ field we declared. A method whose sole responsibility is to write… Read More »

JS++ | Fields and Methods

Creating and Rendering an Animal Open ‘src/Animals/Cat.jspp’ and enter the following code: external $; module Animals { class Cat { void render() { var $element… Read More »