<cfinterface> does not respect implicit getters and setters. I was working on a CreditCard.cfc that implements ICreditCard.cfc in CF8.
CreditCard.cfc has holdername, number, expiryMM, and expiryYYYY properties defined using
<cfproperty>. ICreditCard.cfc (interface) has
getHolderName(), getNumber(), getExpiryMM(), getExpiryYYYY(). I then try removing the getters from CreditCard.cfc, but CF9 complains:
"The getNumber method is not implemented by the component or it is declared as private."
Oh, that sucks. Don't you agree?
UPDATE: CF9 FINAL will generate the getter and setter methods for you when you specify accessors=true, and they Will respace the interface if the method signatures are the same!
no.
ReplyDeleteI don't see the problem. The purpose of an Interface is to enforce that the interface methods are implemented, right?
ReplyDeletePerhaps I should stop responding to blog posts after 10pm. I understand your problem.
ReplyDeleteAfter thinking about it a little more, is it really a good practice to put getters (or setters) in an Interface?
You would be better off enforcing getters/setters using inheritance, right?
I think it sucks. If CF is going to create first class get and set methods that are as good as there, I think they should be able to satisfy interface requirements.
ReplyDelete@iotashan: I think it would be perfectly acceptable to place getters and setters in your interface providing they are truly part of the public API for the object. That being said, I never use the cfinterface tag-- I would code in Java if I wanted to mess with that. :)
Henry, did you create a ticket in the bug tracker?
ReplyDeleteI'm not a huge fan of cfinterface myself, but I figure a post like this should have a link to the bug tracker so the issue can actually be rectified.