Re: [Pharo-users] How can I make this more OOP

2020-09-14 Thread Roelof Wobben via Pharo-users
Thanks Richard for this explanation. and I like also your idea of using #respondTo instead of asking a object if its a collection or a item. Roelof Op 14-9-2020 om 14:28 schreef Richard O'Keefe: "OOP is

Re: [Pharo-users] How can I make this more OOP

2020-09-14 Thread Richard O'Keefe
"OOP is not asking an object what it is"? You've lost me. I'm reminded of a joke exam question that goes something like this: Some things have ping nature and other things have pong nature. Discuss, with examples. Whatever else it is, OOP is a means to an end, not an end in itself. It's

Re: [Pharo-users] How can I make this more OOP

2020-09-13 Thread Noury Bouraqadi
Hi Roelof, Polymorphism is the answer. Object >> flattenInto: result result nextPut: anObject UndefinedObject >> flattenInto: result ^self Collection >> flattenInto: result self do: [ :item | item flattenInto: result ] flatten: anObject ^ (OrderedCollection

[Pharo-users] How can I make this more OOP

2020-09-13 Thread Roelof Wobben via Pharo-users
Hello, I know that OOP is not asking a object what it is but I have to flatten a array so I did this : flattenArray: aCollection     ^ (OrderedCollection         streamContents: [ :stream | self flatten: aCollection into: stream ])         asArray