Main Content
When should I use OO techniques? Archive - Originally posted on "The Horse's Mouth" - 2009-05-11 04:37:21 - Graham Ellis
We have two friends. They're married. She's a keen advocate of Object Oriented Programming and he can't stand the approach. So take them to the pub, buy them a couple of drinks each, mention OO programming and watch the feathers fly ;-)
Seriously, Object Oriented Programming has its place - and there are places it should not be used. Along the base of this diagram you'll find the size of application from tiny to huge, and on the left axis is the easy of writing - from trivial to impossible. The orange line represents "single block" code, the blue line is structured coding, and the black line is object oriented.
• With a single block of code, you can start coding very quickly and easily, but you'll rapidly find that it gets impractical to manage what you're doing. Like writing an article with no paragraphs.
• Structured coding is like writing a short story - there's a bit of an overhead, but the text is broken into paragraphs and it's easy enough to write and maintain up to a certain point.
• And with Object Oriented programming, you can compare with a complete book. There's considerable overhead in the initial setup, but the scheme is expandable far beyond the small and medium sized application - it works really well for something substantial in size
Which of our friends is 'right' in their argument? They both are - she writes parts of large systems, and he writes short system administration utilities.
Some other articles
Y106 - Object Oriented Python When to check an object type - Python isinstance example Why populate object with values as you construct them? From single block to structure and object oriented programming What is the difference between a function and a method? Simple OO demonstration in C++, comparison to Python Really Simple Class and Inheritance example in Python Spike solution, refactored and reusable, Python - Example this or self - what are they, and what is the difference? (Python) From Structured to Object Oriented Programming. Object oriented or structured - a comparison in Python. Also writing clean regular expressions Moving from scripting to Object Orientation in Python From fish, loaves and apples to money, plastic cards and BACS (Perl references explained) Object Oriented Programming for Structured Programmers - conversion training Tips for writing a test program (Ruby / Python / Java) This article Python - a truly dynamic language Introduction to Object Oriented Programming Screw it or Glue it? Access to Object variables - a warning Python class rattling around Python - function v method Python makes University Challenge Class, static and unbound variables Q907 - Object Orientation: Design Techniques Associative objects - one object within another. Spike solution, refactoring into encapsulated object methods - good design practise The spirit of Java - delegating to classes Test driven development, and class design, from first principles (using C++) Using object orientation for non-physical objects Teaching OO - how to avoid lots of window switching early on Storing your intermediate data - what format should you you choose? Inheritance, Composition and Associated objects - when to use which - Python example From Structured to Object Oriented Programming. Rooms ready for guests - each time, every time, thanks to good system design When you should use Object Orientation even in a short program - Python example Spike solutions and refactoring - a Python example Why you should use objects even for short data manipulation programs in Ruby Designing your application - using UML techniques Your PHP website - how to factor and refactor to reduce growing pains Ruby - a training example that puts many language elements together to demonstrate the whole Object Oriented Programming for Structured Programmers - conversion training Comments in and on Perl - a case for extreme OO programming What is a factory method and why use one? - Example in Ruby Turning an exercise into the real thing with extreme programming Should Python classes each be in their own file? Program for reliability and efficiency - do not duplicate, but rather share and re-use Relationships between Java classes - inheritance, packaging and others The Light bulb moment when people see how Object Orientation works in real use Containment, Associative Objects, Inheritance, packages and modules What is a factory? The Multiple Inheritance Conundrum, interfaces and mixins Plan your application before you start Simples Object Oriented programming - a practical design example Planning! Designing a heirarcy of classes - getting inheritance right This article Teaching Object Oriented Java with Students and Ice Cream Object Oriented Tcl Object Oriented Programming in Perl - Course Object Relation Mapping (ORM) What are factory and singleton classes? Maintainable code - some positive advice Build on what you already have with OO Comparison of Object Oriented Philosophy - Python, Java, C++, Perl The Fag Packet Design Methodology Think about your design even if you don't use full UML Design - one name, one action Introduction to Object Oriented Programming Tapping in on resources OO - real benefits P213 - Creating your own Classes Classes and object - first steps in Perl 6 Learning to use existing classes in Perl Learning Object Orientation in Perl through bananas and perhaps Moose Object Orientation in an hour and other Perl Lectures What does blessing a variable in Perl mean? Further more advanced Perl examples Teaching examples in Perl - third and final part This article Introduction to Object Oriented Programming Object Oriented Perl - First Steps Example of OO in Perl Object Oriented Programming in Perl - Course Perl for Larger Projects - Object Oriented Perl Blessing in Perl / Member variable in Ruby Answering ALL the delegate's Perl questions When to bless a Perl variable Bellringing and Programming and Objects and Perl J706 - Objects and Classes Objects - from physical to virtual or abstract - Java Binomial Coefficient (Pascal Triangle) objects in Java Calculation within objects - early, last minute, or cached? Defining a static method - Java, Python and Ruby Looking inside Java classes - javap and javadoc This article Introduction to Object Oriented Programming Long, Longer, Longest in Java First Class Java. First step and moving forward. An example of Java Inheritance from scratch A better alternative to cutting and pasting code Class, static and unbound variables Variable Scope H108 - Objects in PHP Associative objects - one object within another. Caching results in an object for efficiency - avoiding re-calculation Singleton design pattern - examples and uses Changing what operators do on objects - a comparison across different programming languages Object factories in C++, Python, PHP and Perl Learning about Object Orientation in PHP - a new set of examples stdClass in PHP - using an object rather than an associative array Objects in PHP - Revision Caching Design Patterns Copying, duplicating, cloning an object in PHP Autoload in PHP How do classes relate to each other? Associated Classes Design Patterns - what are they? Why use them? Designing your application - using UML techniques Computer Graphics in PHP - World (incoming data) to Pixel (screen) conversion Catchable fatal error in PHP ... How to catch, and alternative solutions such as JSON Private and Public - and things between Getting the OO design write - with PHP a example Does copying a variable duplicate the contents? PHP - Object Oriented Design in use What is a factory? The Multiple Inheritance Conundrum, interfaces and mixins Static class members in PHP - a documented example Object Oriented Programming in PHP Shipping a test harness with your class in PHP Serialization - storing and reloading objects Abstract classes, Interfaces, PHP and Java Object Oriented programming - a practical design example PHP4 v PHP5 - Object Model Difference Cleaning up redundant objects This article PHP - getclass v instanceof Introduction to Object Oriented Programming Sorting objects in PHP Calling base class constructors Accounts in PHP - an OO demo OO PHP demonstration - comparing objects and more What are factory and singleton classes? Object Oriented Model - a summary of changes from PHP4 to PHP5 Cue the music, I'm happy. Build on what you already have with OO Planning a hotel refurb - an example of a Gant chart in PHP Think about your design even if you don't use full UML North, Norther and Northest - PHP 5 Objects Don't repeat code - use loops or functions Should I use structured or object oriented? PHP5 lets you say no PHP v Java Object Oriented Programming in PHP C231 - Introduction to C++ Left shift operator on an output stream object - C++ Hello World in C++ - a first program, with the process explained Moving from C to C++ - Structured to Object Oriented - a lesson for engineers C++ - how we teach the language and the concepts behind the language Strings, Garbage Collection and Variable Scope in C++ Make - automating the commands for building and installing Getting your C++ program to run Objects and Inheritance in C++ - an easy start This article Variable Scope in C++ C++ and Perl - why did they do it THAT way? Targetted Advertising Choosing a theme Programming languages - a comparison