Skip to content

Category Archives: JS++

Promises are used to handle asynchronous operations in JavaScript. They are easy to manage when dealing with multiple asynchronous operations where callbacks can create callback… Read More
Up until now, all of the fields and methods that we’ve declared have belonged to class instances. Static members can also be added to a… Read More
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
As we learned in the chapter on subtype polymorphism, an operation defined for a supertype can be safely substituted with its subtypes. As a result,… Read More
We’ve made our ‘Animal’ class abstract. We’ve declared an abstract ‘talk’ method and implemented this method in all subclasses of ‘Animal’. However, our animals don’t… Read More
We have explored virtual methods and ‘overwrite’ (early binding) and ‘override’ (late binding) which allow us to define base implementations for a method and more… Read More
Access modifiers allow us to change the “visibility” and “access privileges” of a class (or module) member. These are best understood by example. JS++ has… Read More
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
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
Static polymorphism is polymorphism that occurs at compile time, and dynamic polymorphism is polymorphism that occurs at runtime (during application execution). An aspect of static… Read More
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
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
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
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
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