I have seen users in SO saying that protected fields are bad because it can cause problems as code grows. See the following code.
public class Car {
private String modelName;
private int yearReleased;
}
If the Car class is extended by a class named ToyotaCar
public class ToyotaCar extends Car{
}
I want my ToyotaCar facility to have fields modelNameand yearReleased. That's why I decided to leave the Car class. But private members are not inherited by the subclass (although I could access these fields using the public getter and setter). Now, my confusion is whether I should make stickers in the Car class secure, not private. But people say that this creates problems.
Does this mean, regardless of which class you always write, make the fields private?
, protected? , ?