I would like to store some additional information for each of the items in popupbox in FMX.

I would like to store some additional information for each of the items in popupbox in FMX.

There are properties (Tagxxx) for the whole component only. Does anyone know how to do this per item?

I tried to use AddObject which inherites from the component but it doesn't suit my needs. Am I missing something here?

Thanks

Comments

  1. The problem is that you are not coding for the future. You're coding for the present. OOP is about providing extending points to hook code on the future to extend it. It is also about encapsulation (proper encapsulation will grant you the power to change the implementation if you keep your interface). If you use tag to store an integer, what comes next if you need to add, say, a string that is somehow related to your integer? or another integer?; what happens if you change the TPopupBox for a T3rdPartyRockstarPopupBox? If you keep things clean and separated you can do that with ease. Also it makes code easier to understand (Tag is an integer, which is a primitive, which leads you to potential primitive obsession code smell) and easier to even implement it, because you don't have to deal with lots of stuff related to the GUI object and its hierarchy (that's overkill) that introduces complexity.

    Not to talk about testing, how can you run test against something that needs the FMX running?

    ReplyDelete
  2. Agustin Ortu I know all these things and I see the point but what I want to implement is pretty straightforward.

    ReplyDelete
  3. And if after some time I need to add additional data, I will then consider other more sophisticated solutions as you propose or as I attempted with the AddObject

    ReplyDelete

Post a Comment