A (minor) complaint...

  • To my big suprise the property 'Name' is overridden in the TWPFGGraphic class and this just breaks up my complete code. Let me explain why...

    I have a form on which I drop several of these graphics. I have an additional stringlist where the names for these graphics are stored. These names are entered by the user in runtime because there will also be bands and other controls that will link to just this name. So I have code like this:


    The TableGraphicList object is my list of graphics. DisplayException will log and display the exception without reraising the exception. Basically, I let the user enter a name for the control until he has entered a valid name. (IsValidIdent is a Delphi function, btw.)

    The magic in my class is that in the SetName method that I've overridden, I add the name to a list and do some further processing with this name. (E.g. adding to a dropdown box, writing the name to a log, things like that.)

    However, since the inherited 'Name' property is hidden by the new 'Name' property, this just doesn't work. I could of course work around this by adding my own, new 'Name' property and assign some methods to it to use the inherited name property but personally, I feel this a bit bad design.

    Was there any need to override the Name property in WPForms? It's a really annoying thing that took me half a day to discover, and I only discovered it because I have checked the source.

    • Offizieller Beitrag

    Hi,

    >>However, since the inherited 'Name' property is hidden by the new 'Name' property, this just doesn't work. I could of course work around this by adding my own, new 'Name' property and assign some methods to it to use the inherited name property but personally, I feel this a bit bad design. <<

    I don't like it either. But the inherited "name" property requires the name to be empty or unique - and creates an ugly exception otherwise.

    Julian

  • >> I don't like it either. But the inherited "name" property requires the name to be empty or unique - and creates an ugly exception otherwise. <<

    Then again, it would have been a lot nicer if this property had used a SetName method to set the name. Right now, things are just a bit too confusing, because the class now has two properties with the same name, and one of them cannot be accessed anymore. Personally, I would have preferred it if the Name property wasn't overridden. If you wanted to add a custom name to the class, you could have used a different name for it.

    It's not a real big issue for me but I expected some simple behaviour here. I had overridden the SetName method in my custom graphic and it took me half a day to just discover why it didn't change the name of the graphic. The reason being of course that the name property that SetName refers to uses a property that's now hidden by the new Name property.

    In general, the name property for components is pretty useful since you can search in your component list for any component with a given name. But with WPForms this functionality is broken because there is no way to access this hidden name property.