Pseudo classical, prototypal and functional

– functional inheritance -> prototypal inheritance –> pseudo classical inheritance –> hacked classical inheritance

Functional inheritance

– Functional can be achieved by any language who supports closure scope and dynamic object augmentation.

– The bad parts are duplicated properties and methods / impossible to achieve dynamic class modification.

– The good parts are: real private variables / callable instances.

Pseudo classical inheritance

– For pseudo classical, semi private variable is achieved by name convention, i.e. _variable_name.

– Comparison among pseudo classical, prototypal and functional

pseudo classical prototypal functional
start out simple no sort of yes
keep simple no yes yes
Method sharing Method sharing Method sharing with a performance penalty or capability security
Dynamic class modification Dynamic class modification Avoid using ‘this’
instanceOf works at all level instanceOf works at all level callable instance / instanceOf doesn’t work at all level / no prototypal masking
Optimized by the engine Avoid using ‘new’ and ‘.prototype’ Avoid using ‘new’ and ‘.prototype’

One thought on “Pseudo classical, prototypal and functional

  1. Pingback: Day 8, dancer party sprint | Shao

Comments are closed.