Is constructor a good practice?

Constructors are meant to initialize the data fields in the object. Given the choices, the second approach seems more correct. Although what might be better is to include the doDFS method in your graph object. It’s usually bad practice to create an entire class for a single simple function .

Sizin İçin Seçtik  How do you declare a constructor in node JS?

Leave a Reply

Your email address will not be published. Required fields are marked *