For 2023 (and 2024 ...) - we are now fully retired from IT training. We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.
Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!
I am also active in many other area and still look after a lot of web sites - you can find an index ((here)) |
Well House Consultants
You are on the site of
Well House Consultants
who provide
Open Source Training Courses
and business
hotel accommodation. You are welcome to browse and use
our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
|
Perl module P213
Creating your own Classes
Exercises, examples and other material relating to training module P213. This topic is presented on public courses Perl Programming, Perl for Larger Projects, Learning to program in Perl, Perl Programming
In Perl, you can define a class of objects in a module. All the standard Object Oriented facilities are available, and we start with constructors, destructors, instances and accessor methods. Related technical and longer articles Object Orientation in Perl - First StepsIs Perl truly an OO language?
Articles and tips on this subject | updated | 4607 | Classes and object - first steps in Perl 6 Perl 6 has a full object and class implementation ... first simple example [here]. Classes are defined with a class keyword, instance variables with a haskeyword, and methods with a method keyword. There's no "public", "protected", "private" wording, but subsidiary sigils (twigils) ... an extra "." ... | 2016-01-02 | 2169 | When should I use OO techniques? 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 ... | 2014-11-05 | 3833 | Learning to use existing classes in Perl If you've got a whole lot of logic that you want to be able to run on data of a certain type, you'll typically put all of that logic into a grouping of its own - typically known as a package or a class, and you'll then call that logic at a high level from outside the package or class. This is a great ... | 2012-08-18 | 3098 | Learning Object Orientation in Perl through bananas and perhaps Moose Perl 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 ... | 2010-12-21 | 3059 | Object Orientation in an hour and other Perl Lectures I enjoy the occasional course that's different in its design and specification, and yesterday was one of those - more lectures that training, on intermediate and advanced Perl, for a group of eight delegates who were all well experienced at PHP, but Perl "dabblers" to this point. During the day, we ... | 2010-12-04 | 2969 | What does blessing a variable in Perl mean? When you "bless" a variable in Perl, what are you doing?
You are taking the address of the variable, and returning a "reference to an object" - that's a result which contains three pieces of information:
1. The address in memory at which the object is held
2. The type of Perl structure that's held there ... | 2010-09-24 | 2877 | Further more advanced Perl examples I've uploaded a further batch of new examples (that makes around 40 in total!) from the private Perl course that I ran from Wednesday through Saturday last week - many of them adding a new twist on to previous examples. If you read a comment below and thing "that's what I'm looking for an example of", ... | 2010-07-30 (longer) | 2834 | Teaching examples in Perl - third and final part Three part article ... this is part 3. Jump back to part [1] [2]
Following on from two earlier posts, here is the final third of the new examples that I wrote during last week's Perl course, and to which I have added extra documentation over the last couple of days.
P212 More on Character Strings
"Does ... | 2010-06-27 (longer) | 1925 | Introduction to Object Oriented Programming "Object Oriented Programming" is a whole new philosophy for programmers who have been writing short scripts for years, and it can be quite frightening to learn with all these new buzzwords like "overriding", "encapsulation" and "polymorphism" creeping in. It's a beautiful concept and a lovely approach, ... | 2008-12-10 (longer) | 1864 | Object Oriented Perl - First Steps There are some occasions when a new example that I write / a topic that comes up on a course results in an article that's so long that it doesn't fit into the Blog / short article format, but requires a more substantial mechanism.
And so it is for my First steps in Object Oriented Perl examples, written ... | 2008-11-02 | 1664 | Example of OO in Perl Although Perl 5 doesn't use the words "class", "method" or "object" (or any of the other common OO words), it never the less has a very good OO model indeed - here's the source code of an example, together with the result of running the sample. I'll then give you a few clues!
use train;
use bus;
push ... | 2008-06-03 | 227 | Bellringing and Programming and Objects and Perl For the second time this year (and it's only the second month), I find that I have a keen bell-ringer on my programming course ... he's off each evening to meet up with fellow bell-ringers in church towers in Wiltshire, and having a really good time outside course hours as well as during the day. I understand ... | 2008-05-16 | 1435 | Object Oriented Programming in Perl - Course
Perl Review (module P251) Subroutines in Perl (module P209) More than Simple Lists and Hashes! (module P217) Object Orientation: Individual Objects (module Q906) Creating your own Classes (module P213) Object Orientation: Composite Objects (module Q909) More Objects (module P218) Object Orientation: ... | 2007-11-19 | 1320 | Perl for Larger Projects - Object Oriented Perl Perl is a powerful language for short utility scripts - AND a powerful object oriented language too, which is great if you're going to be writing longer applications and / or a suite of programs with shared code.
We run a general course that introduced Perl for everyone and also a more advanced course ... | 2007-08-28 | 983 | Blessing in Perl / Member variable in Ruby How do you decide what member variables you have in an object in Ruby? Well - in Perl, you bless a single hash (or, exceptionally, a list or a scaler), but in Ruby you refer to each variable that you wish to be a member of each object using a preceeding @ character.
Perl:
bless \%abc;
Ruby:
@abc ... | 2006-12-14 (short) | 975 | Answering ALL the delegate's Perl questions During courses, questions arise. "I'll get back to that" could make people feel that I'm brushing something off ... except that I explain, early on, that some questions require a great deal of background knowledge to be answered sensibly. And I keep a list of topics that I'll be getting back to ... | 2006-12-09 | 246 | When to bless a Perl variable Perl's bless function, which turns a reference into an instance of an object, it typically called up as the last action in a constructor method. On today's Perl for Larger Projects course, I was challenged as to when else it might be used. Here's an example - when loading a file of information into ... | 2006-06-05 |
Examples from our training material
3cl | Object Orientation - 2 classes and polymorphism | antest | Introduction to Objects | at2 | Hello Perl Object World | bd1.pm | A simple class, using a scalar to store object information | bd2.pm | A simple class, using a list to store information about each object | bd3.pm | A simple class, storing each object in a hash | big | How Object Inheritance is done in Perl | blessing | Blessing and resultant polymorphism | book.pm | A simple class with a constructor and 2 access methods | ce.pm | Object interface to call events | commute.pm | commute.pm - used in factory demo | higloo | houses and igloos - an OO example | housing.pm | Definition of house, castle and igloo classes | journey | Call to factory class. See ramble.pm and commute.pm | massage.pl | Template object and test program | medium | OO with inheritance demonstrated | message.htp | Sample template for use in other demos | message.pl | None-OO example of template filling | need1 | calling subs via bare words | need2 | Solving the bare word | nsp | variables in packages (autovivification!) | oco | Using the house, castle and igloo classes | peeps.pm | Definition of two classes and polymorphism | ramble.pm | A class that includes a factory method | roar | Sample program to use room.pm | room.pm | A simple class which uses a blessed hash | scemail | quick check of email address format | small | True OO example | spammer | Using global matching to extract all matches | thing.pm | Generic class for use during exercises | tiny | Towards OO in Perl | ub2 | A test program to use the "book" class | ub3 | Another test program to use the book class | ubany.pl | Test program for ub1 ub2 and ub3 classes | usebook | Sample application, constructs and uses book objects | wheretogo | Example that uses commute.pm and ramble.pm |
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from [here].
Topics covered in this module
Resume -- using a class. Background to instance variables. Variables, addresses of variables, contents of variables. A first class. Structure of the class file. The new method. Other methods in the class. Storing information using complex structures. Writing applications that are independent of the class internals. Using a scalar to store information within a class. Using a list to store information within a class. Using a hash to store information within a class. Further capabilities of a hash. The ability to provide generic set and get methods. AUTOLOAD. Summary.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.
Well House Consultants specialise in training courses in
Ruby,
Lua,
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us.
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.
|
|
|