42 - Extended Objects

The examples 101 to 605 all model a person's name with extended objects. The entities are First, Last, and Full names. With each entity also having an associated method; firstMethod(), lastMethod(), and fullMethod(). Full inherits behavior from Last, while Last builds on First. The extended objects can be classes, closures, IIFEs, classFree objects, prototypes, or OLOOs. The examples of 105,205,305,405,605 are in /examples-node.js/ as they can only be run in Node.js.

Checking functions can be toggled on and off with either the inclusion of TypeCzech.js or a boolean variable.

Each function, method, or constructor has its own PRE_checking and POST_checking functions.

There is no 104 example, as this would be a blizzard of if statements because classes are not hoisted and would have to be interleaved with TypeCzech checking functions that in turn would have to be togglable.

  Classes Closures IIFEs ClassFree Prototypes OLOOs
One file containing extended objects and TypeCzech checking functions.

Function checking is toggled on and off with the inclusion of TypeCzech.js.
 
101 201 301 401 501 601
Seven separate files with extended objects and TypeCzech checking functions in their own files.

A boolean controls the loading of files and TypeCzech.js.
 
102 202 302 402 502 602
Four files with extended objects packaged together with their corresponding TypeCzech checking functions.

A boolean controls TypeCzech function checking.
 
103 203 303 403 503 603
Two files with extended objects in one html file and TypeCzech checking functions in another Javascript file

Function checking is toggled on and off with the inclusion of TypeCzech.
 
not realistically useful 204 304 404 504 604
Six Node.js files with extended objects packaged together with their corresponding TypeCzech functions. Examples are inside of /examples-nodejs/
 
105 205 305 405 505 605
The class version of extended objects
class First { 
  constructor(f_name) { 
    this.f_name = f_name 
  }
  firstMethod(a_date) { 
    return a_date
  }  
}

class Last extends First{  
  constructor(f_name, l_name) {
    super(f_name);
    this.l_name = l_name
  }
  lastMethod(a_year){ 
    return a_year
  }
}

class Full extends Last {
  constructor(salu, f_name, l_name) { 
    super(f_name, l_name);
    this.salu = salu
  }
  fullMethod(a_book){
    return a_book
  }
  showName() { }
}
LinkUp() of First class and firstMethod()

First_PREs = { First: PRE_check_First, 
               firstMethod: PRE_check_firstMethod }
First_POSTs = { First: POST_check_First, 
                firstMethod: POST_check_firstMethod }

First = type_czech.linkUp(First, First_PREs, First_POSTs)