Why not subclassing?
As a general answer I'd say:
Subclassing is a very strong (and static) relationship, and in Pharo we have only single inheritance + traits, so inheritance is a single shot gun :).
Splitting the behavior from the button opens you a door in your design.� You can design button actions with shortcuts, or undo actions, and choose your own inheritance criteria suiting your needs.
Just that, it lets an open door for richer designs.
Now, the ammount of code for one or other solution is pretty the same too, you just add one class with the toggle behavior the first one inherits from Button and the other does not), and then the instantiation code should not differ too much.
Bye,
Guille
Here is a little example of what I meant :)BenOn Nov 28, 2011, at 11:28 PM, Ted F.A. van Gaalen wrote:Hi Guille, BenI've just found this very convinient to subclass it and give itits own behaviour.. what's wrong with that? Seems right OOP to me..(I am a descendant of my mother and father (wow multiple inheritance :o)in essence not very much different from my parents, still,i exhibit other behaviour e.g. working with computers..)But, yes, an example of what might be a better solution hereis appreciated, thanksTedAnyone answering my other questions? Thanks(i only have 6 apples no, I've just eaten one)On Mon, Nov 28, 2011 at 11:19 PM, Guillermo Polito <guillermopolito@gmail.com> wrote:
In two words, Ben means to use composition over inheritance :P.
Guille
On Mon, Nov 28, 2011 at 7:10 PM, Benjamin <benjamin.vanryseghem.pharo@gmail.com> wrote:
Here, you are not changing the mechanism of the button, you are connecting a button to a model (when i click, i turn on/off fullscreen).It's not a specific button (like a dunno, a button with 3 different states or stgh else).Your button is a classical one, but you want a specific model to plug your button with :)If you want, I could do a little piece of code to show what i mean :)BenOn Nov 28, 2011, at 11:03 PM, Ted F.A. van Gaalen wrote:Could you be more elaborate on this, Ben?I don't see it (yet)thanksTedOn Mon, Nov 28, 2011 at 10:58 PM, Benjamin <benjamin.vanryseghem.pharo@gmail.com> wrote:
Because it's not a specific button, it's a simple button used in a specific wayBenOn Nov 28, 2011, at 10:44 PM, Ted F.A. van Gaalen wrote:Hi BenAll the functionality needed is justto toggle a Display state..then why use model?TedOn Mon, Nov 28, 2011 at 10:32 PM, Benjamin <benjamin.vanryseghem.pharo@gmail.com> wrote:
Good idea :)but imo, it shouldn't be a subclass of�SimpleButtonMorph.I think a class representing the model is more appropriate.BenOn Nov 28, 2011, at 10:08 PM, Ted F.A. van Gaalen wrote:Hi thereThanks for creating version 1.3 !!!!!!!-loaded Seaside into it.-did a file-in of my Seaside pagesWorks. OKStill missing:What I really would like�perhaps in the next releasea Full Screen Toggle Buttonsomewhere on the desktop..or -like in the Chrome Internet Browsercould you assign it to the F11 key?just an idea.Don't understand why it is hidden�in Settings browser>>appearance>>desktop(IMHO it does not belong there at allit's not a Setting but just a window state..)For now, I've solved this by creating this little helper,which, due to my�laziness�to give it coordinates,drops a button in the upper left corner.Mais enfin, it works.�The class:SimpleButtonMorph subclass: #FullScreenFlipFlopMorphinstanceVariableNames: ''classVariableNames: ''poolDictionaries: ''category: 'TGUtil-One'with just this two instance methods:initializesuper initialize.selftarget: self;label: 'Full Screen';color: Color orange;actionSelector: #toggle;openInWorld "target is self is Smalltalk;"toggleDisplay toggleFullScreenIn a workspace brought to life with evaluatingfullScreenFlipFlop := FullScreenFlipFlopMorph new.Another question:As 1.3 uses a cog VM.�Is the seasidehosting.ststill using �a non-cog VM?This would imply a cog VMbased image would not run on�the seasidehosting?What happened to the user window styles?�(I only see Default and DemoMode)I liked the sort of Aqua themes (I have 7 apples, they are real and in the kitchen :o)Kind RegardsTedvG