CanReadProperty - do you use it?

CanReadProperty - do you use it?

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


maxal posted on Tuesday, April 15, 2008

We are doing our first project using CSLA 3.0. We started by looking into book and CodeSmith templates we found, so every property now has CanReadProperty(<property name>, true) and CanWriteProperty(<promoerty name>, true) calls.

However, we do not really use them, and even if we will, there will be just few of them. So, I am thinking about removing all of them first for perfomance, second - well I don't like having code that is not used.

The question is more academic, or subjective one. Do you try to follow "The Book" and leave CanReadProperty or do you remove them when not needed.

JoeFallon1 replied on Wednesday, April 16, 2008

I have removed them when not needed.

My Codesmith templates can optionally include them by changing a setting to True.

Joe

 

Marjon1 replied on Thursday, April 17, 2008

Just another opinion to throw into the mix, 90% of our objects use these methods but where they are not need they are removed. This is so that we don't accidentally assume that this particular object has some form of authentication logic applied and like you said, I just don't like having code around that has no true meaning.

Marjon

d3vil replied on Thursday, April 17, 2008

there is a very big downside to this...
in the case of a property will get some more logic or will need securtiy, its more likely that the programmer editing the "naked" property will forget adding it.

when no secuirty rules are defined I think the canRead/Write aren't that much a problem issue.. and won't really hart you if you keep them..
I will suggest that if you want to remove them ,try to consider to remark them instead...

maxal replied on Thursday, April 17, 2008

Actually I made my mind and removing them. There is downside you mentioned but I decided that since there is just one entry point for the property, it's easy to add it when the rule is implemented.

Copyright (c) Marimer LLC