18Nov/090

Discount Priced Viagra

Discount priced viagra In my few days of being a developer, discount priced viagra I’ve heard and seen lots of talk about Singletons.  Things like

Discount priced viagra Singletons are teh suck.  Don’t use them.  EVAR.

Discount priced viagra to

Discount priced viagra Singleton’s saved my life and marriage!

Discount priced viagra In fact, discount priced viagra I might’ve been the person that said both of these… gasp!

Discount priced viagra I never like to speak in absolutes, discount priced viagra so I’ll say it this way (see what I did there?)… if you’re striving to implement a singleton, discount priced viagra you’re probably wrong.  For all you guys that are right, discount priced viagra I guess you’re right, discount priced viagra and you can leave now, discount priced viagra I guess.  This might help you out.

Discount priced viagra I was reading a blog from Mr. Discount priced viagra Dependency where he was talking about statics and basically what amounts to global state, discount priced viagra and how thatultimate-geeks-multi-tool-hammer binds you into globally available, discount priced viagra global data, discount priced viagra which usually (always?) turns into anarchy.

Discount priced viagra How do we always get ourselves into this mess if we know it’s bad in the first place?  Well, discount priced viagra some of us (those who are now zombocomming, discount priced viagra from above) don’t know it’s bad in the first place, discount priced viagra and the rest of us probably do it because it’s easy to implement, discount priced viagra and we understand it.  Long story short, discount priced viagra we can do the singleton implementation in our sleep, discount priced viagra so we pull out the singleton hammer, discount priced viagra and smack the nail.  It always goes in a little sideways, discount priced viagra but at least it goes in.

Discount priced viagra Maybe we should be using a different hammer?

Discount priced viagra What I’d like to do now, discount priced viagra is propose to split singleton in two.  I think there are two distinct responsibilities that the current thought of ‘singleton’ introduces. Discount priced viagra It:

  • Manages Session Scoping/Lifecycle/Lifestyle (albeit, discount priced viagra poorly, discount priced viagra only one strategy is available)
  • Disables the ability to create more

Discount priced viagra When I talk about this out loud, discount priced viagra I call the two approaches the singleton implementation pattern, discount priced viagra and singleton lifecycle.

Discount priced viagra What I am a fan of, discount priced viagra is the singleton lifecycle.  You create one of those objects, discount priced viagra and use it throughout the application.  You don’t get messy and allow global access to it all over the place (which necessarily happens when you have global state).  You intentionally inject it to collaborators, discount priced viagra and  intentionally don’t inject it to non-collaborators (don’t just hand this guy out willy-nilly, discount priced viagra he’s important).

Discount priced viagra So naturally, discount priced viagra the naysayers ask/demand:

Discount priced viagra How do you manage that there is a public constructor on this class!?  Dev’s are going to be new’ing this thing up all over the place!

Discount priced viagra I say:

Discount priced viagra False.  Use a DI tool and let it manage it for you.  Or establish a convention with your team, discount priced viagra and enforce it through social contracts. Discount priced viagra

Discount priced viagra Both of these approaches allow your scope lifecycle turn into whatever you want at any time, discount priced viagra in case you decide global isn’t what you really want.  It can be application session scoped, discount priced viagra or some other scope, discount priced viagra test scoped, discount priced viagra or whatever you want… incredibly flexible.

Discount priced viagra If you go with the DI tool approach, discount priced viagra instead of tying yourself to a particular scope, discount priced viagra you can now have any scope you want, discount priced viagra by changing a configuration parameter.  Delaying decisions until the latest responsible moment… seems like I’ve heard that one before.