Re: [Flashcoders] Flair Pattern bad mixins good (?)

2007-02-01 Thread Keith Salisbury

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 (?)

2007-01-31 Thread Glen Pike

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 (?)

2007-01-31 Thread Keith Salisbury

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 (?)

2007-01-31 Thread Steven Sacks | BLITZ
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 (?)

2007-01-31 Thread Keith Salisbury

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 (?)

2007-01-31 Thread Holth, Daniel C.

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 (?)

2007-01-31 Thread T. Michael Keesey

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 (?)

2007-01-30 Thread T. Michael Keesey

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 (?)

2007-01-30 Thread Hans Wichman

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 (?)

2007-01-30 Thread Erik Bianchi
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 (?)

2007-01-30 Thread Erik Bianchi
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 (?)

2007-01-30 Thread T. Michael Keesey

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 (?)

2007-01-30 Thread Erik Bianchi
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 (?)

2007-01-30 Thread Erik Bianchi
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 (?)

2007-01-30 Thread JOR
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 (?)

2007-01-30 Thread Erik Bianchi
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 (?)

2007-01-30 Thread JOR
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 (?)

2007-01-30 Thread David Ham
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 (?)

2007-01-30 Thread JOR
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 (?)

2007-01-30 Thread Erik Bianchi
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] Flair Pattern?

2007-01-29 Thread David Ham

Hey FlashCoders:

In the app I am building, I have a need to add and remove  
functionality to an object at runtime--specifically, functionality  
that will snap the object to a border. I have puzzled on this for  
awhile, and the method that seems most applicable to me is the Flair  
pattern described in OOP with ActionScript by Hall  Wan. If you  
don't have the book, the pattern, in short, is a static class that  
dynamically creates a child object on the class it is modifying, and  
then adds methods and properties to that object.


My question is: has anyone else used this pattern in AS2 projects? Is  
it even the best way to achieve what I am trying to achieve? An  
outline of my SnapFlair class follows below.


Any input you can offer is greatly appreciated, as always,

OK
DAH

SNAPFLAIR CLASS
Implemented as a Singleton

class  SnapFlair {
private static var _obj:SnapFlair;

private function SnapFlair() {}

/**
* @param target The MovieClip being 'flaired'
	* @param source			The source of the event that the flair  
functionality is listening for
	* @param eventName	The name of the event that the flair is listening  
for

*/  
	public function snapOn( target:MovieClip, source:Object,  
eventName:String ) {

target.mc.$snapFlair = new Object();
target.mc.$snapFlair._obj = target;
source.addEventListener( eventName, target.$snapFlair );
target.mc.$snapFlair[eventName] = onEvent;
}

public static function getObj():SnapFlair {
if (SnapFlair._obj == null) {
SnapFlair._obj = new SnapFlair();
}
return _obj;
}

	public function snapOff( target:MovieClip, source:Object,  
eventName:String ) {

source.removeEventListener(eventName, target.$snapFlair)
delete target.mc.$snapFlair;
}

public function onEvent( evt:Object ) {
// do stuff
}

public function toString():String {
return Class SnapFlair;
}
}


___
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?

2007-01-29 Thread Steven Sacks | BLITZ
I've never heard of an OOP design pattern called Flair.  From the class
you've pasted, it looks like a novice attempt at implementating a design
pattern known as Decorator.

Perhaps they were trying to be funny with a reference to the movie
Office Space where buttons decorating a TGIFriday's uniform were called
Flair?  I know that comedy helps when teaching dry material, but
renaming a design pattern like that seems to me to be confusing at best.

At any rate, here is a link to a description of the Decorator pattern.
It should get you on your way.

http://en.wikipedia.org/wiki/Decorator_pattern





 
 SNAPFLAIR CLASS
 Implemented as a Singleton
 
 class  SnapFlair {
   private static var _obj:SnapFlair;
   
   private function SnapFlair() {}
   
   /**
   * @param target The MovieClip being 'flaired'
   * @param source The source of the event 
 that the flair  
 functionality is listening for
   * @param eventName  The name of the event that the 
 flair is listening  
 for
   */  
   public function snapOn( target:MovieClip, 
 source:Object, eventName:String ) {
   target.mc.$snapFlair = new Object();
   target.mc.$snapFlair._obj = target;
   source.addEventListener( eventName, target.$snapFlair );
   target.mc.$snapFlair[eventName] = onEvent;
   }
   
   public static function getObj():SnapFlair {
   if (SnapFlair._obj == null) {
   SnapFlair._obj = new SnapFlair();
   }
   return _obj;
   }
   
   public function snapOff( target:MovieClip, 
 source:Object, eventName:String ) {
   source.removeEventListener(eventName, target.$snapFlair)
   delete target.mc.$snapFlair;
   }
   
   public function onEvent( evt:Object ) {
   // do stuff
   }
   
   public function toString():String {
   return Class SnapFlair;
   }
 }
 
 
 ___
 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?

