When I want to make a method final, first of all I ask myself:Should this method be final?The answer is obvious sometimes, for example imagine this:class Dog{    private $name;    public function __constructor($name)    {        this->name = $name;    }    final public function getName()    {        return this->name;    }}The getName method should obviously be final.Some guys ask why this is obvious? See this example:class DogsSchool{    private $registredDogs = [];    final public function registerDog(Dog $dog)    {        this->registredDogs[$dog->getName()] = $dog;    }}If people change the name of the dog in non-constructor methods for example in getName method, You can't register the dog in any collection like DogsSchool, You can't identify the dog cause the ID (here is the name) can be changed anytime. this will break your application. and also in the real world identifiers are final, Can you change your ID number after your birth? (birth = constructing in OO)OK, no problem, BUT! I am getting confused sometimes! for example imagine this:class SelectMany{    public function selectManyAndReturn()    {        return selectMany();    }}Overwriting the selectManyAndReturn method can change the behavior of the class, people can overwrite it and run selectOne for example instead of selectMany, OK, I can make this method final also to prevent this, but by this way I am also preventing people form adding new features to the method, for example if I make the method final, I am not able to write a new child class like this one:class SelectManyApple extends SelectMany{    public function selectManyAndReturn()    {        return selectManyApple();    }}What should I do? Is forgetting final and private methods completely good idea? like many applications and many programming languages? or Can you tell me when exactly we should make a method final?The question is language agnostic. It's about the general principle that I should use to write good OO programs.
When to use final methods?
object oriented;object oriented design