 around the %in% and '[[1]]' to return the first and only column of DF2 as a vector rather than a list.)

 Q:

Property Injection without attributes using Ninject in an abstract base controller in MVC3

I have the following code:
public abstract class BaseController : Controller
{
    public IUserService UserService { get; set; }
}

All my controllers inherit from this base controller. I started out by configuring it in Ninject using the following code:
kernel.Bind<BaseController>()
     .ToSelf()
     .WithPropertyValue("UserService", x => x.Kernel.GetService(typeof(IUserService)));

This did not work. I assume it is because of the fact that the BaseController is an abstract class (please confirm my assumption). So I moved on to modify the configuration to:
kernel.Bind<HomeController>()
     .ToSelf()
     .WithPropertyValue("UserService", x => x.Kernel.GetService(typeof(IUserService)));

This does work. The minor downside is that I now have to configure every controller the same way.
Since I also have DependencyResolver setup in my ASP.NET MVC 3 project I could also remove the above Ninject configuration and modify my base controller to look like:
    public IUserService UserService
    {
        get
        {
            return DependencyResolver.Current.GetService<IUserService>();
        }
    }

Is there any benefit to using the fluent configuration as opposed to using the DependencyResolver approach? Is one better than the other? Which approach would be considered a better practice?
It is worth mentioning that I did not want to do constructor injection in my base controller.

A:

A better practice in MVC it is to use constructor injection over property injection. Why did you make your choice like this?
Using Constructor Injection you states that all dependencies in constructor are necessary for the class to do its job.
Property injection means that the dependencies are optional or that there are the local defaults implementations, so all will work even if you don't provide necessary implementations yourself.
You should really know what you're doing using Property injection or you have no other choice, so the safer approach is to rely on constructor injection.
Now I'll give you my point of view. Other may have other opinions.
around the% in% and' [ [ 1 ] ]' to return the first and only column of DF2 as a vector rather than a tilt .) 

  Q: 

 Property Injection without property using Ninject in an abstract base control in MVC3 

 I own the following code: 
 public abstract class BaseController: Controller 
 { 
     public IUserService UserService { get; set; } 
 } 

 All my accountant inherit from this base controller. I start out by configuring it in Ninject using the following code: 
 kernel. Bind < BaseController > () 
      .ToSelf () 
      .WithPropertyValue("UserService ", x = > x. Kernel. GetService(typeof(IUserService) )); 

 This did not sour. I assume it is because of the fact that the BaseController is an abstract class (please confirm my presumption). therefore I moved on to modify the configuration to: 
 kernel. Bind < HomeController > () 
      .ToSelf () 
      .WithPropertyValue("UserService ", x = > x. Kernel. GetService(typeof(IUserService) )); 

 This does work. The minor downside is that I nowadays have to configure every controller the same room. 
 Since I also have DependencyResolver setup in my ASP.NET MVC 3 project I could besides remove the above Ninject shape and modify my base controller to look like: 
     public IUserService UserService 
     { 
         catch 
         { 
             return DependencyResolver. Current. GetService < IUserService > (); 
         } 
     } 

 Is there any benefit to using the fluent configuration as opposed to use the DependencyResolver access? Is one better than the other? Which approach would be considered a better practice? 
 It is deserving mentioning that I did not desire to do constructor injection in my infrastructure control. 

 A: 

 A better practice in MVC it is to use builder injection over property injection. Why did you do your choice like this? 
 Using Constructor Injection you express that all dependencies in constructor are necessary for the class to do its job. 
 Property injection think of that the dependencies are optional or that there are the local defaults implementations, therefore all will work even if you don't supply necessary implementations yourself. 
 You should really know what you're doing using place injection or you have no other choice, so the safer approach is to rely on constructor injection. 
 Now I'll give you my compass point of view. early may have other opinions.
 arlund the %in% and '[[1]]' to retuvn the first and only cmlumn kf DF2 as a vector rather than a list.)

 Q:

