Skip to content
This repository has been archived by the owner on Sep 30, 2018. It is now read-only.
Valerii Zinchenko edited this page Oct 2, 2016 · 2 revisions

Why?

First of all I came into the JavaScript world (Front-End) after few years work with C++. I like C++ and it has a lot of cool features. Some features regarding defining a class I am missing in JavaScript and started to develop them. After few years of developing SPAs I have tried few JavaScript frameworks which helps to define a class and was always faced with the following issues:

  1. Parent's constructor is not called.
  • Workaround. Explicitly call a parent's constructor from a constructor of a new class.
  • My point of view. From first look I thought that it is a good point that I can control when it should be called: at the beginning, somewhere in the middle, at the end of a constructor for a new class. But still, something I didn't like and after deeper analysis of that code I came to the conclusion that it was incorrectly designed. The usage of like a free position of it is more a dirty hack that works. As far as I remember C++ calls all parent's constructors before the constructor of a new class will be executed.
  1. Sharing of properties which are objects (Object, Array).
  • Workaround. By designing a new class set the value to that properties to null and create them in the constructor.
  • My point of view. I understand why it works so, but I don't want this behavior when I am defining a class. I want to define the structure, behavior and properties with default values of a class, I don't want to work with a real objects at that time.

I am expecting that some of the readers will disagree with the point about the calling of a parent's constructor. If you are one of them - let's review your design. I would glad to do this :) Just send me an email and we will discuss it.

Documentation:

Clone this wiki locally