Learning OOP for Flash
Many of you reading this may be struggling transitioning from procedural code styles to Object Oriented Programming. Yes, many developers in Flash are now OOP Jedi, but I have been pretty crazy busy these past few years building projects to lift my head up and look around. I hacked my way through many a job, with a hybrid of procedural spaghetti and my own half baked frameworks ( read: I had no idea what the hell I was doing until it worked).
Once I started into PaperVision3D and more recently JigLibFlash I started looking at the structure of the code libraries and realized there was something vastly different than what I had been doing. You can’t really program in AS3 without encountering Classes (that funny package notation that starts your code, and well the dead give-away “public class” declaration). While you can kind of gloss over the intention of classes you are still standing on the threshold of OOP. Everyone is a little different with how they approach modeling of applications, but what worked for me, was to:I started in the early days of Flash, where coding was really an afterthought and mainly to make buttons work and add links. Everything was done in the timeline including the code. Yes, I admit it, my first AS3 Flash projects were gigantic unwieldy beasts with many heads all crammed roughly into a single giant class.
- Buy a white board. I need to get away from sitting in front of the computer as often as I can, this is a huge gift for me. I can doodle, map out diagrams, and erase and move things around. (much neater than a chalk board )
- Learn to do good analysis before even thinking of coding. This took a lot of self-control. I love to test things out and experiment, but this lead to me always cutting and pasting my experimental code into my production, which led down the path to the dark-side. Really learn to invest in analysis first before even writing any code.
- Invest in the Design phase. Yes, again before you start coding, have a clear map of where you are going. The light really turned on for me, when I realized I could have a big part of my app laid out and it didn’t matter what language I would be using to build it. If my analysis was solid and my design followed logically, the code almost became filling in the blanks.
- Don’t be afraid to go back to the white board and improve the design. Just because you are on to the implementation phase, doesn’t mean you can’t go back and make improvements. Just remember to document those changes. I am such a geek, I even take pictures of my white board to save versions of my models in case I forget or go off on a tangent. I really love that damn board.
So, I wanted to mention a few resources that I have found invaluable in the process of developing my understanding of OOP for Flash. First there are some excellent books, Essential ActionScript 3.0 , by Colin Moock, which is an excellent introduction to the language as well as understanding OOP as it applies to Flash. The killer book for me though is, Advanced ActionScript 3 with Design Patterns , by Joey Lott and Dann Patterson. It not only outlines design patterns for AS3, but gives great direction on the process of deciding which patterns to use. It also gave me great ideas as to how to go about the initial Analysis and Design phases. Lastly, I would recommend exploring the PaperVision3D code. The library of classes are filled with excellent techniques and creative solutions. The intuition and expertise of the core team is a blessing for those seeking models for their own work.
There are many great books, teachers and resources out there on the subject, but these are just a few that really helped me on the journey. If you are not thinking of everything in the world in terms of classes and OOP, don’t worry. Soon, all will be clear. Until then, don’t give up, enlightenment is just beyond the horizon.




Recent Comments