podam icon indicating copy to clipboard operation
podam copied to clipboard

Investigate the possibility to use Dynamic proxies to pass AttributeMetadata to data strategies

Open mtedone opened this issue 11 years ago • 6 comments

Goals:

  • Have the DataProviderStrategy methods free of the AttributeMetadata
  • Allow users to define a custom DataProviderStrategy whose methods will be passed an AttributeMetadata through a dynamic proxy. So when DataProviderStrategy methods are invoked, the dynamic proxy can invoke another implementation which receives AttributeMetadata as argument

mtedone avatar Apr 13 '15 21:04 mtedone

Marco, what is wrong about AttributeMetadata? It's part of DataProviderStrategy interface, which allows end users to customize their strategies on per-attribute basis. The only thing I can see these are short living object so maybe class/attribute name/attribute type can be passed directly as method parameters instead of being encapsulated inside AttributeMetadata object?

daivanov avatar Apr 14 '15 14:04 daivanov

What's wrong is that the default implementation (random) doesn't use them. So we're passing an object around that doesn't get used. The only times this gets used is for custom strategies. It's just waste.

On Tuesday, April 14, 2015, Daniil Ivanov [email protected] wrote:

Marco, what is wrong about AttributeMetadata? It's part of DataProviderStrategy interface, which allows end users to customize their strategies on per-attribute basis. The only thing I can see these are short living object so maybe class/attribute name/attribute type can be passed directly as method parameters instead of being encapsulated inside AttributeMetadata object?

— Reply to this email directly or view it on GitHub https://github.com/mtedone/podam/issues/88#issuecomment-92862686.

mtedone avatar Apr 14 '15 15:04 mtedone

Waste of performance?

daivanov avatar Apr 14 '15 19:04 daivanov

No, it’s a waste of cleanness. To whoever reads the code (including ourselves) sends the wrong message. Why would we have an object in the signature that we don’t use? That object has been put there to make some users (amongst whom I understand there’s you and the Russian blogger) happy. Again, I haven’t got any resistance in making users happy, on the contrary. In the end this is why I started Podam. However to me clean and minimalist code is at the heart of the systems I write. If an object is passed to a method and not used, that’s a waste of signature, e.g. that method could work without AttributeMetadata (as I’ve demonstrated). If we do have the need for AttributeMetadata (as we do), then we need to put our brains to work and find an architectural solution that, while it keeps the code clean and minimised to the strictly necessary, it addresses as much use cases as possible.

Regards, M.

On 14 Apr 2015, at 20:20, Daniil Ivanov [email protected] wrote:

Waste of performance?

— Reply to this email directly or view it on GitHub https://github.com/mtedone/podam/issues/88#issuecomment-93026254.

mtedone avatar Apr 14 '15 20:04 mtedone

I've performed ritual purification and it's safe to read the code again.

daivanov avatar Apr 15 '15 20:04 daivanov

Fixed in PODAM 5.3.1

daivanov avatar Apr 26 '15 11:04 daivanov