CFC's and Object Orientation
I've always wanted to write something up about CFC's and Object Orientation from a newbie's perspective. I learned ColdFusion on my own using books and mailing lists and forums, coming into it from having learned HTML and CSS on my own. So i've never had any formal training in programming.
I suppose a lot of people have learned CF that way. I also work alone, so i don't get the opportunity to rub shoulders with people more experienced than i am too often.
When CFC's first came out in CFMX6, i resolved that i would learn OO, largely influenced by Hal Helms. I bought a bunch of introductory books, studied them carefully, read everything i could online, downloaded MachII once it became available and got utterly lost. While i understood the theory of OO fairly well from the get-go, i had no idea AT ALL how to implement it in practice. It was downright embarrassing - ok ... humiliating.
The books talked about aggregation, composition and inheritance, about polymorphism and encapsulation, and i understood it when i read it in the books. I learned to understand UML diagrams and stared at diagrams of patterns and read and reread the texts. And reread them again.
The weird thing is that i didn't have a clue how to implement those concepts in CFC's. I certainly knew about the extends attribute of the cfcomponent tag for instance. But in practice, i didn't know which way it worked. It seemed like inheritance should go from the parent component to the child component like it does in life, so i was instantiating the parent component, thinking the parent "owned the goods" and was first in line, and wondering why nothing was being inherited in the child. "Maybe this doesn't work with CFC's like it does in object oriented languages", i thought.
After inheritance didn't work the way i thought it should, i somehow came to the conclusion that it wasn't implemented in ColdFusion, or implemented properly, or something in between. It took me a lot longer than it should have to understand that i had it upside down.
The stuff i was reading was talking about patterns and the developmental process behind the OO architectural design of applications. It all made sense to me. That's where i wanted to go. But there was nothing available that just demonstrated in a very simple and clear way the basic mechanics of using CFC's together. Not even in Hal Helms' Understanding CFC's book. It went from a basic discussion of OO theory into explaining how CFC's are not truly encapsulated, why that's wrong from an OO perspective, and suggesting workarounds.
Eventually, i figured it out. It took me awhile just experimenting and making mistakes to understand what there was to understand at this level. I fumbled around blindly for months, attempting to build my first OO application. All the time i didn't fully understand how to get these damn CFC's to work together. There were all these walls between them and i wasn't used to that. And inheritance didn't inherit the way i got it in my head that it should. And i was trying to understand Hal's workarounds in his CFC book, but i didn't know what it was i was supposed to be working around.
Looking back, i can say without a doubt that i was profoundly lost. I was more lost than anyone i was emailing on the lists for help - the ones with CS degrees and perhaps a few OO languages under their belt - probably ever realized.
And I'm still completely embarrassed to admit it. But that's what happens when you try to learn this stuff on your own.
When i see new people coming in trying to pick up Model-Glue or some other OO-based framework, and there's that basic confusion underlying their posts, i have a LOT of compassion for them. Really a lot. So if nobody minds too much, i'm going to backtrack from my last post about autowiring and using ColdSpring with MG by a long way, and post some really basic stuff about using CFC's, and using them together with each other, in the Newbie Cafe.
If it never helps anyone else, at least it'll be somewhat therapeutic for me, as in, "OK, i managed to get this far on my own, now maybe i can go on from here." :-) n


Another abstraction layer is needed: thinking about a domain in terms of indipendent but collaborating object: at this first stage, we are notinterested to implementation details.
And don't forget that oop principles are to be ascribed to Plato (Platone) and i seriously doubt his was thinking in terms of inheritance, composition, aggregation and so on, may be only polimorphism.
alla prossima
I know just how you felt and am looking forwards to reading your "introducing OO" posts as there is a long path from reading OO books to being comfortable with what should go in which CFCs. To be fair, once you've gone a certain distance, a framework can help out by making some pretty good suggestions, but there is still a real need for more introductory material. You might also want to let Brian Rinaldi know and see if he'll keep his "OO and Frameworks List" updated or not. Also I know Nic Tunney has a site where you might be able to repost some of the articles. There are various other resources (I think there is a CF OO wiki somewhere) you might also want to donate a copy of some of the posts if you get a chance!!!
Best Wishes,
Peter
Thanks for a great post. I have also learned CF the same way, on my own using books, lists, forums, etc. Coming into it from a graphic designer background and having learned HTML and CSS on my own, and never had any formal training in programming either. I also work alone, so I don't get either the opportunity to rub shoulders with other people. I feel sometimes lost on how to start implementing an API and stay away from the spaghetti code. This post describes me where I am now, sometimes feels embarrassing and humiliating not even been able to know how to ask the technical questions to move ahead. One can download all the examples API and framework out there, but without any understanding or perspective on how thing works, these are useless. I'm looking forward to your posts to help me make sense and go on from here.
Maybe you should blog your experiences? It'll help people going through the same things, and when you post something really stupid (which I usually do about once a day), everyone will jump in to tell you how wrong you are. It is a great way to learn!
And nobody has got this stuff figured. We're all just kids playing in the same sandbox!
Best Wishes,
Peter
I think you are hitting right on the head where a lot of ColdFusion developers are and where they are trying to go. I've been trying to get my head around object oriented ideas but have had a difficult time trying to understand why and how to implement it in my development. I think you're doing a good job in describing the confusion regarding oo ideas and working through how they are beneficial and implemented in CF. Keep up the great posts!
http://www.ooglossary.com/