Backdraft Blog

Public, Protected, and Private Names in Backdraft Classes

May 10, 2018 by Rawld Gill

There are lots of ways to handle the problem of defining public, protected, and private names in JavaScript classes. Axel Rauschmayer has written about this subject lucidly in a couple of his books here and here. The great thing about Axel's writing is that he presents all of the techniques in one place, complete with an analysis of the pros and cons of each. If this subject is new to you, I strongly recommend reading these sections (and purchasing the books to keep more great content from Axel coming).

The core of the problem is to define data and/or names that are somehow hidden from somebody or something. In order to decide which technique is best, you need to understand what you are trying to hide (a name or data) who you are hiding from (a person or other program code), and why you are trying to hide it in the first place.

Read More