Skip to content

Basic rules

ALexeyP0708 edited this page Jul 5, 2020 · 2 revisions

Basic rules for creating code when using the interface

  1. Technology Interfaces is written according to the rules of declaring class (constructor creation) - class NameClass {}. Applying interfaces to other logic of class formation (constructor) and / or creation of objects does not guarantee the correct execution of the code.
  2. Classes that implement interfaces must be immutable. Class members for which interface rules are defined should not be changed after class is declared and interface rules are generated.
  3. Interfaces must be immutable.
  4. interface rules must be immutable.
  5. Class members, to which interface rules will be applied, will be changed (the descriptors will be redefined), and the execution will take place in the sandbox. A set of rules will be stored in the class itself. The following rule follows from this.
  6. Classes to which interfaces should be applied and their prototypes should not be frozen and sealed, and declared class members must have the following settings for the {configurable: true, writable: true} descriptors.
  7. Interfaces are for development. The production version should be able to exclude interfaces from the code (exemple). Therefore, the implementation of interfaces and checks on interfaces should not be mixed with the main code.

Clone this wiki locally