Main Content
Associative objects - one object within another. Archive - Originally posted on "The Horse's Mouth" - 2016-01-20 17:13:22 - Graham Ellis
A new demonstration of the use of objects within objects - [here] from today's PHP course.
Faced with a class of public transport departure times (as strings) and run times (in pinutes), I added a class of time objects so that I could encapsulate the calculations of time into their own class.
It's a very common practise to use objects within objects ... simply not done too often with our own objects on a training course due to pressure of time!
Some other articles
Q907 - Object Orientation: Design Techniques This article 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 When should I use OO techniques? 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 H108 - Objects in PHP This article 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 When should I use OO techniques? 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