Good mod or dumb idea?

Good mod or dumb idea?

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


DansDreams posted on Wednesday, January 03, 2007

Sometimes these changes I make seem so obvious that I pause to wonder what other factors I'm not considering.

The Save method overrides in the PT business objects do some checking for the user's authorization to perform the save operation, and then call the base.Save method if they all pass.

I made the CanAddObject, CanDeleteObject, and CanEditObject methods abstract in my CustomBusinessBase : BusinessBase class and then moved all that authorization checking in there as well.

But that makes me wonder why Rocky didn't do that in BusinessBase in the first place.

Thoughts?

DansDreams replied on Wednesday, January 03, 2007

Well, didn't take me long to get that answer.  Those methods are static (shared) to enable some use in the UI, and you can't have abstract (or virtual for that matter) static methods unfortunately.

 

ajj3085 replied on Wednesday, January 03, 2007

Oddly though you can call those static methods from the base class via the subclasses name.

DansDreams replied on Wednesday, January 03, 2007

Yeah, it seems like a severe limitation that I would expect is solvable by the compiler team.  But then, I'm just talking out my posterior orifice when it comes to that :D

Since this is generated/snippet code anyway I'm not going to worry about it.

If I find myself frequently needing to have instance versions of these authorization checks anyway then I'll revisit this. 

My plan would be to have abstract instance methods CanEditThisObject, CanDeleteThisObject, etc. in the CustomBusinessBase class.  The default implementation in the business object would be to just return the corresponding static/shared call.  The CusomtBusinessBase Save override in CustomBusinessBase could then use the instance version and do that authorization checking as I originally planned.

Copyright (c) Marimer LLC