JavaScript Thingy
JavaScript is an Object Orientated Design (OOD) writing in
JavaScript is known as Object Orientated
Programming (OOP).
Javascript has a syntax very similar to the C programming
language just like PHP although C and
PHP are
not OOD programming languages! C++ is a version of C that is
OOD however PHP does not have one unless you see it
as Python. Classes contain Objects and
variables in the case of classes these
variables would be global varaibles available everywhere and to
everyone. You would use global variables when you want all objects in
the class to have access to it. These variables can also be called
"constants" this is where they're read only variables and can't be
changed. There is
only one type of variable in JavaScript and PHP in C there are
many! Objects
have three attributes: properties, methods and events. Properties are
the same as object level variables which means they are not global
variables they are only
available to that object you would need get/set methods to
change these variables outside the object where global varaibles can be
set
anywhere by anyone! Methods are the same as functions and procedures
are the same as sub routines everywhere there isn't any
difference! There are four types of classes but it's
the same for the objects inside those classes too! The first type is
your
general purpose
type, you create as many as you want, you can delete
them if you want you can have them inherit others even
extend their functionality if you
want! Abstract Classes or Interfaces do not have instances creating
these is
not possible other classes inherit these and extend their
functionality that is how Abstract
Classes/Interfaces work. If a programming language
uses Interfaces like
JavaScript Multiple Inheritance is irrelevant as
Interfaces
provide an alternative that doesn't have the
problem. C++ does use
Multiple Inheritance which means it does have the problem but
what
is this problem?! It is allowing you to inherit more
than one object at
the same time. Imagine you have a
system
with
a office in London, New York and Sydney. Each of these offices have an
Accounts
object. Multiple Inheritance will allow you to inherit the Accounts
objects of
Sydney, New York and London in one object. This may not
seem like a problem at first until you realise they all have a Scott
Middleton in their
accounts object
and they're not all the same person! Now you're going to corrupt
that record when you make a change to it! You see, that change will be
made to every object that contains Scott Middleton they are
not all the
same person corrupting all of them except the one you
wanted to
change. The reason Abstract Classes (Interfaces) get around this is
that every accounts object isn't an accounts object it's an
extension
of it and yours has to be the same! You don't access the
accounts
object you access the extension of it like
newyork.accounts,
sydney.accounts or london.accounts for example, if you
were to inherit the accounts object in your object, you're just
creating
another extension of it: myobject.accounts! Protected
objects are objects with only one instance permitted multiple
instances are forbidden the Document, Navigator
and Window objects/classes in the JavaScript language are examples of protected
Classes/Objects! Static/Absolute objects/classes can not be destroyed most IDE's (Integrated
Development Environments) will create one Static/Absolute
class/object for
every new project by default and this
object/class can't be deleted without deleting the
file that was created when it was created!