Monday, August 24, 2009

CF9 beta: cfinterface does not respect implicit getters/setters

I'm excited these days because I get to play with CF9 for a new project. However, I'm disappointed that <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!

5 comments:

  1. I don't see the problem. The purpose of an Interface is to enforce that the interface methods are implemented, right?

    ReplyDelete
  2. Perhaps I should stop responding to blog posts after 10pm. I understand your problem.

    After 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?

    ReplyDelete
  3. 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.

    @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. :)

    ReplyDelete
  4. Henry, did you create a ticket in the bug tracker?

    I'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.

    ReplyDelete