Live data from Hacker News

Donkey code

einarwh.wordpress.com

21–30 of 64 posts

Re: Donkey code

#21

The problem is not with naming, the problem is with OOP, specifically inheritance and encapsulation. You could have separate entities for horses, donkeys, mules, zebras and functions that work on them. Maybe less code reuse but state is kept separately, code is very easy to understand, modify and implement. And also is faster to implement. If you have too many ifs in some functions you have to ask yourself if you arc…

I didn't read this post as relating to OOP, more to have with defining specific terms and modelling the domain as it relates to business needs. In the example given, the business didn't recognize that they are dealing with donkeys. In a real project you could have eg invitation vs user account. Is the invitation its own model associated with a future user account or just a placeholder user account. Things change when you have other admin accounts that have to assign those users to other entities before the user is signed up in the system for example. (maybe it's a contrived example, couldn't thing of something better)

Re: Donkey code

#22
post #8

This is why I'm a big fan of "name it Steve" philosophy. When we create a new service many people are inclined to call it something like "rhombus keyboard fibriculator" or "octatonic runner". Usually it's of the form "{verb}er" or "{noun} {verb}er" or "{adj} {noun} {verb}er" or whatever. It's never accurate, and it's super confusing because chances are there is some other "{x} {y} {verb}er" with the same "verb". Not…

> This is the power of mathematics really.

I don't think your comparison makes sense. The power of the "name it Steve" philosophy is the same rationale behind adopting codename for projects: it helps create a context to disambiguate discussions. As part of Steve, you work on the Steve web app and on the Steve service. The Steve service later can be refactored to peel out one of Steve's microservices listening to Steve's message broker.

Later if Steve needs to consume data from Pluto, you know that Steve's service will chat with Pluto's service, and perhaps have Steve's message broker listen to some channels in Pluto's message broker, etc etc. Zero ambiguity.

Moreover, monoliths have a propensity to outgrow responsibility-driven names. With a monolith you might start with a widget service, which then handles transactions, inventory, and order history. Once any of those responsibilities is peeled off to a microservice, do you still have a widget service along with a widget inventory service? Is it ok to keep calling widget service the widget service if it only handles widget order history?

Re: Donkey code

#23
post #8

This is why I'm a big fan of "name it Steve" philosophy. When we create a new service many people are inclined to call it something like "rhombus keyboard fibriculator" or "octatonic runner". Usually it's of the form "{verb}er" or "{noun} {verb}er" or "{adj} {noun} {verb}er" or whatever. It's never accurate, and it's super confusing because chances are there is some other "{x} {y} {verb}er" with the same "verb". Not…

In my company we resorted to name many internal tools and libs after birds.

It becomes a problem though when you want to publish open source tools or libraries. These days it becomes very hard to find a name that isn't already attached to a Github repo. Finding a name that is googlable, unique, somewhat intuitive and descriptive is a problem that does not scale at all.

