Design patterns were not born equal. Some of them are boring, while others are special. Do you remember your feelings after learning what the Data Transfer Object is? Don’t remember? Of course – cause you didn’t have any special feelings about it other than “It’s easy”.
What do you say about Singleton? Yeah, this is kinda interesting pattern which gave you something to talk about. Do we really need it? Can’t we just achieve the same effect with static variables? Does it make your entire application tightly coupled? Lots to discuss and share your opinion in online forums.
How about Visitor? You must have remembered those feelings when you ran into it first time. The day when you understood how the Visitor pattern works was crucial in your career – that was the moment when you realized that you were not junior software developer anymore. From that very moment you can consider yourself a mid-level person. Till when? Till you’ll be able to explain the Visitor pattern to at least three juniors. Continuos Explanation (c) might reveal though that Visitor is not exactly what you originally thought it was, but now you really get it!
But there is one pattern that has a very strange effect on people. It’s called Dependency Injection. Decoupling in action! A Customer class doesn’t need to reach out for its Orders! How cool is that! First, it gets you high just like smoking banana peels. Then it makes you a little depressed when you realize that there is always a price to pay – instead of having two simple classes Customer and Order you need to have an Inversion of Control container and should neverforget to properly annotate the injector and injectee. In the server-side Java, containers are not too bad, really. We are used to them and feel pretty comfy inside.
Oh well, why did I poured all this on you? I don’t know. But please don’t try to tell this to people who enjoy living in thes IoC worlds or else they’ll become aggressive again and will make you feel stupid for not realizing that one can’t do a proper unit testing without the DI. Do we need unit testing? OK, OK….I won’t even go there.
3 thoughts on “DI, This Special Design Pattern”
That was cool, Yakov. So, do we need testing. It’s interesting to hear about it from you.
I never said that. Please re-read this blog paying attention to what I actually said.
Thank you, I’ve read your post attentively. All I wanted to say is that it would be great to hear your opinion about the real need of Unit testing.