Why put private fields and methods at the top of class?

It stems from the days when you had to declare everything—that includes functions as well as variables—before you could use them.

The internal (private) variables and functions went at the top of the file and the external (public) functions went at the bottom of the file. This meant that the public functions could reference the internal functions. If you had recursion, you would have to forward reference the function by declaring its profile.

When languages allowed the code to span several files, you had to put public function and variable declarations into header files so that they could be included in the other files in the project—or indeed other projects.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)