Thanks David, you and aside from a few others are the only people who
actually answered my actualy question. I only wanted to know if people found
it odd and whether or not they've done it before.

Although I do think it's not necessarily a bad idea, as I mentioned it's a
similar idea in MVC, when you use the HTML helpers and using lambda
expression's. I just never thought I'd do in this context.


On Thu, May 27, 2010 at 7:50 AM, David Kean <david.k...@microsoft.com>wrote:

> Yep searching for both those terms together in your favourite search engine
> will return a lot of good results.
>
> -----Original Message-----
> From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
> On Behalf Of Arjang Assadi
> Sent: Wednesday, May 26, 2010 2:37 PM
> To: ozDotNet
> Subject: Re: ASP.NET Control databinding, member properties, dynamically
> fetch property name?
>
> Thank you.
>
> What is the name of concept we are dealing with here, "Lambda" and
> "Property Binding ?
>
> On 27 May 2010 06:23, David Kean <david.k...@microsoft.com> wrote:
> > Here's an example:
> >
> >    class Property
> >    {
> >        private readonly PropertyInfo _propertyInfo;
> >
> >        public Property(LambdaExpression property)
> >        {
> >            Requires.NotNull(property, "property");
> >
> >            var body = property.Body as MemberExpression;
> >            if (body == null)
> >                throw new ArgumentException("'property' should be a
> > MemberException");
> >
> >            _propertyInfo = (PropertyInfo)body.Member;
> >        }
> >
> >        public string Name
> >        {
> >            get { return _propertyInfo.Name; }
> >        }
> >
> >        public PropertyInfo PropertyInfo
> >        {
> >            get { return _propertyInfo; }
> >        }
> >
> >        public static implicit operator string(Property property)
> >        {
> >            return property.Name;
> >        }
> >
> >        public static implicit operator PropertyInfo(Property property)
> >        {
> >            return property.PropertyInfo;
> >        }
> >
> >        public static Property Of(Expression<Func<object>> property)
> >        {
> >            return new Property(property);
> >        }
> >
> >        public static Property Of<T>(Expression<Func<T, object>>
> > property)
> >        {
> >            return new Property(property);
> >        }
> >    }
> >
> > You can then use this:
> >
> > Foo foo = ...
> >
> > DisplayMember = Property.Of(() => foo.Bar);
> >
> >
> > -----Original Message-----
> > From: ozdotnet-boun...@ozdotnet.com
> > [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Arjang Assadi
> > Sent: Wednesday, May 26, 2010 1:10 PM
> > To: ozDotNet
> > Subject: Re: ASP.NET Control databinding, member properties, dynamically
> fetch property name?
> >
> > Do you have some links or examples for us to look at? (For winforms too
> would be good) What are the goodness than one can benefit from. Are there
> any programming tools that are can be used with this?
> >
> > Kind Regards
> >
> > Arjang
> >
> > On 27 May 2010 01:51, David Kean <david.k...@microsoft.com> wrote:
> >> I'm really interesting in hearing why people think this is a bad idea.
> >> I've done this in a few code bases (not ASP.NET, but WinForms) and it
> >> nothing but pure goodness from my perspective.
> >>
> >>
> >>
> >> From: ozdotnet-boun...@ozdotnet.com
> >> [mailto:ozdotnet-boun...@ozdotnet.com]
> >> On Behalf Of Stephen Price
> >> Sent: Wednesday, May 26, 2010 3:10 AM
> >> To: ozDotNet
> >> Subject: Re: ASP.NET Control databinding, member properties,
> >> dynamically fetch property name?
> >>
> >>
> >>
> >> So often those things are black and white. They can be done one way,
> >> and the other way can be argued wrong. But then on the other hand
> >> there are reasons why the other way can be right.
> >>
> >>
> >>
> >> When I come across people who believe in the inverse of myself it's
> >> usually in the middle of something that needs to get done. Arguing
> >> the point would lose time so I let it slide. Put it in the "do be
> >> discussed later over a beer or food" where the full ramifications and
> >> spiritual benefits of such code can be truly enjoyed. If all your
> >> codebase was the way you'd write it then you might as well have
> >> written it yourself. You can still be a craftsman and care about what
> >> you do. :)
> >>
> >>
> >>
> >> On Wed, May 26, 2010 at 5:27 PM, Winston Pang <winstonp...@gmail.com>
> wrote:
> >>
> >> Sorry, I think I didn't make it clear, the person who asked me us to
> >> do this was a Senior Developer on their team. They too could be
> >> lurking these mailing list, which would be cool if they replied too!
> >> :D
> >>
> >> So it's not so much about educating them... I'm sure they are "Senior"
> >> enough to know the ramifications, consdidering I did outline, it's
> >> uncommon and also quite redundant. But anyways, there's no winner,
> >> even if you outline all the cons to this, they are also a programmer
> >> too, have you ever had disputes with other developers other doing one
> thing over another way?
> >> Sometimes it gets resolved, sometimes people are just way too stubborn.
> >>
> >>
> >> On Wed, May 26, 2010 at 3:51 PM, Arjang Assadi
> >> <arjang.ass...@gmail.com>
> >> wrote:
> >>
> >> Or
> >>
> >> Just an opportunity to do something different, that is what they want
> >> that is what we will give them, or even better ask them why? where
> >> did they get the idea to have it like that from and understand their
> >> real concerns that has facilitated the odd requirements, maybe there
> >> is method to their madness or maybe they have misunderstood something
> >> and need to be helped out of it.
> >>
> >> No client knows really what they want, only what they think that they
> >> want, we (the programmers) are their guides and confidants, we (as
> >> programmers) have to hold their hands and help them out, after all if
> >> we don't then who will?
> >>
> >> Please ask and find out their real problem and what will satisfaction
> >> of this requirement give them, and report back here! :)
> >>
> >> Let's find out the real problem.
> >>
> >> Kind Regards
> >>
> >> Arjang
> >>
> >> On 26 May 2010 14:12, Winston Pang <winstonp...@gmail.com> wrote:
> >>> Well, firstly. The client is govt, and we're really dealing with
> >>> their internal IT team, who would eventually do supporting for the
> system.
> >>>
> >>> I have no say in whether we do it or not, I've told them, it's
> >>> redundant, and uncommon, and a bit too much. I've done all I can,
> >>> can't fight anymore about it.
> >>>
> >>> I just wanted to see what people though of it, I quite frankly think
> >>> it's stupid and unnecessary.
> >>>
> >>>
> >>>
> >>> On Wed, May 26, 2010 at 2:05 PM, mike smith <meski...@gmail.com>
> wrote:
> >>>>
> >>>> On 26 May 2010 08:35, Winston Pang <winstonp...@gmail.com> wrote:
> >>>> > Hi guys,
> >>>> >
> >>>> >
> >>>> > This is more of a question of whether or not this sounds feasible
> >>>> > and has anyone seen anyone do this:
> >>>> >
> >>>> >
> >>>> > Typically with most ASP.NET controls, lets take the ComboBox for
> >>>> > an example, it'll be like
> >>>> >
> >>>> > this.comboBox.DataSource = someList; this.comboBox.DisplayMember
> >>>> > = "Property1"; this.comboBox.ValueMember = "Property2";
> >>>> >
> >>>> > The client we're dealing with, has specifically told us to not
> >>>> > "hard-code"
> >>>> > these property names, and to use reflection, through lambda
> >>>> > expressions to derive the property name.
> >>>>
> >>>> I find a lot of use can be gained in such cases in asking the
> >>>> client why they want to do things a certain way at the outset,
> >>>> rather than blindly doing what they ask.  Sounds a lot like COM
> >>>> late binding (aka everything old is new again)
> >>>>
> >>>> >
> >>>> > Firstly, do you think this will add a lot of overhead? I'm
> >>>> > guessing it'll be ok-ish, considering ASP.NET MVC uses it a lot.
> >>>> >
> >>>> > Also, has anyone seen people do it this way?
> >>>> >
> >>>> > It this a stupid thing to do? I think it has it's merits to an
> >>>> > extent, but it sure doesn't seem common to me.
> >>>> >
> >>>> >
> >>>> > Cheers,
> >>>> >
> >>>> >
> >>>> > Winston
> >>>> >
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Meski
> >>>>
> >>>> "Going to Starbucks for coffee is like going to prison for sex.
> >>>> Sure, you'll get it, but it's going to be rough" - Adam Hills
> >>>
> >>>
> >>
> >>
> >>
> >>
> >
> >
>
>

Reply via email to