Programmers only!
Which of these three software designs is best?
----
class Noun {
/* ... */
}
function verb(noun) {
/* ... */
}
let noun = new Noun()
let result = verb(noun)
----
class Noun {
/* ... */
verb(noun) {
/* ... */
}
}
let noun = new Noun()
let result = noun.verb()
----
class Noun {
/* ... */
}
class Verber {
/* ... */
verb(noun) {
/* ... */
}
}
let noun = new Noun()
let verber = new Verber()
let result = verber.verb(noun)
@evan oh no! I only just realised that when you say "Noun" you mean that types are sort of like nouns and terms of the types are sort of like names, whereas functions over types are sort of like verbs and interfaces are sort of like "verbers"!
I thought that we're taking about language processing related domain!
If we aren't, then I'm heavily in "it depends" camp. There is #ExpressionProblem, so while picking tools to encode your problem domain, you have to pick the closeness of extending "nouns" with more "verbs" or allowing a "verb" to work on more "nouns" based on the problem domain. There's no right answer and no reasonable way to prefer one over the other.
But from the standpoint of ease of understanding, facilitated the most by #DeclarativeProgramming, I would pick option 1 because it doesn't rely on traits, is explicit and separates "algorithms" (verb) and "data structures" (Noun) so that people can understand them independently.
@evan I take the polls very seriously!
@jonn oh no!