Requriing static class setter to be called before Constructor, bad design?

Posted by roverred on Programmers See other posts from Programmers or by roverred
Published on 2013-10-19T21:46:29Z Indexed on 2013/10/19 22:13 UTC
Read the original article Hit count: 253

I have a class, say Foo, and every instance of Foo will need and contain the same List object, myList.

Since every class instance will share the same List Object, I thought it would be good to make myList static and use a static function to set myList before the constructor is called. I was wondering if this was bad, because this requires the setter to be called before the constructor. If the person doesn't, the program will crash. Alternative way would be passing myList every time. Thanks.

© Programmers or respective owner

Related posts about design

Related posts about static-methods