Main Content
Object Oriented Tcl Archive - Originally posted on "The Horse's Mouth" - 2008-02-02 08:45:17 - Graham Ellis
Object Oriented Tcl ([incr-Tcl]) is darned good - but it's only a requirement in a small proportion of the Tcl Training Courses that I give. So it was with real pleasure that I spent some time yesterday writing an example in front of my class in the Nottingham area to show them just how fabulous it is!
The source code of the example I came up with is here , and I have added a whole lot of comments in to it this morning so that readers can see a "hello world" type example of how Tcl implements classes, objects, inheritance, encapsulation, security matters, polymorphism and the rest. And for readers who would like a deeper explanation, you'll find ongoing links ... or I would love to see you on a course!
P.S. Yes - we can train you whether or not you have prior OO experience; our training resources include modules that overview straightforward objects , talk about how objects can be build from other objects and introduce you to OO design principles so you can start making the very best of the facilities
Here's what you get when you run the code I've linked to above.
Dorothy:stuffing grahamellis$ tclsh exv
East Midlands !!!!! place1 - 960 40
First Great Western !!!!! place2 - 1250 25
Connex !!!!! place3 - 0
FGW !!!!! place4 - 5264 94
Dorothy:stuffing grahamellis$
Some other articles
T245 - [incr-Tcl] Using Object Oriented Tcl and the Tk toolkit together - real life example Objects in Tcl - iTcl - updated first steps example Private and Public - and things between Introduction to Object Oriented Programming Calling base class constructors This article Think about your design even if you don't use full UML Object Orientation in Tcl - [incr-Tcl] 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 When should I use OO techniques? Teaching Object Oriented Java with Students and Ice Cream This article 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