0

An Unbiased Description Of Interfaces

Programming
For a long time I've been reading everyone wanting interfaces or not wanting interfaces in ColdFusion; make it more like Java or make it more abstract. No one has yet described what an interface means to them (since most think of or only know of Java interfaces). So, for anyone reading and for people just coming to ColdFusion or programming in general I supply this short list of what an interface is. No opinion, just the description of an interface/protocol as used in the Object Oriented Programming paradigm.

An interface is:

  1. the list of operations understood by the object
  2. the arguments these operations can be supplied with
  3. the types of results the operations return

    What #1 - #3 mean is that you as a developer can be handed an object that you have no idea how it works but because it adheres to an interface you know what it does. This also means that you can write an interface for something you need -say image resizing- and use that interface throughout your program. Then give your interface to some other programmer to develop and as long as they adhere to that interface it will work in your code.

  4. the invariants preserved despite modification to the object

    An invariant is a condition that does not change. The simplest example I can think of is where you have an object with two fields (variables): VariableA and VariableB then in a method that receives an argument and sets the value of VariableA the value of VariableB should not be changed after the method returns. This is important because if you call a method you have to have a clear understanding not only of what was modified but what wasn't.

  5. any exceptional situations the client using the interface must handle

    Error handling is important especially when code is being written by more than one person. Supplying the exceptional situations of a method is a good way to ensure that everyone is on the same page.

tags:
Programming

Search