I'm not surprised the NSA ended up generating names for their tools. At least that's what they seem to do judging by names like Eternal Blue, Double Pulsar, Dander Spritz and the like. (https://en.wikipedia.org/wiki/The_Shadow_Brokers#Fifth_leak:...)

Re: Donkey code

#24
A beautifully written piece with lovely images. At some stage in my (ongoing) OO enlightenment, I got to appreciate that in a healthy OO codebase, there should be constant refactoring and code movement in order to adapt to small and large changes (and that there is a lot of judgement in when to opt for a big change when requirements are only incrementally arriving.)

While I agree with much of the sentiment about clear naming, I think that many languages with OO capabilities fail to provide easy to use role based composition at their peril. It is a big challenge to do wrestle real code and we need all the tools we can get.

Here's how it could look with roles at a coarse grain level:

---

role Breedable { ... }

role Feedable { method eat-carrot { ... } }

role Trainable { ... }

class Horse does Breedable does Feedable does Trainable { has $.sound = 'neigh'; ... }

class Donkey does Breedable does Feedable does Trainable { has $.sound = 'heehaw'; ... }

my $h = Horse.new(); $h.eat-carrot();

---

The benefit of roles is that they let you apply your human language skills (English, French, etc) to combine words as in natural languages - so roles are akin to Adjectives and classes to Nouns, and method names to Verbs.

With roles, you can avoid the temptation to hardwire inheritance:

---

class Donkey is Horse { ... }

---

And it leaves open the option for layers of specialization of roles like this:

---

role DonkeyTrainable does Trainable { ... }

class Donkey does Breedable does Feedable does DonkeyTrainable { ... }

---

And you can use inheritance and role composition side by side:

---

class Beast Breedable does Feedable does Trainable { ... }

class Horse is Beast { ... }

class Donkey is Beast { ... }

---

Here's what it says in the docs: _Roles are a collection of attributes and methods; however, unlike classes, roles are meant for describing only parts of an object's behavior; this is why, in general, roles are intended to be mixed in classes and objects. In general, classes are meant for managing objects and roles are meant for managing behavior and code reuse within objects._

btw these examples are in raku ... https://docs.raku.org/language/objects#Roles

Re: Donkey code

#25
post #8

This is why I'm a big fan of "name it Steve" philosophy. When we create a new service many people are inclined to call it something like "rhombus keyboard fibriculator" or "octatonic runner". Usually it's of the form "{verb}er" or "{noun} {verb}er" or "{adj} {noun} {verb}er" or whatever. It's never accurate, and it's super confusing because chances are there is some other "{x} {y} {verb}er" with the same "verb". Not…

  SEND
  
  HAVE ISOLATED ORGANISM WISH CODING


  MESSAGE FROM CENTRAL CODES FOLLOWS
  
  OPENING NEW CATEGORY
  
  CODE FOR YOUR ORGANISM WILL BE ANDROMEDA
  
  CODE WILL READ OUT ANDROMEDA STRAIN
  
  END MESSAGE

Re: Donkey code

#26
post #8

This is why I'm a big fan of "name it Steve" philosophy. When we create a new service many people are inclined to call it something like "rhombus keyboard fibriculator" or "octatonic runner". Usually it's of the form "{verb}er" or "{noun} {verb}er" or "{adj} {noun} {verb}er" or whatever. It's never accurate, and it's super confusing because chances are there is some other "{x} {y} {verb}er" with the same "verb". Not…

>"name it Steve" philosophy

I think of these kinds of names as being like primary key fields in a database: Their main purpose is to distinguish the identities of various things, so it's better not to incorporate any functional/behavioural description into them because that way there's never a need to change the name in the future if the behaviour changes.

The downside is that the names become arbitrary lumps of data that you have to become familiar with by rote use.

Re: Donkey code

#27
post #8

This is why I'm a big fan of "name it Steve" philosophy. When we create a new service many people are inclined to call it something like "rhombus keyboard fibriculator" or "octatonic runner". Usually it's of the form "{verb}er" or "{noun} {verb}er" or "{adj} {noun} {verb}er" or whatever. It's never accurate, and it's super confusing because chances are there is some other "{x} {y} {verb}er" with the same "verb". Not…

You think ‘Galois field’ is better than ‘finite field’?

Re: Donkey code

#28

This one's epic. I believe this is a fundamental aspect of OOP. Name different "things" differently!

I thought it is more about recognising that they are talking about a different thing they have to name instead of adding additional qualities to it.

Re: Donkey code

#29
post #23
post #8

This is why I'm a big fan of "name it Steve" philosophy. When we create a new service many people are inclined to call it something like "rhombus keyboard fibriculator" or "octatonic runner". Usually it's of the form "{verb}er" or "{noun} {verb}er" or "{adj} {noun} {verb}er" or whatever. It's never accurate, and it's super confusing because chances are there is some other "{x} {y} {verb}er" with the same "verb". Not…

In my company we resorted to name many internal tools and libs after birds. It becomes a problem though when you want to publish open source tools or libraries. These days it becomes very hard to find a name that isn't already attached to a Github repo. Finding a name that is googlable, unique, somewhat intuitive and descriptive is a problem that does not scale at all. I'm not surprised the NSA ended up generating na…

In WW2, British intelligence analysts inferred that a secret Nazi radar system used only a single beam based on its code name: Wotan (Odin), a god with one eye. For a long time, I have occasionally referenced this example, but today I learned that it was actually sheer luck. The prior radar system that used two beams was also codenamed Wotan.

https://en.wikipedia.org/wiki/Battle_of_the_Beams#Y-Ger%C3%A...

Post reply on HN