We haven't had a design debate in a while - thoughts on CD.buy article...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

We haven't had a design debate in a while - thoughts on CD.buy article...

Tim Mackinnon
Hi guys - someone pointed out this article from a UK colleague which seems to be causing a flurry of discussion - but I always like the insights of this group. I had an instant reaction when I read it - but curious what people here think in 2021.

https://www.linkedin.com/posts/jasongorman_the-year-is-2021-and-people-still-think-activity-6787650079764303872-SJzz

Tim
Reply | Threaded
Open this post in threaded view
|

Re: We haven't had a design debate in a while - thoughts on CD.buy article...

Esteban A. Maringolo
I saw a tweet about that, and I think that the example is misleading, maybe intentionally so.

I don't think anybody would model it that way, in any case you'd have aProduct.buy() or aProduct.addToCart(aCart). 

If you think it with the typical dog.bark() it certainly makes more sense than bark(dog).

Regards!

Esteban A. Maringolo


On Fri, Apr 16, 2021 at 5:20 AM Tim Mackinnon <[hidden email]> wrote:
Hi guys - someone pointed out this article from a UK colleague which seems to be causing a flurry of discussion - but I always like the insights of this group. I had an instant reaction when I read it - but curious what people here think in 2021.

https://www.linkedin.com/posts/jasongorman_the-year-is-2021-and-people-still-think-activity-6787650079764303872-SJzz

Tim
Reply | Threaded
Open this post in threaded view
|

Re: We haven't had a design debate in a while - thoughts on CD.buy article...

Russ Whaley
Wow, I must be missing a whole lot of context in that discussion...  (instant reaction as well, lol)

- a product (CD, book, etc.) does not 'buy' - it can be bought, sure, but it has no buying action.  Even in another context a CD does not 'play'... aMusicPlayer.play(aCD).
- However, a customer can 'buy' a product... 
  • customer.buy(aCD) -or-
  • customer.addToCart(aCD)
  • customer.checkOut(aCart)
  • Invoice.new(aCart), etc. 
- ... but the CD doesn't DO anything. 

- I get the idea that different products might have different behaviour when they are 'bought' - but these are, in this example, fulfillment - not the 'buy' action... 
  • aCDstream might be set for download
  • aCDphysical might be set to physically pull off a shelf and ship
  • aCDcare might send an email on warranty, whatever... but let's name it better than 'buy' :)
Tim, thanks for the link - I'm always trying to expand my thinking about object modeling - discovering cool ways/things others are thinking about...  Now I have to go dust off all my old POS (point of sale, not piece of s#&t) code and see how poorly I may have modeled those environments!!

Thanks for the morning diversion!  Cheers.

On Fri, Apr 16, 2021 at 8:53 AM Esteban Maringolo <[hidden email]> wrote:
I saw a tweet about that, and I think that the example is misleading, maybe intentionally so.

I don't think anybody would model it that way, in any case you'd have aProduct.buy() or aProduct.addToCart(aCart). 

If you think it with the typical dog.bark() it certainly makes more sense than bark(dog).

Regards!

Esteban A. Maringolo


On Fri, Apr 16, 2021 at 5:20 AM Tim Mackinnon <[hidden email]> wrote:
Hi guys - someone pointed out this article from a UK colleague which seems to be causing a flurry of discussion - but I always like the insights of this group. I had an instant reaction when I read it - but curious what people here think in 2021.

https://www.linkedin.com/posts/jasongorman_the-year-is-2021-and-people-still-think-activity-6787650079764303872-SJzz

Tim


--
Russ Whaley
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: We haven't had a design debate in a while - thoughts on CD.buy article...

Tim Mackinnon
Its comforting to see that other have the same reaction as me - I agree with the sentiment that you send messages to objects - and the naming of those messages and their context is important.

and CD.buy - is at least a message to an object but as others have commented, it  highlights flaws in the context or modelling as it just doesn't read right. I'd model it different too.

Phew, I'm not losing it....

Tim

On Fri, 16 Apr 2021, at 2:44 PM, Russ Whaley wrote:
Wow, I must be missing a whole lot of context in that discussion...  (instant reaction as well, lol)

- a product (CD, book, etc.) does not 'buy' - it can be bought, sure, but it has no buying action.  Even in another context a CD does not 'play'... aMusicPlayer.play(aCD).
- However, a customer can 'buy' a product... 
  • customer.buy(aCD) -or-
  • customer.addToCart(aCD)
  • customer.checkOut(aCart)
  • Invoice.new(aCart), etc. 
- ... but the CD doesn't DO anything. 

- I get the idea that different products might have different behaviour when they are 'bought' - but these are, in this example, fulfillment - not the 'buy' action... 
  • aCDstream might be set for download
  • aCDphysical might be set to physically pull off a shelf and ship
  • aCDcare might send an email on warranty, whatever... but let's name it better than 'buy' :)
