Prev | Current Page 249 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


interface IPerson
{
var firstName : String;
var familyName : String;
function getFullName() : String;
}
122
Part I: The Core Language
The I prefix in the interface name is a naming convention in some other languages such as C#, but it is
not required and you can follow your own style conventions or none at all.
An interface can implement one or more interfaces but can extend none. On the contrary of what
happens in a class definition, when the access modifier is omitted the default value of public is
assumed; the types for functions, parameters, variables, and properties must always be explicitly
provided.
Static fields have no meaning in interface declaration because, as already explained, they are owned just
by the declaring type and are not inherited.
Interfaces in practice are used when a system requires exchangeable classes, which share their definition
but not their implementation. Such a system could be for example a graphical user interface (GUI) that
requires that its widgets (buttons, text fields, and so on ) implement a common Control interface.


Pages:
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261