Edit: See my second post, together with this they are a better round-up of OOP.
Object-oriented programming (OOP) is one of the so called 'programming paradigm', that is, programming style. In this programming style the main focus is all kinds of different abstract objects and their interactions, to make the purpose of the program more clearly presented. These objects can be inspired from real life objects intuitively, which is a main selling point for OOP. Since OOP itself is quite abstract too I shall illustrate this by two examples:
- Real objects have all sort of properties, which are called attributes and methods in OOP. Attributes are like information such as height of a person, while methods are functions are what an object can carry out, for example the toast function of a toaster. You can then ask the toaster to toast the bagel, which is another object. Pretty straight forward.
- Now of course objects in real life are not all distinct but can be categorized by their properties (example being laptop and desktop are both computer, and spork having the properties of spoon and fork). Now notice that this two way of categorization is different: a laptop inherits the properties of a computer and it could have other properties (a touch pad), but the property of spork is a composition of the properties of a spoon and a fork. This kind of difference is carried to OOP as inheritance and composition of objects (see http://learnpythonthehardway.org/book/ex44.html).
P.S. Please tell me if the font size is too small, or any other suggestions you have!
No comments:
Post a Comment