Re: [Flashcoders] Flair Pattern bad mixins good (?)
Funny enough, they are also less widely known as the Four Gangsters after a someone with limited English skills referred to them this way at a conference. Perhaps it was actually English skillz ;-) ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Flair Pattern bad mixins good (?)
My 0.02: GoF makes me very sleepy - I find it very dry and the chapters very long winded. (Sorry GoF'rs) Wait's for lightning bolt from on high... I have read it through once and understood some of it, but I have found snippets of information about patterns online which seem much clearer and less sleep inducing. I liked Colin Moock's chapters on patterns from the Essential ActionScript 2 books because they taught by tutorials which work towards a finished example rather than by printing snippets of code. I have learnt some C++, but don't code in it so I can sort of understand what is going on in GoF. My AS is better and I find that doing the Moock examples helped me more. I would be interested to know if Head First Design Patterns follows the same process as Moock - learn by doing. I can handle that, although I will keep delving into GoF, keeping an oven timer handy to bring me back from the brink. :) Erik Bianchi wrote: I think GoF is a great reference book but the writers aren't very gentle about how they present information. It is very blunt and straight to the point. Reminds me a bit of an old calculus book. The first time I read the GoF book I thought my head was going to explode. A few years later though when I'm referencing a pattern it's a lot more clear now for some reason. Also, It be nice if they revised using java or C# rather then C++. -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Ham Sent: Tuesday, January 30, 2007 7:02 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) Been a while since I've posted here, a few years I think. I miss the geek tangents / debates. =) Good man! Seriously, the world affords precious few opportunities to truly geek out on design patterns and such. Internet mailing lists excepted of course. I have the Head First Design Patterns book, and I have to say I like it, in spite of its profusion of clip art and cheesy humor. Despite these stylistic affronts, it presents the material in a way that is easy to learn. What's the consensus on the GoF book? I know it's a classic, but so is Ulysses and dog if I can read that. I don't have a CS background-- Flash is about as far as my programming expertise extends--so the Head First style works for me. Is GoF accessible for people who don't program in C++? OK DAH ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Flair Pattern bad mixins good (?)
Mmmm I really want a bagel now!!! Damn that decor On 1/30/07, JOR [EMAIL PROTECTED] wrote: A decorator object composites the object it wishes to decorate and is used in it's place. Since the decorator inherits from the the same base class as the object it decorates they can both be used interchangeably through polymorphism. consider something like this: var myBagel:Bagel = new Bagel(); trace (myBagel.getCalories()); // 200 // Add creamcheese to my bagel myBagel = new CreamCheeseDecorator(myBagel); trace (myBagel.getCalories()); // 300 // Add lox to my bagel myBagel = new LoxDecorator(myBagel); trace (myBagel.getCalories()); // 330 //--- // bagel looks something like this public class Bagel { public function getCalories ():uint { return 200; } } //inside the decorator is something like this: public class CreamCheeseDecorator extends Bagel { private var _bagel:Bagel; public function CreamCheeseDecorator (bagel:Bagel) { _bagel = bagel; } public function getCalories ():uint { return _bagel.getCalories() + 100; } } //inside the decorator is something like this: public class LoxDecorator extends Bagel { private var _bagel:Bagel; public function LoxDecorator (bagel:Bagel) { _bagel = bagel; } public function getCalories ():uint { return _bagel.getCalories() + 30; } } You can add more Bagel types like EggBagel and EverythingBagel and more Decorator objects like Butter and use them all interchangeably. note, this untested code, I just typed it out in the post so their might be typos. James O'Reilly — Consultant Adobe Certified Flash Expert http://www.jamesor.com Design • Code • Train Erik Bianchi wrote: Opps meant to add: that's my interpretation anyways. I could be wrong. I'm wrong all the time. In fact I consider myself a professional mistake maker. -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erik Bianchi Sent: Tuesday, January 30, 2007 1:49 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Flair Pattern bad mixins good (?) A decorator is meant to be dynamic. It adds responsibilities to an object at run time. You take ComponentA and add methods to it on mouseclick, that's a decorator. ComponentB is made up of ComponentC and ClassA, that's a composite. My implementation of a mixin which I borrowed from java is really just using composites + interfaces to emulate multiple inheritance. Decorators and composites are similar however in that they are both structural patterns and define an interface for communicating between parent and child components / classes. Best, -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 9:00 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) How is this any different from a Decorator/Wrapper? Looks like a double decorator. On 1/30/07, Erik Bianchi [EMAIL PROTECTED] wrote: Actually my definition of a mixin is very strict compared to a decorator; it uses design by contract, composition and declares type: Class ClassA implements IClassB, IClassC { private var classB:ClassB; private var classC:ClassC; private function classBMethod():Boolean{...}; private function classCMethod():Number{...}; } -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 12:09 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) On 1/29/07, David Ham [EMAIL PROTECTED] wrote: startObjectDrag triggered by obj_mc.onPress checkForSnaptriggered bysetInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease This looks more like the Broadcaster pattern or the Event Dispatcher (a.k.a. Observer) pattern than Decorator. (Also, it might be better to tie checkForSnap to mouseMove.) Personally, I'm not a big fan of mix-ins because, well, they're kind of sloppy. They involve tinkering with stuff that should be off-limits (and is in AS3, I think). Using mix-ins, you could accidentally use a non-function as a function. That can't happen if you stick to strictly-typed programming. -- T. Michael Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier
RE: [Flashcoders] Flair Pattern bad mixins good (?)
Yeah, the GoF book is definitely like reading a calculus textbook. It's dry and to the point and the examples are in Smalltalk and some C++, which means a lot of cross-referencing with google. The concepts they discuss and the examples they give are helpful to a point but code examples you can't understand definitely get in the way. GoF's is good reference book worth owning, and once you grasp design patterns more firmly, you'll probably get more from it. Head First is a lot more accessible out the gate. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Flair Pattern bad mixins good (?)
If you feel like this: GoF makes me very sleepy - I find it very dry and the chapters very long winded. (Sorry GoF'rs) then: I would be interested to know if Head First Design Patterns follows the same process as Moock - learn by doing. I can handle that, although I will keep delving into GoF, keeping an oven timer handy to bring me back from the brink. You will probably get a lot out of this book. The examples are (within reason) interesting, and as with all the head first books and they've made a very concerted effort to liven up what is to some a fairly dry topic. I learnt a lot from this book; now if i need to research a particular pattern, mostly i'll use the internet. http://www.google.com/codesearch is great for examples. Also would highly recommend ActionScript 3 Design Patterns by Joey Lott and Danny Patterson, for any actionscript programmers wanting to understand appliying patterns in flash/flex, it covers most of the main ones. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Flair Pattern bad mixins good (?)
I've actually been reading through Head First Design Patterns, and think it's a great book! It uses a lot of example code but they are well thought out and clearly demonstrate the uses of the patterns. Granted, many of their examples are doing ridiculous things like simulating the actions of ducks, turkeys and chickens through text output, there are other examples that apply them to real-world scenarios. What I really like about the book is how the authors compare the different patterns head to head and explain how one is different than another. Another thing I like about the Head First Design Patterns book is that it states a lot of the advantages and disadvantages of the patterns and how to work around them. I have another book on my desk, Design Patterns by Gamma, Helm, Johnson and Vissides, that reads very much like a college text book - it has built in book marking ribbons, which is nice. Is this the one by the GoF? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Glen Pike Sent: Wednesday, January 31, 2007 12:57 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) My 0.02: GoF makes me very sleepy - I find it very dry and the chapters very long winded. (Sorry GoF'rs) Wait's for lightning bolt from on high... I have read it through once and understood some of it, but I have found snippets of information about patterns online which seem much clearer and less sleep inducing. I liked Colin Moock's chapters on patterns from the Essential ActionScript 2 books because they taught by tutorials which work towards a finished example rather than by printing snippets of code. I have learnt some C++, but don't code in it so I can sort of understand what is going on in GoF. My AS is better and I find that doing the Moock examples helped me more. I would be interested to know if Head First Design Patterns follows the same process as Moock - learn by doing. I can handle that, although I will keep delving into GoF, keeping an oven timer handy to bring me back from the brink. :) Erik Bianchi wrote: I think GoF is a great reference book but the writers aren't very gentle about how they present information. It is very blunt and straight to the point. Reminds me a bit of an old calculus book. The first time I read the GoF book I thought my head was going to explode. A few years later though when I'm referencing a pattern it's a lot more clear now for some reason. Also, It be nice if they revised using java or C# rather then C++. -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Ham Sent: Tuesday, January 30, 2007 7:02 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) Been a while since I've posted here, a few years I think. I miss the geek tangents / debates. =) Good man! Seriously, the world affords precious few opportunities to truly geek out on design patterns and such. Internet mailing lists excepted of course. I have the Head First Design Patterns book, and I have to say I like it, in spite of its profusion of clip art and cheesy humor. Despite these stylistic affronts, it presents the material in a way that is easy to learn. What's the consensus on the GoF book? I know it's a classic, but so is Ulysses and dog if I can read that. I don't have a CS background-- Flash is about as far as my programming expertise extends--so the Head First style works for me. Is GoF accessible for people who don't program in C++? OK DAH ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com This e-mail and its attachments are intended only for the use of the addressee(s) and may contain privileged, confidential or proprietary information. If you are not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination
Re: [Flashcoders] Flair Pattern bad mixins good (?)
In addition the the books already mentioned, I highly recommend Refactoring by Martin Fowler and Refactoring to Patterns by Kerievsky (in that order). Together they show you how to adapt code you've already created to design patterns without breaking it in the process. The examples are in Java, which is very similar to ActionScript. -- T. Michael Keesey Director of Technology Exopolis, Inc. 2894 Rowena Avenue Ste. B Los Angeles, California 90039 -- The Dinosauricon: http://dino.lm.com Parry Carney: http://parryandcarney.com ISPN Forum: http://www.phylonames.org/forum/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Flair Pattern bad mixins good (?)
On 1/29/07, David Ham [EMAIL PROTECTED] wrote: startObjectDrag triggered by obj_mc.onPress checkForSnaptriggered bysetInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease This looks more like the Broadcaster pattern or the Event Dispatcher (a.k.a. Observer) pattern than Decorator. (Also, it might be better to tie checkForSnap to mouseMove.) Personally, I'm not a big fan of mix-ins because, well, they're kind of sloppy. They involve tinkering with stuff that should be off-limits (and is in AS3, I think). Using mix-ins, you could accidentally use a non-function as a function. That can't happen if you stick to strictly-typed programming. -- T. Michael Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Flair Pattern bad mixins good (?)
Hi, maybe a dumm question but would it be off limits to express this changing-behaviour in the interface? For example in such an object as you are describing, you could add a method setResizeBehaviour(r:ResizeBehaviorImpl) (in pseudo then). Then you can change a certain type of behavior at runtime and it is explicit in the interface. Assuming you don't want to use decorator that is. Or is this not done? greetz JC On 1/30/07, T. Michael Keesey [EMAIL PROTECTED] wrote: On 1/29/07, David Ham [EMAIL PROTECTED] wrote: startObjectDrag triggered by obj_mc.onPress checkForSnaptriggered bysetInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease This looks more like the Broadcaster pattern or the Event Dispatcher (a.k.a. Observer) pattern than Decorator. (Also, it might be better to tie checkForSnap to mouseMove.) Personally, I'm not a big fan of mix-ins because, well, they're kind of sloppy. They involve tinkering with stuff that should be off-limits (and is in AS3, I think). Using mix-ins, you could accidentally use a non-function as a function. That can't happen if you stick to strictly-typed programming. -- T. Michael Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Flair Pattern bad mixins good (?)
Just to clarify mixins and strategy are a bit different. One is more structural while the other is more behavioral. Also mixins aren't really considered a design pattern but it is made up of composites, proxies / facades (all structural design patterns ) + interfaces. They are used to emulate multiple inheritance. So something could have functionality of say a MovieClip and a Sound Object. The strategy design pattern is used to encapsulate interchangeable logic (layout, validation, etc). However, I think what you're really asking is more of an architectural question so I would take a look at ARP and Cairngorm. Cairngorm is labeled for Flex but can be easily adapted to Flash development. Similarly ARP is thought of as being used for slides but can be adapted to using MovieClips. Just a note, Cairngorm is less prescriptive about how to structure your views (which may or may not be a good thing depending on your disposition) so if you're already pretty far a long in your development check out Cairngorm Cairngorm: http://labs.adobe.com/wiki/index.php/Cairngorm ARP: http://www.osflash.org/ARP If you want want something a bit more fine grained you can do a search on MVP (Model View Presenter) or MVC (Model View Controller). Both are similar but have different rules of communication and responsibilities. -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Ham Sent: Monday, January 29, 2007 11:40 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) OK, this is helping a lot. And Steven I see what you mean, poor Flair is starting to look a little meager now. In my app, I have several different states. Each state sets itself up by initializing variables and drawing its various pieces, and the final piece is to subscribe various parts of the app to events that happen in other parts. So in one state I have methods like: onRoomObjectPress() onRoomObjectRelease() that are triggered by onPress and onRelease events in my object movieclips. These onSomething() methods contain the core logic of the app--code to resize clips or process values or what have you. This structure is good because I know where to look to track down where things happen, but its bad because sometimes a bunch of things are supposed to happen at once and those onSomething() methods get hairy. So in this new mixin strategy (which does look a lot like Strategy, thanks James!), should I design my Snappable class to have methods that would map to movieclip events, such as: startObjectDrag triggered by obj_mc.onPress checkForSnaptriggered bysetInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease Am I headed in the right direction? Thank you again, this OK DAH The theory of mixins originated from multiple inheritance programming languages such as C++. So for example: Say you wanted to make an object dragable, clickable and resizable. You would then create separate classes called: Dragable, Clickable and Resizable (common naming convention for a mixin). Then your base class would just inherit form those 3 classes. Since AS2 doesn't support multiple inheritances you can emulate a mixin using interfaces and composed classes. For example: IClickable, IDragable, IResizable So then your AS2 class would say: Class MyClass extends Whatever implements IClickable, IDragable, IResizable Those interfaces just specify what methods your class has to support. From there you could have a class (or a consolidated class) implement that functionality private var clickable:Clickable = new Clickable(); private var dragable:Dragable = new Dragable(); private var resizeable:Resizeable = new Resizeable(); from there you just forward / wire the appropriate methods to its corresponding instances. public function startResize() { this.resizeable.startResize(); } Or for arguments: public function startResize() { this.resizeable.apply.(this.resizeable.startResize, arguments); } You could get even more fancy by externalizing those classes so based on various rules you could pass in different resize logic, etc. Anyhow, hope that gets the gears turning. =) DISCLAIMER: Didn't spell check or test anything in the compiler so maybe some typos. =) -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Ham Sent: Monday, January 29, 2007 7:12 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) Anyhow I tend not to use decorators (matter of personal taste). I prefer to not Frankenstein an object at runtime and rather use mixins (composition + interfaces). Ah, thank you, now we are getting somewhere! Tell me about mixins. I have used EventDispatcher before, but I am unfamiliar with the theory behind
RE: [Flashcoders] Flair Pattern bad mixins good (?)
Actually my definition of a mixin is very strict compared to a decorator; it uses design by contract, composition and declares type: Class ClassA implements IClassB, IClassC { private var classB:ClassB; private var classC:ClassC; private function classBMethod():Boolean{...}; private function classCMethod():Number{...}; } -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 12:09 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) On 1/29/07, David Ham [EMAIL PROTECTED] wrote: startObjectDrag triggered by obj_mc.onPress checkForSnaptriggered bysetInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease This looks more like the Broadcaster pattern or the Event Dispatcher (a.k.a. Observer) pattern than Decorator. (Also, it might be better to tie checkForSnap to mouseMove.) Personally, I'm not a big fan of mix-ins because, well, they're kind of sloppy. They involve tinkering with stuff that should be off-limits (and is in AS3, I think). Using mix-ins, you could accidentally use a non-function as a function. That can't happen if you stick to strictly-typed programming. -- T. Michael Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Flair Pattern bad mixins good (?)
How is this any different from a Decorator/Wrapper? Looks like a double decorator. On 1/30/07, Erik Bianchi [EMAIL PROTECTED] wrote: Actually my definition of a mixin is very strict compared to a decorator; it uses design by contract, composition and declares type: Class ClassA implements IClassB, IClassC { private var classB:ClassB; private var classC:ClassC; private function classBMethod():Boolean{...}; private function classCMethod():Number{...}; } -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 12:09 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) On 1/29/07, David Ham [EMAIL PROTECTED] wrote: startObjectDrag triggered by obj_mc.onPress checkForSnaptriggered bysetInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease This looks more like the Broadcaster pattern or the Event Dispatcher (a.k.a. Observer) pattern than Decorator. (Also, it might be better to tie checkForSnap to mouseMove.) Personally, I'm not a big fan of mix-ins because, well, they're kind of sloppy. They involve tinkering with stuff that should be off-limits (and is in AS3, I think). Using mix-ins, you could accidentally use a non-function as a function. That can't happen if you stick to strictly-typed programming. -- T. Michael Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- T. Michael Keesey Director of Technology Exopolis, Inc. 2894 Rowena Avenue Ste. B Los Angeles, California 90039 -- The Dinosauricon: http://dino.lm.com Parry Carney: http://parryandcarney.com ISPN Forum: http://www.phylonames.org/forum/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Flair Pattern bad mixins good (?)
A decorator is meant to be dynamic. It adds responsibilities to an object at run time. You take ComponentA and add methods to it on mouseclick, that's a decorator. ComponentB is made up of ComponentC and ClassA, that's a composite. My implementation of a mixin which I borrowed from java is really just using composites + interfaces to emulate multiple inheritance. Decorators and composites are similar however in that they are both structural patterns and define an interface for communicating between parent and child components / classes. Best, -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 9:00 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) How is this any different from a Decorator/Wrapper? Looks like a double decorator. On 1/30/07, Erik Bianchi [EMAIL PROTECTED] wrote: Actually my definition of a mixin is very strict compared to a decorator; it uses design by contract, composition and declares type: Class ClassA implements IClassB, IClassC { private var classB:ClassB; private var classC:ClassC; private function classBMethod():Boolean{...}; private function classCMethod():Number{...}; } -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 12:09 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) On 1/29/07, David Ham [EMAIL PROTECTED] wrote: startObjectDrag triggered by obj_mc.onPress checkForSnaptriggered bysetInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease This looks more like the Broadcaster pattern or the Event Dispatcher (a.k.a. Observer) pattern than Decorator. (Also, it might be better to tie checkForSnap to mouseMove.) Personally, I'm not a big fan of mix-ins because, well, they're kind of sloppy. They involve tinkering with stuff that should be off-limits (and is in AS3, I think). Using mix-ins, you could accidentally use a non-function as a function. That can't happen if you stick to strictly-typed programming. -- T. Michael Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- T. Michael Keesey Director of Technology Exopolis, Inc. 2894 Rowena Avenue Ste. B Los Angeles, California 90039 -- The Dinosauricon: http://dino.lm.com Parry Carney: http://parryandcarney.com ISPN Forum: http://www.phylonames.org/forum/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Flair Pattern bad mixins good (?)
Opps meant to add: that's my interpretation anyways. I could be wrong. I'm wrong all the time. In fact I consider myself a professional mistake maker. -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erik Bianchi Sent: Tuesday, January 30, 2007 1:49 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Flair Pattern bad mixins good (?) A decorator is meant to be dynamic. It adds responsibilities to an object at run time. You take ComponentA and add methods to it on mouseclick, that's a decorator. ComponentB is made up of ComponentC and ClassA, that's a composite. My implementation of a mixin which I borrowed from java is really just using composites + interfaces to emulate multiple inheritance. Decorators and composites are similar however in that they are both structural patterns and define an interface for communicating between parent and child components / classes. Best, -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 9:00 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) How is this any different from a Decorator/Wrapper? Looks like a double decorator. On 1/30/07, Erik Bianchi [EMAIL PROTECTED] wrote: Actually my definition of a mixin is very strict compared to a decorator; it uses design by contract, composition and declares type: Class ClassA implements IClassB, IClassC { private var classB:ClassB; private var classC:ClassC; private function classBMethod():Boolean{...}; private function classCMethod():Number{...}; } -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 12:09 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) On 1/29/07, David Ham [EMAIL PROTECTED] wrote: startObjectDrag triggered by obj_mc.onPress checkForSnaptriggered bysetInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease This looks more like the Broadcaster pattern or the Event Dispatcher (a.k.a. Observer) pattern than Decorator. (Also, it might be better to tie checkForSnap to mouseMove.) Personally, I'm not a big fan of mix-ins because, well, they're kind of sloppy. They involve tinkering with stuff that should be off-limits (and is in AS3, I think). Using mix-ins, you could accidentally use a non-function as a function. That can't happen if you stick to strictly-typed programming. -- T. Michael Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- T. Michael Keesey Director of Technology Exopolis, Inc. 2894 Rowena Avenue Ste. B Los Angeles, California 90039 -- The Dinosauricon: http://dino.lm.com Parry Carney: http://parryandcarney.com ISPN Forum: http://www.phylonames.org/forum/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Flair Pattern bad mixins good (?)
A decorator object composites the object it wishes to decorate and is used in it's place. Since the decorator inherits from the the same base class as the object it decorates they can both be used interchangeably through polymorphism. consider something like this: var myBagel:Bagel = new Bagel(); trace (myBagel.getCalories()); // 200 // Add creamcheese to my bagel myBagel = new CreamCheeseDecorator(myBagel); trace (myBagel.getCalories()); // 300 // Add lox to my bagel myBagel = new LoxDecorator(myBagel); trace (myBagel.getCalories()); // 330 //--- // bagel looks something like this public class Bagel { public function getCalories ():uint { return 200; } } //inside the decorator is something like this: public class CreamCheeseDecorator extends Bagel { private var _bagel:Bagel; public function CreamCheeseDecorator (bagel:Bagel) { _bagel = bagel; } public function getCalories ():uint { return _bagel.getCalories() + 100; } } //inside the decorator is something like this: public class LoxDecorator extends Bagel { private var _bagel:Bagel; public function LoxDecorator (bagel:Bagel) { _bagel = bagel; } public function getCalories ():uint { return _bagel.getCalories() + 30; } } You can add more Bagel types like EggBagel and EverythingBagel and more Decorator objects like Butter and use them all interchangeably. note, this untested code, I just typed it out in the post so their might be typos. James O'Reilly — Consultant Adobe Certified Flash Expert http://www.jamesor.com Design • Code • Train Erik Bianchi wrote: Opps meant to add: that's my interpretation anyways. I could be wrong. I'm wrong all the time. In fact I consider myself a professional mistake maker. -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erik Bianchi Sent: Tuesday, January 30, 2007 1:49 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Flair Pattern bad mixins good (?) A decorator is meant to be dynamic. It adds responsibilities to an object at run time. You take ComponentA and add methods to it on mouseclick, that's a decorator. ComponentB is made up of ComponentC and ClassA, that's a composite. My implementation of a mixin which I borrowed from java is really just using composites + interfaces to emulate multiple inheritance. Decorators and composites are similar however in that they are both structural patterns and define an interface for communicating between parent and child components / classes. Best, -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 9:00 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) How is this any different from a Decorator/Wrapper? Looks like a double decorator. On 1/30/07, Erik Bianchi [EMAIL PROTECTED] wrote: Actually my definition of a mixin is very strict compared to a decorator; it uses design by contract, composition and declares type: Class ClassA implements IClassB, IClassC { private var classB:ClassB; private var classC:ClassC; private function classBMethod():Boolean{...}; private function classCMethod():Number{...}; } -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 12:09 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) On 1/29/07, David Ham [EMAIL PROTECTED] wrote: startObjectDrag triggered by obj_mc.onPress checkForSnaptriggered bysetInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease This looks more like the Broadcaster pattern or the Event Dispatcher (a.k.a. Observer) pattern than Decorator. (Also, it might be better to tie checkForSnap to mouseMove.) Personally, I'm not a big fan of mix-ins because, well, they're kind of sloppy. They involve tinkering with stuff that should be off-limits (and is in AS3, I think). Using mix-ins, you could accidentally use a non-function as a function. That can't happen if you stick to strictly-typed programming. -- T. Michael Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Flair Pattern bad mixins good (?)
I've seen examples of it both ways where a decorated object maintains the objects interface or it adds additional methods so it breaks polymorphism. Don't have the GOF book with me to reference so no idea what they actually outlined. Doing a quick search wikipedia states 1 to 1 where doFactory shows otherwise. On a side note I love doFactory as they offer simple UML diagrams and sample code (both conceptual and real world). Been a while since I've posted here, a few years I think. I miss the geek tangents / debates. =) -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of JOR Sent: Tuesday, January 30, 2007 3:55 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) A decorator object composites the object it wishes to decorate and is used in it's place. Since the decorator inherits from the the same base class as the object it decorates they can both be used interchangeably through polymorphism. consider something like this: var myBagel:Bagel = new Bagel(); trace (myBagel.getCalories()); // 200 // Add creamcheese to my bagel myBagel = new CreamCheeseDecorator(myBagel); trace (myBagel.getCalories()); // 300 // Add lox to my bagel myBagel = new LoxDecorator(myBagel); trace (myBagel.getCalories()); // 330 //--- // bagel looks something like this public class Bagel { public function getCalories ():uint { return 200; } } //inside the decorator is something like this: public class CreamCheeseDecorator extends Bagel { private var _bagel:Bagel; public function CreamCheeseDecorator (bagel:Bagel) { _bagel = bagel; } public function getCalories ():uint { return _bagel.getCalories() + 100; } } //inside the decorator is something like this: public class LoxDecorator extends Bagel { private var _bagel:Bagel; public function LoxDecorator (bagel:Bagel) { _bagel = bagel; } public function getCalories ():uint { return _bagel.getCalories() + 30; } } You can add more Bagel types like EggBagel and EverythingBagel and more Decorator objects like Butter and use them all interchangeably. note, this untested code, I just typed it out in the post so their might be typos. James O'Reilly - Consultant Adobe Certified Flash Expert http://www.jamesor.com Design . Code . Train Erik Bianchi wrote: Opps meant to add: that's my interpretation anyways. I could be wrong. I'm wrong all the time. In fact I consider myself a professional mistake maker. -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erik Bianchi Sent: Tuesday, January 30, 2007 1:49 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Flair Pattern bad mixins good (?) A decorator is meant to be dynamic. It adds responsibilities to an object at run time. You take ComponentA and add methods to it on mouseclick, that's a decorator. ComponentB is made up of ComponentC and ClassA, that's a composite. My implementation of a mixin which I borrowed from java is really just using composites + interfaces to emulate multiple inheritance. Decorators and composites are similar however in that they are both structural patterns and define an interface for communicating between parent and child components / classes. Best, -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 9:00 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) How is this any different from a Decorator/Wrapper? Looks like a double decorator. On 1/30/07, Erik Bianchi [EMAIL PROTECTED] wrote: Actually my definition of a mixin is very strict compared to a decorator; it uses design by contract, composition and declares type: Class ClassA implements IClassB, IClassC { private var classB:ClassB; private var classC:ClassC; private function classBMethod():Boolean{...}; private function classCMethod():Number{...}; } -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 12:09 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) On 1/29/07, David Ham [EMAIL PROTECTED] wrote: startObjectDrag triggered by obj_mc.onPress checkForSnaptriggered bysetInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease This looks more like the Broadcaster pattern or the Event Dispatcher (a.k.a. Observer) pattern than Decorator. (Also, it might be better to tie checkForSnap to mouseMove.) Personally, I'm not a big fan of mix-ins because, well, they're kind of sloppy. They involve tinkering with stuff that should be off-limits (and is in AS3, I think). Using mix-ins, you could accidentally use a non
Re: [Flashcoders] Flair Pattern bad mixins good (?)
Yes, it's very common to add additional methods in your subclasses for additional behaviour. Polymorphism is maintained only through the base case's interface. I'll have to check out doFactory, haven't heard of it before. James O'Reilly — Consultant Adobe Certified Flash Expert http://www.jamesor.com Design • Code • Train Erik Bianchi wrote: I've seen examples of it both ways where a decorated object maintains the objects interface or it adds additional methods so it breaks polymorphism. Don't have the GOF book with me to reference so no idea what they actually outlined. Doing a quick search wikipedia states 1 to 1 where doFactory shows otherwise. On a side note I love doFactory as they offer simple UML diagrams and sample code (both conceptual and real world). Been a while since I've posted here, a few years I think. I miss the geek tangents / debates. =) -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of JOR Sent: Tuesday, January 30, 2007 3:55 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) A decorator object composites the object it wishes to decorate and is used in it's place. Since the decorator inherits from the the same base class as the object it decorates they can both be used interchangeably through polymorphism. consider something like this: var myBagel:Bagel = new Bagel(); trace (myBagel.getCalories()); // 200 // Add creamcheese to my bagel myBagel = new CreamCheeseDecorator(myBagel); trace (myBagel.getCalories()); // 300 // Add lox to my bagel myBagel = new LoxDecorator(myBagel); trace (myBagel.getCalories()); // 330 //--- // bagel looks something like this public class Bagel { public function getCalories ():uint { return 200; } } //inside the decorator is something like this: public class CreamCheeseDecorator extends Bagel { private var _bagel:Bagel; public function CreamCheeseDecorator (bagel:Bagel) { _bagel = bagel; } public function getCalories ():uint { return _bagel.getCalories() + 100; } } //inside the decorator is something like this: public class LoxDecorator extends Bagel { private var _bagel:Bagel; public function LoxDecorator (bagel:Bagel) { _bagel = bagel; } public function getCalories ():uint { return _bagel.getCalories() + 30; } } You can add more Bagel types like EggBagel and EverythingBagel and more Decorator objects like Butter and use them all interchangeably. note, this untested code, I just typed it out in the post so their might be typos. James O'Reilly - Consultant Adobe Certified Flash Expert http://www.jamesor.com Design . Code . Train Erik Bianchi wrote: Opps meant to add: that's my interpretation anyways. I could be wrong. I'm wrong all the time. In fact I consider myself a professional mistake maker. -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erik Bianchi Sent: Tuesday, January 30, 2007 1:49 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Flair Pattern bad mixins good (?) A decorator is meant to be dynamic. It adds responsibilities to an object at run time. You take ComponentA and add methods to it on mouseclick, that's a decorator. ComponentB is made up of ComponentC and ClassA, that's a composite. My implementation of a mixin which I borrowed from java is really just using composites + interfaces to emulate multiple inheritance. Decorators and composites are similar however in that they are both structural patterns and define an interface for communicating between parent and child components / classes. Best, -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 9:00 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) How is this any different from a Decorator/Wrapper? Looks like a double decorator. On 1/30/07, Erik Bianchi [EMAIL PROTECTED] wrote: Actually my definition of a mixin is very strict compared to a decorator; it uses design by contract, composition and declares type: Class ClassA implements IClassB, IClassC { private var classB:ClassB; private var classC:ClassC; private function classBMethod():Boolean{...}; private function classCMethod():Number{...}; } -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of T. Michael Keesey Sent: Tuesday, January 30, 2007 12:09 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) On 1/29/07, David Ham [EMAIL PROTECTED] wrote: startObjectDrag triggered by obj_mc.onPress checkForSnaptriggered bysetInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease This looks more like the Broadcaster pattern
Re: [Flashcoders] Flair Pattern bad mixins good (?)
Been a while since I've posted here, a few years I think. I miss the geek tangents / debates. =) Good man! Seriously, the world affords precious few opportunities to truly geek out on design patterns and such. Internet mailing lists excepted of course. I have the Head First Design Patterns book, and I have to say I like it, in spite of its profusion of clip art and cheesy humor. Despite these stylistic affronts, it presents the material in a way that is easy to learn. What's the consensus on the GoF book? I know it's a classic, but so is Ulysses and dog if I can read that. I don't have a CS background-- Flash is about as far as my programming expertise extends--so the Head First style works for me. Is GoF accessible for people who don't program in C++? OK DAH ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Flair Pattern bad mixins good (?)
The Head First Design Patterns book rocks and I definitely recommend it to anyone wanting to learn about design patterns. I actually got a kick out of the clip art and humor but I'm kind of quirky that way I guess. The Java examples were trivial to port to ActionScript and a good exercise. The GoF book reads more like a college textbook. I use it from time to time to compare notes between my different pattern books but it's definitely not the one I pick up first. The introduction section of the book is a good read. However, unlike Java or C#, if you don't know C++ you might find the examples difficult to understand. The ActionScript 3 with Design Patterns is also very good. It's obviously very specific to ActionScript unlike the other two books so the samples don't need to be ported. James O'Reilly — Consultant Adobe Certified Flash Expert http://www.jamesor.com Design • Code • Train David Ham wrote: Been a while since I've posted here, a few years I think. I miss the geek tangents / debates. =) Good man! Seriously, the world affords precious few opportunities to truly geek out on design patterns and such. Internet mailing lists excepted of course. I have the Head First Design Patterns book, and I have to say I like it, in spite of its profusion of clip art and cheesy humor. Despite these stylistic affronts, it presents the material in a way that is easy to learn. What's the consensus on the GoF book? I know it's a classic, but so is Ulysses and dog if I can read that. I don't have a CS background-- Flash is about as far as my programming expertise extends--so the Head First style works for me. Is GoF accessible for people who don't program in C++? OK DAH ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Flair Pattern bad mixins good (?)
I think GoF is a great reference book but the writers aren't very gentle about how they present information. It is very blunt and straight to the point. Reminds me a bit of an old calculus book. The first time I read the GoF book I thought my head was going to explode. A few years later though when I'm referencing a pattern it's a lot more clear now for some reason. Also, It be nice if they revised using java or C# rather then C++. -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Ham Sent: Tuesday, January 30, 2007 7:02 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) Been a while since I've posted here, a few years I think. I miss the geek tangents / debates. =) Good man! Seriously, the world affords precious few opportunities to truly geek out on design patterns and such. Internet mailing lists excepted of course. I have the Head First Design Patterns book, and I have to say I like it, in spite of its profusion of clip art and cheesy humor. Despite these stylistic affronts, it presents the material in a way that is easy to learn. What's the consensus on the GoF book? I know it's a classic, but so is Ulysses and dog if I can read that. I don't have a CS background-- Flash is about as far as my programming expertise extends--so the Head First style works for me. Is GoF accessible for people who don't program in C++? OK DAH ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Flair Pattern bad mixins good (?)
Anyhow I tend not to use decorators (matter of personal taste). I prefer to not Frankenstein an object at runtime and rather use mixins (composition + interfaces). Ah, thank you, now we are getting somewhere! Tell me about mixins. I have used EventDispatcher before, but I am unfamiliar with the theory behind mixins in general. In my app, i have objects that can be dragged around in a Room, and they have a snapping behavior that lets them snap to the walls of the room, and in some cases, rotate themselves so that a given side of the object is always to the wall. Currently, my snapping behavior is in a separate class like the one at the top of this thread. If the room object has snapping enabled, the SnapFlair class adds an object with a bunch of methods and properties to it. The snapping methods are triggered by an event that is broadcast as the room object is being dragged. How would I implement this as a mixin? Many thanks fellas! As for Steven, sounds like HE'S got a case of the Mondays! *smirk* OK DAH ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Flair Pattern bad mixins good (?)
The theory of mixins originated from multiple inheritance programming languages such as C++. So for example: Say you wanted to make an object dragable, clickable and resizable. You would then create separate classes called: Dragable, Clickable and Resizable (common naming convention for a mixin). Then your base class would just inherit form those 3 classes. Since AS2 doesn't support multiple inheritances you can emulate a mixin using interfaces and composed classes. For example: IClickable, IDragable, IResizable So then your AS2 class would say: Class MyClass extends Whatever implements IClickable, IDragable, IResizable Those interfaces just specify what methods your class has to support. From there you could have a class (or a consolidated class) implement that functionality private var clickable:Clickable = new Clickable(); private var dragable:Dragable = new Dragable(); private var resizeable:Resizeable = new Resizeable(); from there you just forward / wire the appropriate methods to its corresponding instances. public function startResize() { this.resizeable.startResize(); } Or for arguments: public function startResize() { this.resizeable.apply.(this.resizeable.startResize, arguments); } You could get even more fancy by externalizing those classes so based on various rules you could pass in different resize logic, etc. Anyhow, hope that gets the gears turning. =) DISCLAIMER: Didn't spell check or test anything in the compiler so maybe some typos. =) -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Ham Sent: Monday, January 29, 2007 7:12 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) Anyhow I tend not to use decorators (matter of personal taste). I prefer to not Frankenstein an object at runtime and rather use mixins (composition + interfaces). Ah, thank you, now we are getting somewhere! Tell me about mixins. I have used EventDispatcher before, but I am unfamiliar with the theory behind mixins in general. In my app, i have objects that can be dragged around in a Room, and they have a snapping behavior that lets them snap to the walls of the room, and in some cases, rotate themselves so that a given side of the object is always to the wall. Currently, my snapping behavior is in a separate class like the one at the top of this thread. If the room object has snapping enabled, the SnapFlair class adds an object with a bunch of methods and properties to it. The snapping methods are triggered by an event that is broadcast as the room object is being dragged. How would I implement this as a mixin? Many thanks fellas! As for Steven, sounds like HE'S got a case of the Mondays! *smirk* OK DAH ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Flair Pattern bad mixins good (?)
Erik Bianchi wrote: The theory of mixins originated from multiple inheritance programming languages such as C++. So for example: Say you wanted to make an object dragable, clickable and resizable. You would then create separate classes called: Dragable, Clickable and Resizable (common naming convention for a mixin). Then your base class would just inherit form those 3 classes. Since AS2 doesn't support multiple inheritances you can emulate a mixin using interfaces and composed classes. For example: IClickable, IDragable, IResizable So then your AS2 class would say: Class MyClass extends Whatever implements IClickable, IDragable, IResizable Those interfaces just specify what methods your class has to support. From there you could have a class (or a consolidated class) implement that functionality private var clickable:Clickable = new Clickable(); private var dragable:Dragable = new Dragable(); private var resizeable:Resizeable = new Resizeable(); from there you just forward / wire the appropriate methods to its corresponding instances. public function startResize() { this.resizeable.startResize(); } Or for arguments: public function startResize() { this.resizeable.apply.(this.resizeable.startResize, arguments); } You could get even more fancy by externalizing those classes so based on various rules you could pass in different resize logic, etc. enter the State and Strategy Patterns :) The State Pattern would be implemented like the above example when you described a fancier version with multiple resize classes. Those resize classes can be swapped out at run-time to provide different functionality. For example, the object resizes from the center or from the corner depending on the resize class composited. The Strategy Pattern is similar but the composited functionality is an encapsulated algorithm. In theory, you would have a bunch of concrete algorithm classes and depending on your needs at run-time composite the right one to perform a calculation. -- james -- James O'Reilly — Consultant Adobe Certified Flash Expert http://www.jamesor.com Design • Code • Train ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Flair Pattern bad mixins good (?)
OK, this is helping a lot. And Steven I see what you mean, poor Flair is starting to look a little meager now. In my app, I have several different states. Each state sets itself up by initializing variables and drawing its various pieces, and the final piece is to subscribe various parts of the app to events that happen in other parts. So in one state I have methods like: onRoomObjectPress() onRoomObjectRelease() that are triggered by onPress and onRelease events in my object movieclips. These onSomething() methods contain the core logic of the app--code to resize clips or process values or what have you. This structure is good because I know where to look to track down where things happen, but its bad because sometimes a bunch of things are supposed to happen at once and those onSomething() methods get hairy. So in this new mixin strategy (which does look a lot like Strategy, thanks James!), should I design my Snappable class to have methods that would map to movieclip events, such as: startObjectDrag triggered by obj_mc.onPress checkForSnap triggered by setInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease Am I headed in the right direction? Thank you again, this OK DAH The theory of mixins originated from multiple inheritance programming languages such as C++. So for example: Say you wanted to make an object dragable, clickable and resizable. You would then create separate classes called: Dragable, Clickable and Resizable (common naming convention for a mixin). Then your base class would just inherit form those 3 classes. Since AS2 doesn't support multiple inheritances you can emulate a mixin using interfaces and composed classes. For example: IClickable, IDragable, IResizable So then your AS2 class would say: Class MyClass extends Whatever implements IClickable, IDragable, IResizable Those interfaces just specify what methods your class has to support. From there you could have a class (or a consolidated class) implement that functionality private var clickable:Clickable = new Clickable(); private var dragable:Dragable = new Dragable(); private var resizeable:Resizeable = new Resizeable(); from there you just forward / wire the appropriate methods to its corresponding instances. public function startResize() { this.resizeable.startResize(); } Or for arguments: public function startResize() { this.resizeable.apply.(this.resizeable.startResize, arguments); } You could get even more fancy by externalizing those classes so based on various rules you could pass in different resize logic, etc. Anyhow, hope that gets the gears turning. =) DISCLAIMER: Didn't spell check or test anything in the compiler so maybe some typos. =) -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Ham Sent: Monday, January 29, 2007 7:12 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) Anyhow I tend not to use decorators (matter of personal taste). I prefer to not Frankenstein an object at runtime and rather use mixins (composition + interfaces). Ah, thank you, now we are getting somewhere! Tell me about mixins. I have used EventDispatcher before, but I am unfamiliar with the theory behind mixins in general. In my app, i have objects that can be dragged around in a Room, and they have a snapping behavior that lets them snap to the walls of the room, and in some cases, rotate themselves so that a given side of the object is always to the wall. Currently, my snapping behavior is in a separate class like the one at the top of this thread. If the room object has snapping enabled, the SnapFlair class adds an object with a bunch of methods and properties to it. The snapping methods are triggered by an event that is broadcast as the room object is being dragged. How would I implement this as a mixin? Many thanks fellas! As for Steven, sounds like HE'S got a case of the Mondays! *smirk* OK DAH ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- David Ham http://anthropomorphy.org :: +1 630 297 1273 http://davidham.com :: [EMAIL PROTECTED] ___ Flashcoders