addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1launch-new-window--smalllight-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [lsug] Dependency Injection

From: Uberto B.
Sent on: Friday, February 15, 2013 3:46 PM

On Fri, Feb 15, 2013 at 3:19 PM, Sandro Mancuso <[address removed]> wrote:
Personal preference. I prefer to have my classes injected instead of creating classes by hand, create constructors and pass the classes around. I'm quick lazy so the less code I write, the better. :)

;) good point.

Doing it by hand is a good thing since every time you want to inject another collaborator into a class you will need to add it to the constructor. This will make you think twice if the class receiving the new collaborator is doing too much. And that's good. Since I already have that in mind, I'm OK with that. 

Yes I'm also lazy so this force me to keep dependecies low. 

From the TDD perspective, I can't really see how much it matters. I always test-drive my code in Java and that was never a problem since Mockito works well with the Spring @Autowired annotation, allowing to write my tests already thinking how classes will be collaborating.  

Sure, it's not a problem using a DI framework in TDD, but if I start in TDD I hardly feel the need of it.
Instead if I'm working in a brownfield project is easier to use a framework to introduce some DI in badly designed classes, comparing to changing their constructor(s).

I'm just starting using scala now, so I was interested in your opinion. Thanks.


Our Sponsors

  • Scala Dojo

    Web site for monthly Scala Dojo

  • Scala Jobs

    Google Group of Scala Jobs in the London Area

  • _.underscore

    Scala consultants, trainers, and developers, based in London, UK

  • Springer

    Help and supporters of the monthly dojo

  • Skills Matter

    Provide the venue for many of our meetings.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy