You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been looking at dependency injection and a few issues with refactoring in regards to _.pluck. One of the primary things I run into is that I want these things to enforce the interface for refactoring.
A few examples
Interface used as a symbol for dependency injection
Dan Quirk (@danquirk), seems to me that the initial suggestion on #394 is quite different. This nameof methodology is primarily aimed at elmination of magic strings that cannot be refactored. Specifically the pluck use case isn't solved by checking the literal argument. The proposal in #394 is dangerous as noted in some of the comments and would either need runtime gating or to prevent all non literal strings from being parameters to a method describe with the memberof methodology. It also does not handle using Interface names for injection purposes as the nameof methodology would.
// A user modelvaruser={id: 0,name: 'Brendan Eich',title: 'Mr.'};// Create a greeting for the userfunctionupdateGreeting(){user.greeting='Hello, '+user.title+' '+user.name+'!';}updateGreeting();Object.observe(user,function(changes){changes.forEach(function(change){// Any time name or title change, update the greetingif(change.name===nameof(user.name)||change.name===nameof(user.title)){updateGreeting();}});});
Activity
RyanCavanaugh commentedon Apr 24, 2015
Are we basically talking about C#'s
nameofoperator?park9140 commentedon Apr 24, 2015
Hadn't used it before but seems right.
danquirk commentedon Apr 24, 2015
Is this a dupe of #394 then?
park9140 commentedon Apr 25, 2015
Dan Quirk (@danquirk), seems like this is different.
park9140 commentedon Apr 25, 2015
Dan Quirk (@danquirk), seems to me that the initial suggestion on #394 is quite different. This
nameofmethodology is primarily aimed at elmination of magic strings that cannot be refactored. Specifically the pluck use case isn't solved by checking the literal argument. The proposal in #394 is dangerous as noted in some of the comments and would either need runtime gating or to prevent all non literal strings from being parameters to a method describe with thememberofmethodology. It also does not handle using Interface names for injection purposes as thenameofmethodology would.alex1kirch commentedon May 12, 2015
I fully agree with Jonathan Park (@park9140).
Also, the
nameofmethodology can be used when working with Object.observe() method.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
mhegazy commentedon Dec 10, 2015
looks like another duplicate of #3628