The logic inside the constructor

Is it good to have logic inside __constructor?

public class someClass
{
    public function __construct()
    {
        //some logic here
    }

Until now, I thought that everything was in order; however, this reddit comment points to the opposite.

+4
source share
3 answers

As @Barry wrote , one of the reasons is unit testing, but this is just a side effect.

: "", (, , ). ... ? , - , , , . . .

: , , . .

" " - . , , -- (, ). , , .

, / . (, , PoLA. , , , , . , .

: " ". (, eval() ), .

+4

, . "" , , . , , , .

, (google tech talk by Misko Hevery) https://www.youtube.com/watch?v=RlfLCWKxHJ0

+3

, , , __construct - , , ? , . Symfony Response - , , . - - ( )...

, , - ...

SOLID ...

+1

All Articles