0
0

More than 5 years have passed since last update.

Object Orientation オブジェクト指向

Posted at

Object Orientation

Notice

You should change your recognition.
1. Package => Class
2. Subroutine of Package => Method of Class

Reading

There is car manufacture(Class). Pushing car generating button(Constructor), car(Object) is generated.
Car can run ahead and chime klaxon(Method).
And it can load burden and understand own location information(Insert value into reference).

When you want another car, you can get another one(Object) by pushing the button(Constructor).
The car(Object) has it own having.
So nobody cannot interfere(Capsulize).

Changing something in car manufacture(Global variables in Name Space or something) make effects on all cars(but the effect is only in the name space).

For example, if there is parking lot in the manufacture(Global variables in name space), parking(method) makes vacant spaces decreased.

Notice2

  1. You cannot call method(subrountine) which starts with '_' by '->' from outer of the class.
    e.g) Never call $obj->_hoge; from main package.

  2. You cannot directly edit object's value(value of reference).
    e.g) Never operate like $obj->{huge} = "bar"; from main package

  3. You cannot edit global variables which is in name space of class.
    e.g.) Never $package_name::hoge = "bar";

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0