2007-01-29 Thread Dave Watts
 I've never heard of an OOP design pattern called Flair.  From 
 the class you've pasted, it looks like a novice attempt at 
 implementating a design pattern known as Decorator.

http://chattyfig.figleaf.com/pipermail/flashcoders/2003-January/060703.html

My understanding of the point of this pattern is to allow you to implement
multiple Decorators.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

___
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?

2007-01-29 Thread David Ham
I've never heard of an OOP design pattern called Flair.  From the  
class
you've pasted, it looks like a novice attempt at implementating  
(sic) a design

pattern known as Decorator.

Perhaps they were trying to be funny with a reference to the movie
Office Space where buttons decorating a TGIFriday's uniform were  
called

Flair?  I know that comedy helps when teaching dry material, but
renaming a design pattern like that seems to me to be confusing at  
best.


The pattern is similar to Decorator (as they acknowledge in the book)  
but different in that it allows you to add and remove functionality  
at runtime. I decided against Decorator because not all objects in  
the app will need this functionality, and the ones that do can have  
it turned on and off by the user. So I figured a separate class would  
be a good way to encapsulate this functionality, and I remembered  
this pattern from their book. I don't have a lot of background in  
design patterns so I was curious if other people have used it.


Incidentally, you are correct about the Office Space reference. Here  
is a post from Branden Hall, the book's author, from this very list:


http://chattyfig.figleaf.com/pipermail/flashcoders/2003-January/ 
060703.html


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?

2007-01-29 Thread Benny
The pattern is similar to Decorator (as they acknowledge in the book)  
but different in that it allows you to add and remove functionality  
at runtime. ...

Hmmm ...sounds interesting.
Besides the book (which I don't have access to unfortunately) are there any
online resources where I can find more details (description/code samples)
about the flair pattern?

- Benny


___
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?

2007-01-29 Thread Steven Sacks | BLITZ
So I was dead on about the Office Space reference.  :)

The class manages assigning Decorators.  It isn't a design pattern.
It's a class that manages the Decorator design pattern on multiple
objects.

I'm not sure where the idea that the Decorator pattern must be used on
all or none of the objects in an application, or that Decorated objects
cannot be undecorated.

There are no references to the Flair design pattern anywhere else
because it doesn't exist anywhere except in the ego of Brendan Hall.
It's not a design pattern, it's a class that uses another design
pattern, and poorly, too, judging by the code example.

If you want to learn more about Design Patterns, there are quite a few
great books out there on the subject written by people more learned and
experienced than Brendan Hall.  Like people with PhD's in Computer
Science.  From the de facto bible Design Patterns by the Gang of Four to
many others.
___
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?

2007-01-29 Thread Martin Wood-Mitrovski
Im not normally one to comment on personal behaviour but that post really does 
leave a bitter taste, which is sad as you are sometimes helpful.


If you are going to pass judgements on other peoples work which may prove 
helpful in the situation facing the OP then at least qualify them or you also 
look like you are relying on us accepting your notion of your own ego.


Design patterns are not cast in stone and the GoF dont hold the one true set of 
patterns, PhD's or no PhD's.


Actionscript is not C++ and its not Smalltalk, other solutions may apply.

I know you can discuss a topic without resorting to ad hominem, so please do so.

thanks,

Martin

Steven Sacks | BLITZ wrote:

There are no references to the Flair design pattern anywhere else
because it doesn't exist anywhere except in the ego of Brendan Hall.
It's not a design pattern, it's a class that uses another design
pattern, and poorly, too, judging by the code example.

If you want to learn more about Design Patterns, there are quite a few
great books out there on the subject written by people more learned and
experienced than Brendan Hall.  Like people with PhD's in Computer
Science.  From the de facto bible Design Patterns by the Gang of Four to
many others.

___
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?

2007-01-29 Thread slangeberg

Yeah, hear-hear (here-here?).

I would wager that we could find one ore more non-PhD's who've produced some
major, seminal works. I'm sure this even applies in the CS field, no?

OTP:
Flex 2 rocks. Get it now.

-Scott
 Yeah, well the God I believe in isn't short of cash, mister.

On 1/29/07, Martin Wood-Mitrovski [EMAIL PROTECTED] wrote:


Im not normally one to comment on personal behaviour but that post really
does
leave a bitter taste, which is sad as you are sometimes helpful.

If you are going to pass judgements on other peoples work which may prove
helpful in the situation facing the OP then at least qualify them or you
also
look like you are relying on us accepting your notion of your own ego.