Tim, thanks for the link - I'm always trying to expand my thinking about object modeling - discovering cool ways/things others are thinking about...  Now I have to go dust off all my old POS (point of sale, not piece of s#&t) code and see how poorly I may have modeled those environments!!

Thanks for the morning diversion!  Cheers.

On Fri, Apr 16, 2021 at 8:53 AM Esteban Maringolo <[hidden email]> wrote:
I saw a tweet about that, and I think that the example is misleading, maybe intentionally so.

I don't think anybody would model it that way, in any case you'd have aProduct.buy() or aProduct.addToCart(aCart). 

If you think it with the typical dog.bark() it certainly makes more sense than bark(dog).

Regards!

Esteban A. Maringolo


On Fri, Apr 16, 2021 at 5:20 AM Tim Mackinnon <[hidden email]> wrote:
Hi guys - someone pointed out this article from a UK colleague which seems to be causing a flurry of discussion - but I always like the insights of this group. I had an instant reaction when I read it - but curious what people here think in 2021.


Tim


--
Russ Whaley

Reply | Threaded
Open this post in threaded view
|

Re: We haven't had a design debate in a while - thoughts on CD.buy article...

Richard Sargent
Administrator
I remember - way back in the dark ages - walking into a music store, picking up a CD, and asking it to buy itself. Every single time, the response was the same: nothing.

On Fri, Apr 16, 2021 at 10:07 AM Tim Mackinnon <[hidden email]> wrote:
Its comforting to see that other have the same reaction as me - I agree with the sentiment that you send messages to objects - and the naming of those messages and their context is important.

and CD.buy - is at least a message to an object but as others have commented, it  highlights flaws in the context or modelling as it just doesn't read right. I'd model it different too.

Phew, I'm not losing it....

Tim

On Fri, 16 Apr 2021, at 2:44 PM, Russ Whaley wrote:
Wow, I must be missing a whole lot of context in that discussion...  (instant reaction as well, lol)

- a product (CD, book, etc.) does not 'buy' - it can be bought, sure, but it has no buying action.  Even in another context a CD does not 'play'... aMusicPlayer.play(aCD).
- However, a customer can 'buy' a product... 
  • customer.buy(aCD) -or-
  • customer.addToCart(aCD)
  • customer.checkOut(aCart)
  • Invoice.new(aCart), etc. 
- ... but the CD doesn't DO anything. 

- I get the idea that different products might have different behaviour when they are 'bought' - but these are, in this example, fulfillment - not the 'buy' action... 
  • aCDstream might be set for download
  • aCDphysical might be set to physically pull off a shelf and ship
  • aCDcare might send an email on warranty, whatever... but let's name it better than 'buy' :)
Tim, thanks for the link - I'm always trying to expand my thinking about object modeling - discovering cool ways/things others are thinking about...  Now I have to go dust off all my old POS (point of sale, not piece of s#&t) code and see how poorly I may have modeled those environments!!

Thanks for the morning diversion!  Cheers.

On Fri, Apr 16, 2021 at 8:53 AM Esteban Maringolo <[hidden email]> wrote:
I saw a tweet about that, and I think that the example is misleading, maybe intentionally so.

I don't think anybody would model it that way, in any case you'd have aProduct.buy() or aProduct.addToCart(aCart). 

If you think it with the typical dog.bark() it certainly makes more sense than bark(dog).

Regards!

Esteban A. Maringolo


On Fri, Apr 16, 2021 at 5:20 AM Tim Mackinnon <[hidden email]> wrote:
Hi guys - someone pointed out this article from a UK colleague which seems to be causing a flurry of discussion - but I always like the insights of this group. I had an instant reaction when I read it - but curious what people here think in 2021.


Tim


--
Russ Whaley

Reply | Threaded
Open this post in threaded view
|

Re: We haven't had a design debate in a while - thoughts on CD.buy article...

giorgiof
In reply to this post by Russ Whaley
Hi, Russ, 
I feel better after reading your mail :)
That's the way I modeled and still model things in my (long...) developer life, so I felt a bit strange after reading that discussion.... 

ciao

giorgio



On Fri, Apr 16, 2021 at 3:45 PM Russ Whaley <[hidden email]> wrote:
Wow, I must be missing a whole lot of context in that discussion...  (instant reaction as well, lol)

- a product (CD, book, etc.) does not 'buy' - it can be bought, sure, but it has no buying action.  Even in another context a CD does not 'play'... aMusicPlayer.play(aCD).
- However, a customer can 'buy' a product... 
  • customer.buy(aCD) -or-
  • customer.addToCart(aCD)
  • customer.checkOut(aCart)
  • Invoice.new(aCart), etc. 
- ... but the CD doesn't DO anything. 

- I get the idea that different products might have different behaviour when they are 'bought' - but these are, in this example, fulfillment - not the 'buy' action... 
  • aCDstream might be set for download
  • aCDphysical might be set to physically pull off a shelf and ship
  • aCDcare might send an email on warranty, whatever... but let's name it better than 'buy' :)
