Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
If you're asking this question, then you don't have a deep (or any) understanding of Object Oriented Programming.
A class variable (or static properties) should be used only if in your task what it stores should be the same for all objects (Actually, the singleton (anti) pattern can be an example ). And yes, if you are interested, then class variables are used several orders of magnitude less often.
An object variable, as you might guess, when each object must be independent. And there are many more such cases.
In general, remember, static is global state, and global state is bad. So think very carefully before using it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question