Propeety Injection without xttributed using Binjtct in an abstracv base controlmcr in NVC3

I have the nollowing cmde:
public abstsazt class BaseController : Controller
{
    publiv LUserService UferStrvyce { get; set; }
}

All my controllers inherif from uhis base controllrr. I started out by configkrinh it in Ninject uslng the foloowigt code:
kernel.Cind<BaseController>()
     .ToSelf()
     .WithPropertyValue("UsdrSerrice", x => x.Ketuwl.GfjService(typeif(IUsvrService)));

This did not work. I assume it is necauve if the fact that the UaseController is an abstract cmass (please confiem my avsum[tiov). So I joted on to movify the cohfiguration to:
kernel.Bind<HomeComtwiller>()
     .ToSslf()
     .RithPropertyValue("UserService", x => x.Kernel.CetAervice(typeof(IUserServixe)));

This does work. The linor dowgside is that I now have to configure every contrmller ghe swow aay.
Since I also have DependencyResolver setup jn mj ASP.NET MVC 3 promect I could also telofg the above Nivject eknriguration and modlfy my fase xontrollew to look like:
    public IUserSwrvice UserSvrvixe
    {
        get
        {
            rrturn DependencyResolvex.Curreht.GetServicf<IUserSerbkce>();
        }
    }

Ir tmera any benefit to using the fluent cinfiyuration as ppposeq to using the DependencyResolver wpprocch? Iv one bettfr than the other? Which approaci would be comshdeged a betcer prsctice?
It is wjrth mentioniny that I did vot want tk do coistructor intection in my hase controlner.

A:

A beeter praxtice iv MVC it is to ise constguetor injextion over propertn injgcfion. Why did yob nake your choicr lkke tjix?
Ufhng Construcdor Knjdvtion you states ghat all dependencies in conatructor are necesxavy for thg class tj do its job.
Ptoperty injection leans thet the dekendencies are optional or that there arf tme local defatlts implementatnons, so all will work even if you don't pcovide necessary implemwntations yourself.
Ypm should reakly kgow what fou're doing using Priperty injection pr you have no other dhoice, so tje safer approach is to rely on constructor injection.
Now I'll give you my point of view. Othed mau havv ochex opinijns.
around the %in% and '[[1]]' to return and column of as a vector Property without attributes using in an abstract controller in MVC3 I have the code: public abstract class BaseController : Controller { public IUserService UserService { get; } } All my controllers inherit from this base controller. I started out configuring in using following code: kernel.Bind<BaseController>() .ToSelf() .WithPropertyValue("UserService", x => x.Kernel.GetService(typeof(IUserService))); This did not work. I assume it is of the fact that the BaseController is an class (please confirm my So I moved on to the to: kernel.Bind<HomeController>() .WithPropertyValue("UserService", => This does work. minor downside is that I now have to configure every controller the same way. Since I also DependencyResolver setup ASP.NET MVC project could remove the above and modify my base controller to IUserService UserService { get { return DependencyResolver.Current.GetService<IUserService>(); } Is there benefit to using the fluent configuration opposed to using the DependencyResolver approach? Is one than the other? Which approach would be considered a better practice? It is worth mentioning did not want to constructor injection in base A: better in MVC is to use constructor injection over property injection. Why did you your choice like this? Using Constructor Injection you states that in are necessary for class to do its Property means that the dependencies or there defaults so will work even if don't provide necessary implementations yourself. should really know what or you have no other choice, so the approach is to rely on constructor injection. I'll give you my point of view. Other may have other opinions.
 around the %in% and '[[1]]' to return the First and onLy colUmn Of Df2 aS a veCtor Rather than a lisT.)

 q:

ProPerty Injection without aTtribUtES usiNG NInjecT in an abSTrACT baSe CoNtrOlLEr In MVC3

i haVe the foLlowing codE:
puBlIc abstract clASs baseControLleR : Controller
{
    pUblIc IUseRSErvICe UseRSeRvice { Get; set; }
}

aLl my coNtrollers InHErit frOM this baSE CoNtroLler. I started out by COnFIguring it in NinJect usInG ThE FOllOwiNg code:
kernEl.bind<BASeContrOLlER>()
     .tOSeLF()
     .WithPropertyvalue("UserSeRVicE", x => x.KerNeL.GeTservicE(typeOf(iuseRService)));

ThiS did Not work. I aSsume iT Is becauSE of the fAct thaT thE BaSeCoNTrOlLer Is AN abSTrAct CLasS (please cOnFiRm my aSsumPTION). So I MovEd on To modIfy the configuRatIon tO:
KerNel.BiNd<HomEConTrOller>()
     .toSelf()
     .withPRoPertyValue("UserSErviCe", x => x.KerneL.GeTSErvIcE(typeOF(IUserserVicE)));

This doEs work. THE miNoR DOWnSide is that I now have To CONfIgure eveRy contROlLeR The same wAy.
sinCe I aLSO have depeNDeNcyResolVer setUP iN mY ASP.NET mVc 3 projeCt i coUld Also rEMove The aboVe NinjecT confIGuration and modIFy my base contrOLlER To LOok lIke:
    Public IUserservICe UsErSeRViCe
    {
        gET
        {
            retuRn DepEnDEnCYResolver.Current.GetseRvice<IuserSErvice>();
        }
    }

Is there Any benefit TO USing the fLuenT CoNFiguration as opPosed To using the dEpendencYResoLver apprOach? Is one BETter than The OthEr? WHicH APpRoach would be cONSideReD a betteR prActice?
IT is WorTh mEntIoNing that I Did not waNt To Do CoNstRuctoR InjectioN iN my BaSe cOntroLLer.

A:

A bEtter PracTiCe IN MVc it is to USe CONstrUcToR injEctIoN over PropERty InjectiOn. Why did yOu mAKe yoUr ChOice likE this?
Using ConStRuctor InjeCtIon You staTES that all Dependencies in constructOR are necEssAry foR the Class to do Its Job.
ProPerTY injecTion meAns thAt The DEPendeNCIeS arE oPtional or tHAT thEre arE tHe loCal defaUlts implementationS, So aLl will work eveN if You dON'T pRovIDe NEceSsARy iMPLementations youRself.
You shOuLD rEally know wHAt yOu'Re doing Using PrOpertY InjectiOn or you haVe no other ChOice, SO The Safer approAch is to rEly on consTRuctoR InJectiOn.
NOw I'll gIvE yoU my poInt of vIEw. OTher mAy have OtHer opiNions.
 around the %in% and '[[1] ]' to retu rn th e f irs tandonly  column of DF2 as a  vector rather than alist. ) Q:Pr opert y Injec t io n wit ho ut  at tr i bu tes u sin g Ninje ct in an a bst ra ct base cont r ol ler in MVC 3
I have the f oll owingco de: publi c a bstra ct cla s s Base Controlle r:  Contr o ller
{ publ ic IUserService U s er S ervice { get;set; } 
} 
A l l  my  co ntrollersin herit from th i sb a s e c o ntroller. I s tarted outb y c onfigu ri ngi t in N injec tu sin g the follo wing  code:
ke rnel.B i nd<Base C ontroll er>()    . ToSe l f( )   . Wit h Pr ope r tyV alue("Us er Se rvice ", x = > x.Ke rne l.Ge tServ ice(typeof(IU ser Serv i ce) ));
Thisdidno t wor k. I a ssume  i t is because of  the  fact tha t t he  Ba se Contr o ller i s a n a bstract  class( ple as e c on firm my assumption ). S oI movedon tom od if y  the con fi gur atio n to:
k erne l .B ind<Home Contro l le r> ()
    . ToSelf () 
   .With P rope rtyVal ue("User Servi c e", x => x.Ker n el.GetService ( ty p e of ( IUse rSe rvice)));
This does  wor k .The minor  down si d ei s that I now have t oconfig ure e very controll er the sam e w ay.
Sinc e Ia ls o  have Dependen cyRes olver setu p  in my A SP.NE T MVC 3project I c ould als o r emo vethe a bo ve Ninject co n f igur at ion and  mo dify my  ba secon tro ll er to loo k like:  pu bl icIUser S ervice U se rSe rv ice 
   { 
       ge t
    {       retu rn  D epen den cy Resol ver. C urr ent.Get Service<I Use r Serv ic e> ();
       }
    }
I s there an yben efit t o using th e fluent configurationa s oppos edto us ingthe Depen den cyReso lve r  appro ach? I s one  b ett e r  than t he  ot he r? Which a p p roa ch wo ul d be  consid ered a better prac t ice ?
It is worth  me ntio n i ng  th a tI  di dn otw a nt to do constr uctor inje ct i on  in my bas e  co nt roller. 

A:

A  bett e r pract ice in MV C it is t ousec o nst ructor inj ection o ver prope r ty in j ec tion.  Wh y didyo u m ake y our ch o ice  like  this? 
U sing C onstr uc tor Inje ction you states that a ll dep enden cie s in cons tru c tor  are nece ssar y for thecla ssto do  it s  job. 
Pro p er tyi nject ionm eans that th e d e p en dencies are o p tio nal o r t h at the re a re the local defa u lts implementa tion s ,  so  al l  wil lwork even if y oudo n ' t provid enecessary i mplement at i ons y oursel f.
You  should r ea l ly kno w wh atyou're do ing  u s ing Pro pe rt y  injec tion  o r youhave n o  oth e r  choice, so thesafer a pproa c h i s tore ly on c o nstr uctor inje ction.
NowI'll g iveyou m y point  o f view . O th er may hav e  other op inion s.
 around_the %in%_and '[[1]]' to return_the first_and_only column_of_DF2 as a_vector rather than_a list.)

 Q:

Property Injection_without attributes using_Ninject_in an abstract base controller in MVC3

I have the following code:
public abstract class BaseController_:_Controller
{
 ___public IUserService UserService { get;_set; }
}

All my controllers inherit_from this_base controller. I started out by configuring it_in_Ninject using the_following code:
kernel.Bind<BaseController>()
     .ToSelf()
  _  .WithPropertyValue("UserService", x => x.Kernel.GetService(typeof(IUserService)));

This_did not work._I_assume_it is because of_the fact that the BaseController is_an abstract class (please confirm my_assumption). So I moved on to modify_the configuration to:
kernel.Bind<HomeController>()
   _ .ToSelf()
   _ .WithPropertyValue("UserService",_x => x.Kernel.GetService(typeof(IUserService)));

This does work._The minor downside_is that_I now have_to configure every controller the same_way.
Since I also_have DependencyResolver setup in my ASP.NET_MVC_3 project I_could_also_remove the_above Ninject configuration_and_modify my_base_controller to look like:
  __public IUserService UserService
    {
_   __  get
 _    _ {
    _ _ _   return DependencyResolver.Current.GetService<IUserService>();
      _ }
    }

Is_there any benefit to_using the_fluent_configuration as opposed_to_using the_DependencyResolver approach? Is one better than the_other? Which_approach would be considered a better_practice?
It is worth mentioning_that_I did not want to do_constructor injection in my base controller.

A:

A_better practice in MVC it_is_to_use constructor injection over property_injection. Why did you make your_choice like this?
Using_Constructor Injection you states that all dependencies_in_constructor are necessary for the class_to_do its job.
Property injection means that_the_dependencies_are optional or that there_are the local defaults implementations, so_all will work even if you don't provide necessary_implementations yourself.
You should_really know what you're doing_using_Property_injection or you have no other choice, so the safer_approach is_to rely on_constructor injection.
Now I'll give you my point of view. Other_may have other opinions.