I read a lot of books about how to code right and usually they are talking about all these techniques from a point of view I can't understand.
E.g. lets consider the singleton pattern:
I'm restricting so the class can only be instantiated once, but since it's only me creating the application, if I know that the class only should be instantiated once, then why would I create it a second time?
It sounds like I'm securing against myself.
I feel like missing the big picture.
What is my main goal when coding an application?
How should I think?
Thanks.
Make it work, make it work right, make it work fast.
Most patterns introduce complexity as one price to using them. Do not add patterns if you do not need them.
In the case of singleton - if you don't have to restrict the class to one instance (and when do you really need to), don't turn it into a singleton. It only makes your code more complex and difficult to understand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With