Home Accessibility Courses Diary The Mouth Facebook Resources Site Map About Us Contact
Private and Public - and things between

Shiplake StationA public train service is one which is available for anyone to travel on; a private one only takes limited passengers as invites / made available by the operator. And there could be intermediate levels too - I understand that at times the British Transport Police protect the last train from Weymouth to Bristol on a Saturday night from the more inebriated members of the public who wish to travel on it. Then you have package trips available - such as [this one] next September, which is open to the public, but only if they join a group.

It gets more interesting when you consider that a public train service can be provided by a private company, and that even within the public accessible railway premises, there are areas which are protected from access from the public and are only available to staff who, however, may not be staff actually employed by the private company that runs the stations and trains.


In a garden at Shiplake
Why all the rules about who can do what? It would be downright dangerous to allow members of the public, without appropriate health and safety training, do wander around at will even on a publicly owned railway. And if such training was given, and precedents were set, the new system would provide yet another set of rules and regulations that had to be looked after and updated as each new station opened( ;-) ) and each new train type came into service. So the best thing is to allow a single way of doing each operation that's needed by the public user, and then to provide protected or private methods of delivering those requirements.

The first picture illustrate a train at Shiplake, operated by the First group which is private / protected (a plc) but operating a public service from Henly-on-Thames (population 12,000) to Twyford (for London) through village at least once an hour. The second picture illustrates a private railway in a garden in Shiplake. The only trains there are provided and run by the owner for his own use, and it would be an exceptional day indeed if he were to run services for the general public.


Where am I headed? I'm drawing a real life parallel to computer programming, where various elements of a program are often marked "public" or "private", and where there are often levels in between - the most commonly used intermediate word is "protected" and sometimes the word "package" is used too, although each of these words has slightly different meanings depending on the programming language that we're talking about.

Starting with a standard that applies across all languages. If something is described as "public" then it's available to any programmer who wants to use it. And if something is described as "private" then it's available only within the tight area of the programming unit - usually a class - in which it is defined. The public can make use of private elements indirectly, however, by calling up a piece of code marked 'public' within a class which within itself makes a call to a private element.

The beauties of using private members like this are two-fold. Firstly, the private method can be changed later on without the need for the public user to make any changes to allow for it (this is known as encapsulation), and secondly there's only a limited number of facilities that need to be ruggedised and safety audited for use by the public, as private ones have a firm lock on the door!

In PHP, the additional level of "protected" says that a member is available within its own class (so as it would be if it were private), AND within other classes which are derived - either directly or indirectly - from that class. Yesterday, I wrote a new example - a [source code] which included a base class called animal. I extended the animal into a specialized subclass called silentanimal, and then I defined four types more finely - dogs (which bark from time to time, and it depends on the dog how much it barks), sealions (all of which bark 20 times a day), giraffes (which don't bark), and cats (which don't bark either, but which are going to have their names displayed a bit differently). PHP does *not* have an extra package level.

Both C++ and Java also use private, protected and public - and also have a "package" level which is unstated and again comes somewhere in the middle. There's a full set of notes and diagrams that we've provided for Java [here - .pdf file]. And you'll notice that "protected" in Java does not relate to the class inheritance structure, but to Java's packages and subpackages.

In languages such as Perl, it's assumed that the programmer knows what (s)he's doing, and there aren't any of the "private" and "public" words. Which makes for much quicker coding if the assumption is correct, and a nightmare or maintainance if it isn't ...




Public Well House Consultants courses which include Object Orientation:
A Training CoursePerl for Larger Projects
Object Oriented PHP
Python Programming
Learning to program in Python
Ruby Programming
Learning to program in Ruby
Learning to program in Java
Java Bootcamp
Learning to program in C++
C and C++ programming
C++ Programming

Object Oriented techniques, and how they're implemented in each of the languages above, are also covered if required on private (single company) courses which can be run for you at our training centre, or at your offices.


[incr-Tcl] is an Object Oriented extension to Tcl, and we can cover it on private Tcl courses; if you're on either of our public Tcl courses and would like the subject added in, please let the tutor know and he'll be happy to add an extra hour or two before or after lessons on the final day of the course (no extra charge!).

