Training, Open Source computer languages

PerlPHPPythonMySQLhttpd / TomcatTclRubyJavaC and C++LinuxCSS

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Class, static and unbound variables
In Object Oriented programming, you'll have certain named blocks of code (usually known as methods) that you can perform on specific objects (type A), and others that you can perform on all the objects of a particular type (type B).

Example.

If I had a class called sandwich, I might have one method called getFilling and another called getBread which return me information as to whether a particular sandwich is Beef or Cheese, and whether it's on brown or white bread. These methods are both Type A as their actions will vary depending on which sandwich they're run.

However, if I have a method called getCount that returns me a total of the number of sandwiches I have, then it's going to return me the same value whether I call it on my "Beef and Stilton on White", or on a Plain cheese sandwich in brown bread. So that's an example of a Type B.

Type B methods are sometimes known as Class methods since they apply to the class as a whole. You'll also find that Java programmers refer to them as static methods, and Python fans call them unbound methods since they're not attached (bound) to any particular single instance of an object.

Type B methods, then, may be known as Object methods as they apply to an individual object, dynamic methods as they change in behaviour depending on which particular object they're called on, or bound methods because their behaviour is bound to a certain object.

(written 2005-10-25 14:47:07)

 
Associated topics are indexed under
Y112 - Python - Objects - Intermediate
Y106 - Object Oriented Python
J706 - Java - Objects and Classes
Q909 - Object Orientation and General technical topics - Object Orientation: Composite Objects

Back to
May I be politically incorrect?
Previous and next
or
Horse's mouth home
Forward to
Watch what you wear

Some other Articles
PHP upgrade - traps to watch
New look to website
New servlet from old
Watch what you wear
Class, static and unbound variables
May I be politically incorrect?
Where to stay in and near Melksham
Vintage Bus Day
Looking different in town
Are you free on 29th October - Charity ball
1638 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho