Case Sensitivity of DataMapper and PropertyHasChanged is an unnecessary Nuisance

Case Sensitivity of DataMapper and PropertyHasChanged is an unnecessary Nuisance

Old forum URL: forums.lhotka.net/forums/t/935.aspx


Jav posted on Thursday, August 17, 2006

1. DataMapper fails with an exception if the Property name in <%# Bind("address") %> differes from the Property name e.g., "Address" in case only. 

2. I am using ActiveObjects, so this may be a problem with Petar's code, but the following results in an exception also.

        Public Property Zipcode() As String
            Get
                CanReadProperty("Zipcode", False)
                Return mZipcode
            End Get

            Set(ByVal Value As String)
                CanWriteProperty("Zipcode", False)
                mZipcode = Value
                PropertyHasChanged("ZipCode")
            End Set
        End Property

When auto-generating the code, the problem is not likely.  When typing the code by hand it creates unnecessary problems for VB programmers.

Jav 

DesNolan replied on Friday, August 18, 2006

Hi,

Right after my private fields in my business object I decalre another set of  string variables for each field which are prefixed with 'fn' to which I assign the name of each field.

Then in all my Can Reads and Can Writes I use those fn variables (which avoids any reflection), and in fetching parameters I also use them avoiding dependency on field positions in result sets.

So as long as I spell them correct once, there spelt correctly throughout the application.

Cheers,

Des

Jav replied on Friday, August 18, 2006

Thank you Des.  That is a way to handle it - a workaround.  But the point still remains. We name things (all things) to identify them and to make our lives easier - not more difficult.

Only in a colony of idiots people will start a custom where case sensitivity of a name is meant to be a differentaiting factor - like "my name is 'James', but my brother is named 'james'"

Jav

ajj3085 replied on Friday, August 18, 2006

Hey now... there were good reasons for case senstivity.  For one, its faster to do a direct compare; case insensitivity does take time (no matter how little). 

At any rate, if it really bothers you, you can modifly Csla.  The reflection API does allow you to specifiy if you want to ignore case or not.  As alternates, you can just copy and paste the property name into the PropertyHasChanged parameter or just not specify it at all (and let Csla work out the name of the property).

I wouldn't want that Csla modification to be the default though, since in my code private fields which are exposed via a property DO only differ by case.. I've personally always found it silly to have to prepend some random character to force some artifical difference to distinguish between private fields and public properties.



Andy


david.wendelken replied on Friday, August 18, 2006

As I understand it, the C# and the VB version of the Csla library can both be used to support C# and VB classes.

If case sensitivity is removed from the Csla library, it will not be able to properly support a C# module.

It may not affect you, but it would affect others.

 

 

ajj3085 replied on Friday, August 18, 2006

If the OP doesn't care about C# libraries though, modifying Csla to fit his needs is fine.  I was just giving different ways for the OP to solve the problem he was having (not specifying the property name explicitly is probably the best one).

malloc1024 replied on Friday, August 18, 2006

CSLA is a teaching tool on how to build a framework.  The code is provided so you can change it to your liking.  If there is something you don’t like about it, stop complaining and change it.  It really is that simple.

Copyright (c) Marimer LLC