So, all we need to use an object is to know its external interface. We can use its features via the external interface. For instance, a boiler tube is attached to the heating element.īut from the outside a coffee machine is closed by the protective cover, so that no one can reach those. If we continue the analogy with the coffee machine – what’s hidden inside: a boiler tube, heating element, and so on – is its internal interface.Īn internal interface is used for the object to work, its details use each other. External interface – methods and properties, accessible also from outside the class.Internal interface – methods and properties, accessible from other methods of the class, but not from the outside.In object-oriented programming, properties and methods are split into two groups: If we remove the protective cover from the coffee machine, then using it will be much more complex (where to press?), and dangerous (it can electrocute).Īs we’ll see, in programming objects are like coffee machines.īut in order to hide inner details, we’ll use not a protective cover, but rather special syntax of the language and conventions. The secret of reliability and simplicity of a coffee machine – all details are well-tuned and hidden inside. But we can use it without knowing anything.Ĭoffee machines are quite reliable, aren’t they? We can use one for years, and only if something goes wrong – bring it for repairs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |