Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Should I use structured or object oriented?

There's no "one size fits all" answer to "what's the best way for me to meet this application requirement", and if you're writing code there will be a number of different approached / methodologies you can use. I'm going to have a look at some of the possible choices and relate it to PHP today ... it's rather on my mind as I'm teaching an Object Oriented PHP course.

If your application is tiny, you can just write a single block of code. Let's face it, if you've just got a regular HTML web page on which you want to include today's date, a simple PHP print(date( ... is all you need. If the application is not tiny (but remains small), you would be well advised to split out the logically separate elements into functions. Taken to the extreme, you're looking at structured programming design where everything's in a function and each function performs a single logical task.

As applications grow, structured programming gets unwieldy too and you'll be best advised to use an Object Oriented approach. That's a great way to compartmentalise your code, allowing for easy extensability and code testing unit by unit.

As applications grow still further, from medium size to "large" or "huge", another trend may become apparent. While the development team is a tight little community, all the members know and share knowledge and will only call up pieces of code through appropriate ways - what I describe as a Trusted Object Oriented system, where the programmers are trusted to know what they're doing. But grow the thing massively, and there will be times that team members call up a piece of code in a way that the team leader would really rather they didn't. At this stage, you'll want to be using what I call a "Policed Object Oriented" system where externally visible components are marked with words such as "private", "public" and "protected".

PHP in various versions supports single code blocks, trusted OO and policed OO:

Application sizeMethodologyWeb language
SmallNot OOPHP - any version
MediumTrusted OOPHP4 or PHP5
LargePoliced OOPHP5


Bear in mind that if you want a policeman at the end of each street to protect you from the villains, you're going to have to pay for it in your taxes. The same thing applies with OO in PHP - a policed OO system may slightly extend development time, but you may feel that it's worth it. Certainly, when you're doing your initial coding practise you should use the trusted approach so that you're not hauled over the coals for every tiny error while you learn.
(written 2005-06-10 12:39:51)

 
Associated topics are indexed under
G906 - Well House Consultants - Programming Standards
H108 - Objects in PHP
A401 - Web Application Deployment - Structured Code and Object Orientation

Back to
The evening after the course
Previous and next
or
Horse's mouth home
Forward to
Walk in Bath
Some other Articles
Frightening and from-friend viruses and spams
No Smoking Pubs
Spotting a denial of service attack
Walk in Bath
Should I use structured or object oriented?
The evening after the course
Happy Birthday, PHP
Code and code maintainance efficiency
Passing information into and out of PHP functions
OO techniques are hard to teach
2259 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 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., 2009: 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