Design patterns are not cast in stone and the GoF dont hold the one true
set of
patterns, PhD's or no PhD's.

Actionscript is not C++ and its not Smalltalk, other solutions may apply.

I know you can discuss a topic without resorting to ad hominem, so please
do so.

thanks,

Martin

Steven Sacks | BLITZ wrote:
 There are no references to the Flair design pattern anywhere else
 because it doesn't exist anywhere except in the ego of Brendan Hall.
 It's not a design pattern, it's a class that uses another design
 pattern, and poorly, too, judging by the code example.

 If you want to learn more about Design Patterns, there are quite a few
 great books out there on the subject written by people more learned and
 experienced than Brendan Hall.  Like people with PhD's in Computer
 Science.  From the de facto bible Design Patterns by the Gang of Four to
 many others.
___
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





--

: : ) Scott
___
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?

2007-01-29 Thread Steven Sacks | BLITZ
I felt that I did qualify my statement, I'll try again with clearly
language.

My statement:
There is no such thing as a Flair design pattern.

My qualification:
Brendan Hall's book and deep in the archives of Flashcoders back when
Brendan operated this list are the only places you will find reference
to it.

His class uses the Decorator design pattern.  Using a design pattern
doesn't mean you've made your own design pattern.  Calling it a design
pattern gives it a level of authenticity that it simply doesn't have
and is misleading to anyone who reads it, as the OP has demonstrated
with his post.  He has no point of reference outside of Brendan's book
or this list to support him or his questions.

I provided a link that would hopefully help him learn the actual design
pattern being used, which is called Decorator.  Using Decorator on
multiple objects isn't a design pattern, it's the usage of the Decorator
design pattern.

To your comment that Actionscript isn't C++ or Smalltalk, that's true.
My feeling is that Design Patterns are universal, not limited to syntax
or language.  I didn't mean to imply that GoF holds the one true set of
patterns.  They don't cover MVC in their book, for instance, a pattern I
use regularly.  Their book is weighted heavily towards the Composition
design pattern, which is slowly being embraced by the Actionscript
community.  The Flex framework and even the AS3 language are influenced
by the power of the Composition design pattern.

The Head First Design Patterns book is quite good, as well, and is more
accessible than the heady and dense GoF one which I had trouble
understanding parts of (often due to lack of experience with C++ and
Smalltalk) and had to turn to google and other books to grasp some of
the concepts they were talking about.  However, the 18 design patterns
covered by Head First can all be found in the 23 covered by Gang of
Four, and all are on Wikipedia, discussed all over the web, and come up
with many useful results in google, in contrast to Brendan's Flair
design pattern.

To the ad hominem remark:
When you're writing a book to help people and claiming you're using a
new design pattern who does it serve?  The reader or the author?  And if
it serves the author and not the reader, is that not an ego driven
decision?

Years ago, a company I worked at sent a few employees to Figleaf for
training and the class was taught by Brendan Hall.  I walked away from
that class with the impression that Brendan spent most of the time
telling everyone how smart he was but not teaching very much at all.
His class did little to improve my or my coworkers Flash skills.  That
experience, the way he ran Flashcoders in the early days, and now this,
is, I suppose, why I called it an ego driven decision to call it a
design pattern.  If you see it as ad hominem, that's my fault for not
using clear enough language.

Cheers,
Steven
___
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?

2007-01-29 Thread Claus Wahlers



the way he ran Flashcoders in the early days


Can you elaborate?

Cheers,
Claus.

--
claus wahlers
côdeazur brasil
http://codeazur.com.br/
http://wahlers.com.br/claus/blog/

--
READ CAREFULLY. By reading this email you agree, on behalf of your 
employer, to release me from all obligations and waivers arising from 
any and all NON-NEGOTIATED agreements, licenses, terms-of-service, 
shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, 
non-compete and acceptable use policies (BOGUS AGREEMENTS) that I have 
entered into with your employer, its partners, licensors, agents and 
assigns, in perpetuity, without prejudice to my ongoing rights and 
privileges. You further represent that you have the authority to release 
me from any BOGUS AGREEMENTS on behalf of your employer.

___
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?

2007-01-29 Thread Steven Sacks | BLITZ
 Can you elaborate?

While a trip down memory lane replete with posts from the archives
sounds like a wonderful time (not), I have work to do and it would take
this thread extremely OT.
___
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?

2007-01-29 Thread eric dolecki

i can only recall from the early days that posts be about coding, and some
posts(threads) would get bounced (I think) if they didn't. Which was
understandable imho. Beyond that, I'm not sure what the comment about
Branden running the list means either...

-ericd.

On 1/29/07, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote:


 Can you elaborate?

While a trip down memory lane replete with posts from the archives
sounds like a wonderful time (not), I have work to do and it would take
this thread extremely OT.
___
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





