29b9 Learning Object Orientation in Perl through bananas and perhaps Moose
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Learning Object Orientation in Perl through bananas and perhaps Moose

BananasPerl has the most incredbible range of OO facilities (though at times it's overfeatured and a bit old fashioned / tricky to use). So yesterday I wrote a whole series of examples ... and then went on to explore Moose - a module which adds extra keywords and lets you define your classes in a shorter and somewhat more conventional way. See [here] for the moose series - this post introduces the standard facilities in a series of examples.

Bananas.

Our supplier for the hotel provides three types - best bananas, large bananas and small bananas ... "best" are priced per kg, "large" per fruit, and "small" per bunch ... which makes life interesting when we do stock controls and start looking at supply usage, but it did provide a very useful example for yesterday ...

Here are the examples

Setting up a package of hash references - [source]

How to bless the references and thus turn them into objects - [source] - First practical example

Notifying the caller of where errors are triggered in his code via carp, croak and confess - [source]

Use of the caller function to examine the stack frames - [source]

Base class, subclasses, inheritance - [source] First example that shows how we do polymorphism in Perl

How we can use the Universal superclass to find out what our object is / what it can do - [source] can lead to poor class design!

A factory method to construct objects indirectly - [source]

Perl 5's OO facilities are covered on our Perl for Larger Projects course - where we cover OO principles too as necessary. Moose can be introduced on private courses (it's a bit of an interim thing prior to Perl 6 though), or if you're on the public course let me know you would like to cover it and I'll run an extra session one evening.

(written 2010-12-21) 296c

 
Associated topics are indexed under
P310 - Perl - Moose
  [3097] Making Perl class definitions more conventional and shorter - (2010-12-20)

P213 - Perl - Creating your own Classes
  [3833] Learning to use existing classes in Perl - (2012-08-10)
  [3059] Object Orientation in an hour and other Perl Lectures - (2010-11-18)
  [2969] What does blessing a variable in Perl mean? - (2010-09-24)
  [2877] Further more advanced Perl examples - (2010-07-19)
  [2834] Teaching examples in Perl - third and final part - (2010-06-27)
  [2169] When should I use OO techniques? - (2009-05-11)
  [1925] Introduction to Object Oriented Programming - (2008-12-06)
  [1864] Object Oriented Perl - First Steps - (2008-11-01)
  [1664] Example of OO in Perl - (2008-06-03)
  [1435] Object Oriented Programming in Perl - Course - (2007-11-18)
  [1320] Perl for Larger Projects - Object Oriented Perl - (2007-08-25)
  [983] Blessing in Perl / Member variable in Ruby - (2006-12-14)
  [975] Answering ALL the delegate's Perl questions - (2006-12-09)
  [246] When to bless a Perl variable - (2005-03-15)
  [227] Bellringing and Programming and Objects and Perl - (2005-02-25)

P218 - Perl - More Objects
  [4096] Perl design patterns example - (2013-05-20)
  [3941] Building an object based on another object in Perl - (2012-12-03)
  [3581] Perl - calls to methods that use => - what do they mean? - (2012-01-16)
  [3377] What do I mean when I add things in Perl? - (2011-08-02)
  [2972] Some more advanced Perl examples from a recent course - (2010-09-27)
  [2876] Different perl examples - some corners I rarely explore - (2010-07-18)
  [2811] Igloos melt in the summer, but houses do not - (2010-06-15)
  [2717] The Multiple Inheritance Conundrum, interfaces and mixins - (2010-04-11)
  [2651] Calculation within objects - early, last minute, or cached? - (2010-02-26)
  [2427] Operator overloading - redefining addition and other Perl tricks - (2009-09-27)
  [1949] Nuclear Physics comes to our web site - (2008-12-17)
  [1819] Calling base class constructors - (2008-10-03)
  [1665] Factory method example - Perl - (2008-06-04)
  [1217] What are factory and singleton classes? - (2007-06-04)
  [930] -> , >= and => in Perl - (2006-11-18)
  [831] Comparison of Object Oriented Philosophy - Python, Java, C++, Perl - (2006-08-13)
  [656] Think about your design even if you don't use full UML - (2006-03-24)
  [592] NOT Gone phishing - (2006-02-05)
  [588] Changing @INC - where Perl loads its modules - (2006-02-02)
  [531] Packages in packages in Perl - (2005-12-16)


Back to
Making Perl class definitions more conventional and shorter
Previous and next
or
Horse's mouth home
Forward to
Perl - database access - DBD, DBI and DBIx modules
Some other Articles
AND and OR operators - what is the difference between logical and bitwise varieties?
The week before Christmas
Looking ahead and behind in Regular Expressions - double matching
Perl - database access - DBD, DBI and DBIx modules
Learning Object Orientation in Perl through bananas and perhaps Moose
Contrast in pictures
The Christmas Season has arrived
Setting your user_agent in PHP - telling back servers who you are
How many toilet rolls - hotel inventory and useage
4086 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 at 50 posts per page

454d
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., 2013: 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/3098_Lea ... Moose.html • PAGE BUILT: Sat Feb 23 12:39:13 2013 • BUILD SYSTEM: wizard
0