Lua is not strictly an object oriented language, but its metatables provide something that's very close and with the same philosophy; we cover them on our public Lua courses, and they'll usually be covered on private courses too (subject to tailoring - very occasionally they won't be required)
(written 2011-01-22, updated 2011-01-25)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
C233 - C and C based languages - OO in C++ - beyond the basics
  [3979] Extended and Associated objects - what is the difference - C++ example - (2013-01-18)
  [3811] Associated Classes - using objects of one class within another - (2012-07-21)
  [3508] Destructor methods in C++ - a primer - (2011-11-05)
  [3251] C++ - objects that are based on other objects, saving coding and adding robustness - (2011-04-17)
  [3244] C and C++ - preprocess, compile, load, run - what each step is for - (2011-04-12)
  [3124] C++ - putting the language elements together into a program - (2011-01-08)
  [3123] C++ objects - some short, single file demonstrations - (2011-01-07)
  [3056] C++ - a complete example with polymorphism, and how to split it into project files - (2010-11-16)
  [2845] Objects and Inheritance in C++ - an easy start - (2010-07-01)
  [2577] Complete teaching example - C++, inheritance, polymorphism - (2010-01-15)
  [1819] Calling base class constructors - (2008-10-03)
  [1674] What a lot of files! (C++ / Polymorphism demo) - (2008-06-12)
  [1572] C - structs and unions, C++ classes and polymorphism - (2008-03-13)
  [1217] What are factory and singleton classes? - (2007-06-04)
  [925] C++ - just beyond the basics. More you can do - (2006-11-14)
  [831] Comparison of Object Oriented Philosophy - Python, Java, C++, Perl - (2006-08-13)
  [801] Simple polymorphism example - C++ - (2006-07-14)
  [798] References and Pointers in C++ - (2006-07-10)

H108 - Objects in PHP
  [4073] Learning about Object Orientation in PHP - a new set of examples - (2013-04-28)
  [4057] stdClass in PHP - using an object rather than an associative array - (2013-04-02)
  [3953] Objects in PHP - Revision - (2012-12-16)
  [3843] Caching Design Patterns - (2012-08-20)
  [3841] Copying, duplicating, cloning an object in PHP - (2012-08-18)
  [3840] Autoload in PHP - (2012-08-17)
  [3609] How do classes relate to each other? Associated Classes - (2012-02-12)
  [3608] Design Patterns - what are they? Why use them? - (2012-02-12)
  [3607] Designing your application - using UML techniques - (2012-02-11)
  [3211] Computer Graphics in PHP - World (incoming data) to Pixel (screen) conversion - (2011-03-24)
  [3210] Catchable fatal error in PHP ... How to catch, and alternative solutions such as JSON - (2011-03-22)
  [2922] Getting the OO design write - with PHP a example - (2010-08-14)
  [2921] Does copying a variable duplicate the contents? - (2010-08-14)
  [2774] PHP - Object Oriented Design in use - (2010-05-21)
  [2741] What is a factory? - (2010-04-26)
  [2717] The Multiple Inheritance Conundrum, interfaces and mixins - (2010-04-11)
  [2680] Static class members in PHP - a documented example - (2010-03-16)
  [2641] Object Oriented Programming in PHP - (2010-02-19)
  [2632] Shipping a test harness with your class in PHP - (2010-02-12)
  [2435] Serialization - storing and reloading objects - (2009-10-04)
  [2434] Abstract classes, Interfaces, PHP and Java - (2009-10-03)
  [2380] Object Oriented programming - a practical design example - (2009-08-27)
  [2172] PHP4 v PHP5 - Object Model Difference - (2009-05-11)
  [2171] Cleaning up redundant objects - (2009-05-11)
  [2169] When should I use OO techniques? - (2009-05-11)
  [2160] PHP - getclass v instanceof - (2009-05-07)
  [1925] Introduction to Object Oriented Programming - (2008-12-06)
  [1820] Sorting objects in PHP - (2008-10-04)
  [1682] Accounts in PHP - an OO demo - (2008-06-19)
  [1535] OO PHP demonstration - comparing objects and more - (2008-02-08)
  [1153] Object Oriented Model - a summary of changes from PHP4 to PHP5 - (2007-04-18)
  [1027] Cue the music, I'm happy. - (2007-01-09)
  [836] Build on what you already have with OO - (2006-08-17)
  [720] Planning a hotel refurb - an example of a Gant chart in PHP - (2006-05-14)
  [656] Think about your design even if you don't use full UML - (2006-03-24)
  [485] North, Norther and Northest - PHP 5 Objects - (2005-11-04)
  [421] Don't repeat code - use loops or functions - (2005-08-21)
  [343] Should I use structured or object oriented? - (2005-06-10)
  [205] PHP5 lets you say no - (2005-02-07)
  [124] PHP v Java - (2004-11-20)
  [67] Object Oriented Programming in PHP - (2004-09-29)

J709 - Java - Class Access
  [3047] What is a universal superclass? Java / Perl / Python / Other OO languages - (2010-11-13)
  [2535] When should I use Java, Perl, PHP, or Python? - (2009-12-13)
  [2419] Where is my Java class? - (2009-09-24)
  [874] Who can use which access door? - (2006-09-21)

Q909 - Object Orientation and General technical topics - Object Orientation: Composite Objects
  [3152] Jargon busting - (2011-01-30)
  [2865] Relationships between Java classes - inheritance, packaging and others - (2010-07-10)
  [2170] Designing a heirarcy of classes - getting inheritance right - (2009-05-11)
  [1348] Screw it or Glue it? Access to Object variables - a warning - (2007-09-12)
  [1345] Perl and Shell coding standards / costs of an IT project - (2007-09-11)
  [592] NOT Gone phishing - (2006-02-05)
  [477] Class, static and unbound variables - (2005-10-25)

R108 - Ruby - More Classes and Objects
  [3782] Standard methods available on all objects in Ruby - (2012-06-23)
  [3781] Private, Protected, Public in Ruby. What about interfaces and abstract classes in Ruby? - (2012-06-23)
  [3760] Why you should use objects even for short data manipulation programs in Ruby - (2012-06-10)
  [3260] Ruby - a training example that puts many language elements together to demonstrate the whole - (2011-04-23)
  [3158] Ruby training - some fresh examples for string handling applications - (2011-02-05)
  [3154] Changing a class later on - Ruby - (2011-02-02)
  [2980] Ruby - examples of regular expressions, inheritance and polymorphism - (2010-10-02)
  [2977] What is a factory method and why use one? - Example in Ruby - (2010-09-30)
  [2623] Object Oriented Ruby - new examples - (2010-02-03)
  [2620] Direct access to object variable (attributes) in Ruby - (2010-02-02)
  [2616] Defining a static method - Java, Python and Ruby - (2010-02-01)
  [2604] Tips for writing a test program (Ruby / Python / Java) - (2010-01-29)
  [2603] Ruby objects - a primer - (2010-01-29)
  [2601] Ruby - is_a? v instance_of? - what is the difference? - (2010-01-27)
  [2292] Object Orientation in Ruby - intermediate examples - (2009-07-16)
  [1587] Some Ruby programming examples from our course - (2008-03-21)
  [184] MTBF of coffee machines - (2005-01-20)

T245 - Tcl/Tk - [incr-Tcl]
  [1528] Object Oriented Tcl - (2008-02-02)
  [290] Object Orientation in Tcl - [incr-Tcl] - (2005-04-24)

U107 - Object Orientation - the Lua way
  [4273] Dot or Colon separator between table name and member in Lua - what is the difference? - (2014-05-06)
  [4248] Metatables, Metamethods, classes and objects in Lua - (2014-03-18)
  [4117] Is Lua an Object Oriented language? - (2013-06-15)
  [3730] What is a metatable? How do I set one up? How do I use them? Lua - (2012-05-12)
  [3727] Using Lua tables as objects - (2012-05-11)
  [3694] Special __ methods you can use in Lua metatables - (2012-04-12)
  [3683] Weak references in Lua - what are they, and why use them? - (2012-04-04)
  [3524] Metaclasses (Python) and Metatables (Lua) - (2011-11-17)
  [3396] Tables as Objects in Lua - a gentle introduction to data driven programming - (2011-08-17)
  [2710] __index and __newindex in Lua - metatable methods - (2010-04-05)
  [2703] Lua Metatables - (2010-04-02)
  [2701] Is Lua an Object Oriented language? - (2010-04-01)
  [2455] Lua examples - coroutines, error handling, objects, etc - (2009-10-15)
  [2359] A fresh example - objects the Lua way - (2009-08-13)
  [2318] For Lua Programmers AND for Town Planners - (2009-08-02)
  [1743] First class functions in Lua lead to powerful OO facilities - (2008-08-07)
  [1699] If you are learning Lua, here are some more examples - (2008-07-06)
  [1692] Towards Object Oriented Programming in Lua - (2008-06-30)


Back to
Wiltshire Rail services - a golden opportunity
Previous and next
or
Horse's mouth home
Forward to
On time
Some other Articles
Strings in C
Structures v Structure Pointers in C. How, which, why.
Setting up arrays in C - fixed size at compile time, or dynamic
On time
Private and Public - and things between
Wiltshire Rail services - a golden opportunity
Django - separating the HTML from the view / model
Steering our Python courses towards wxPython, SQLite and Django
Django - adding your own views, and then templating your views.
Training Classes - should the training company provide a system for each delegate to use?
4279 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, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86 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).

You can Add a comment or ranking to this page

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

PAGE: http://www.wellho.net/mouth/3142_Pri ... tween.html • PAGE BUILT: Sun Mar 30 15:20:58 2014 • BUILD SYSTEM: WomanWithCat