--
eric e. dolecki
senior interactive engineer
http://www.ericd.net
___
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?

2007-01-29 Thread David Ham
For my part, I have the Head First book, and the Decorator section  
did not answer the particular questions I had. Nor did the other  
sources I read.


Whether something is a true design pattern or not is kind of beside  
the point, for me; what I want to know is if a particular approach is  
good for what I am trying to accomplish: in this case, adding and  
removing functionality to an object at runtime.


As for Steve's earlier comment, It's not a design pattern, it's a  
class that uses another design pattern, and poorly, too, thanks for  
the reply, but it does nothing to explain why the code is bad, or  
what a better approach would be.


My approach is working so far; if it's no good, I'm sure the code  
will tell me, soon enough.


For the common good I move that we put this thread to bed,

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?

2007-01-29 Thread Steven Sacks | BLITZ
 Whether something is a true design pattern or not is kind 
 of beside the point, for me; what I want to know is if a 
 particular approach is good for what I am trying to 
 accomplish: in this case, adding and removing functionality 
 to an object at runtime.

If it works and you meet the deadline, then it's good enough, eh?  :)

If you want to engage in what a fellow coder friend of mine calls
aromatherapy, I'm for it.  I was mistaken in my impression that you
were looking to understand the design pattern, which is why I was trying
to lead you to Decorator and away from Flair because you weren't going
to find any information on Flair that would be helpful, but there are
plenty of helpful places to look for Decorator.  

If you want to discuss best practice for what you're doing, I'd be happy
to offer ideas later today when I have more time.  Other people might be
able to chime in here on the best application of Decorator in
Actionscript.
___
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?

2007-01-29 Thread T. Michael Keesey

On 1/29/07, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote:

If you want to discuss best practice for what you're doing, I'd be happy
to offer ideas later today when I have more time.


I'm a little confused as to why the original poster would want to
dynamically add or remove functionality to/from an object at runtime.
That sounds a bit unstable--code that works perfectly fine when the
functionality is added would break when the functionality is removed.
Perhaps it is better to add a flag (like the enabled property of
movie clips and buttons) and disable certain functionality when it is
false (or true or whatever).


Other people might be
able to chime in here on the best application of Decorator in
Actionscript.


Personally, I find one of the best uses to be in place of mixing in
(i.e., copying functions from the prototype of one class to an
unrelated class). In essence, it's a way to get around the every
class can have only one parent problem. For example, if I have an
IEventDispatcher interface that's implemented by an EventDispatcher
class that's descended from Object, then I can't have a component that
extends EventDispatcher because components (in AS2) must extend
MovieClip. The solution: make a DispatcherClip class that extends
MovieClip and implements IEventDispatcher by keeping a hidden
EventDispatcher object and wrapping/decorating its public functions.

--
T. Michael Keesey
Director of Technology
Exopolis, Inc.
2894 Rowena Avenue Ste. B
Los Angeles, California 90039
___
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?

2007-01-29 Thread Erik Bianchi
Respectfully, Isn't that like saying a singleton is just a class that
manages a factory? =)

A design pattern is a repeatable solution to a commonly occurring problem in
software development. So if all a Flair does is manage decorators and 2
people know that's what it does, then that sounds like a design pattern to
me (unless there's a ECMA committee for that now a days). =)

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).


-erik

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks
| BLITZ
Sent: Monday, January 29, 2007 11:35 AM
To: Flashcoders mailing list
Subject: RE: [Flashcoders] Flair Pattern?

So I was dead on about the Office Space reference.  :)

The class manages assigning Decorators.  It isn't a design pattern.
It's a class that manages the Decorator design pattern on multiple
objects.

I'm not sure where the idea that the Decorator pattern must be used on
all or none of the objects in an application, or that Decorated objects
cannot be undecorated.

There are no references to the Flair design pattern anywhere else
because it doesn't exist anywhere except in the ego of Brendan Hall.
It's not a design pattern, it's a class that uses another design
pattern, and poorly, too, judging by the code example.

If you want to learn more about Design Patterns, there are quite a few
great books out there on the subject written by people more learned and
experienced than Brendan Hall.  Like people with PhD's in Computer
Science.  From the de facto bible Design Patterns by the Gang of Four to
many others.
___
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?

2007-01-29 Thread Steven Sacks | BLITZ
Is adding and removing identical decorators on multiple objects a
commonly occuring problem in software development?  ;)

I avoid Decorators, as well, for the same reasons you stated and the
same solutions you offered, as well.  :)
___
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 (?)

2007-01-29 Thread David Ham
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 (?)

2007-01-29 Thread Erik Bianchi
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 (?)

2007-01-29 Thread JOR

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 (?)

2007-01-29 Thread David Ham
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