Tim, thanks for the link - I'm always trying to expand my thinking about object modeling - discovering cool ways/things others are thinking about...  Now I have to go dust off all my old POS (point of sale, not piece of s#&t) code and see how poorly I may have modeled those environments!!

Thanks for the morning diversion!  Cheers.

On Fri, Apr 16, 2021 at 8:53 AM Esteban Maringolo <[hidden email]> wrote:
I saw a tweet about that, and I think that the example is misleading, maybe intentionally so.

I don't think anybody would model it that way, in any case you'd have aProduct.buy() or aProduct.addToCart(aCart). 

If you think it with the typical dog.bark() it certainly makes more sense than bark(dog).

Regards!

Esteban A. Maringolo


On Fri, Apr 16, 2021 at 5:20 AM Tim Mackinnon <[hidden email]> wrote:
Hi guys - someone pointed out this article from a UK colleague which seems to be causing a flurry of discussion - but I always like the insights of this group. I had an instant reaction when I read it - but curious what people here think in 2021.

https://www.linkedin.com/posts/jasongorman_the-year-is-2021-and-people-still-think-activity-6787650079764303872-SJzz

Tim


--
Russ Whaley
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: We haven't had a design debate in a while - thoughts on CD.buy article...

Stéphane Ducasse
In reply to this post by Richard Sargent


> On 16 Apr 2021, at 19:24, Richard Sargent <[hidden email]> wrote:
>
> I remember - way back in the dark ages - walking into a music store, picking up a CD, and asking it to buy itself. Every single time, the response was the same: nothing.

May be it was a NullCDObject :)

S.
Reply | Threaded
Open this post in threaded view
|

Re: We haven't had a design debate in a while - thoughts on CD.buy article...

Tim Mackinnon
I think that is a nice end to this thread… you guys really made me chuckle.

> On 17 Apr 2021, at 17:36, Stéphane Ducasse <[hidden email]> wrote:
>
>
>
>> On 16 Apr 2021, at 19:24, Richard Sargent <[hidden email]> wrote:
>>
>> I remember - way back in the dark ages - walking into a music store, picking up a CD, and asking it to buy itself. Every single time, the response was the same: nothing.
>
> May be it was a NullCDObject :)
>
> S.
Reply | Threaded
Open this post in threaded view
|

Re: We haven't had a design debate in a while - thoughts on CD.buy article...

Russ Whaley
In reply to this post by Stéphane Ducasse
👍😁

On Sat, Apr 17, 2021 at 12:37 PM Stéphane Ducasse <[hidden email]> wrote:


> On 16 Apr 2021, at 19:24, Richard Sargent <[hidden email]> wrote:
>
> I remember - way back in the dark ages - walking into a music store, picking up a CD, and asking it to buy itself. Every single time, the response was the same: nothing.

May be it was a NullCDObject :)

S.
--
Russ Whaley
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: We haven't had a design debate in a while - thoughts on CD.buy article...

Erik Stel
In reply to this post by Russ Whaley
Hi people,

A bit late to the party, but I want to provide some info as well.

I think an Article can perfectly respond to a #sell (or #sellQuantity:)
message. Depending on the type of application it could know or interact with
other objects responsible for Stock for example to provide an estimated
delivery date and price. When a customer is not known through some context
it could be #sellToCustomer: or #sellToAccount:. But mostly to have a
delivery address and make sure payment is done. Not to have a customer do
the buying (as an act), that is irrelevant for most (web)shops.

There is often no need to have a person like object to fulfil the role of
actor (dare I say 'manager') in the object interactions. Objects have
behaviour and take on responsibilities of their own. Having a human like
object moves responsibilities away from the objects and creates unneeded
dependencies between objects. You'll quickly see conditional logic appear in
those classes.

Kids sometimes understand this way of looking at objects better than we
adults. A kid does not find it weird to see a movie or play in which a
teapot pours itself or where a CD plays itself.

So I do understand that a CD understands #play as a message. Perfectly fine.
We do not literally have to represent every physical object and its physical
characteristics in our world as objects in our applications. It is the
behaviour and responsibilities they posses that counts. (CRC cards are
really quite helpful in OO)

I highly recommend reading the book Object Thinking by Dave West. For sake
of clarity: yes, we are partners in ObjectGuild. See the link to the book
below. Don't be put back by the age of the book.

http://davewest.us/product/object-thinking/

Cheers,
Erik




--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
Reply | Threaded
Open this post in threaded view
|

Re: We haven't had a design debate in a while - thoughts on CD.buy article...

Christopher Fuhrman-4
Hello all - I am reviving this thread with some OO Design archaeology I stumbled upon while revising my course notes. In 1995 Peter Coad proposed a "Do it myself" pattern for assigning responsibilities that says:
"I do those things that are normally done to the actual object that I'm an abstraction of."

Anyway, this heuristic could explain cd.buy()

Here's the reference (but it's out of print...):
Coad, P. (1997). Object Models : Strategies, Patterns, and Applications (2nd Revised ed. edition). Upper Saddle
River, N.J : Pearson Technology Group.