LoginSignup
0
0

More than 3 years have passed since last update.

Private, Protected, Readonlyなどの目的

Posted at

Private

Privateの挙動は、class内からしかそのプロパティーやメソッドが呼び出されない。
その目的は、APIの公開範囲を限定することにより、影響の範囲を限定することにある。
Privateメソッドを削除したり変更したりした時、クラスの内部だけに影響範囲が限定されていることを保証する

Protected

classの内部と、継承先にAPIの公開範囲が限定される。
これも同じく、影響範囲がそのクラスと継承先のクラスのみに限定される。

ReadOnly

値が変更されないことを保証する。

0
0
2

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