Live data from Hacker News

Design Patterns – A comprehensible guide

github.com

91–100 of 112 posts

Re: Design Patterns – A comprehensible guide

#91
post #72
post #67

Earlier quoted context omitted.

My main point (just to make sure we are on the same page) was that whatever patterns are, we should also tell computers "look, here I use this pattern", and not rely just on humans to see it. Unfortunately, computers are idiot savants, so this very well might require those to be formally defined. Anyway, I think we have an ontological disagreement here. I don't believe the "design patterns" which cannot be formally d…

But you don't _talk_ exclusively in formalisms to other mathemeticians, do you? You don't immediately jump into a specific form of calculus upon first hearing of a concrete real world problem? And I'm not saying React itself is a pattern. I'm saying if you wanted to create your own React-like framework, or to communicate the design decisions and mechanisms that make it different from other frameworks, there is value…

> But you don't _talk_ exclusively in formalisms to other mathemeticians, do you?

In informal setting (like lecture or workshop), maybe not. But when publishing, you always talk in concepts that are defined formally. That doesn't mean that you use formal language all the time, but every time you introduce some definition or term, it is understood (obvious) that you could provide completely formal definition. Also, having a formal definition doesn't preclude using motivational examples.

So no, I don't think a book like "Design Patterns" could happen in professional mathematics today. Mathematicians simply don't introduce shared vocabulary of informal definitions. But it wasn't always like this - Euler used words like "curve" without having a completely formal definition (and without worrying about it). But eventually we learned this was a problem, and I think we will learn the same about programming patterns (and that's why people IMHO largely stopped trying to name new patterns).

> And I'm not saying React itself is a pattern.

Yeah, I understand, I was just taking a rhetorical shortcut. What I am saying you should be able to point at a set of functions of React and say "these embody one of the ideas behind React" (although there can be technical reasons that prevent doing exactly that on the current React codebase). Then the "pattern" you have in mind is well-defined by these functions.

> But if you think all things in the design of software are reducable to reusable pieces of code, more power to you.

I think it must be, because the "pieces of code" is the ultimate end goal. So there must be a point where the informal definition of pattern gets translated into formal code. And to do this translation reliably, you need to be able to enumerate (or parametrize) the choice of formal options that stem from the informal concept, and this process is actually the formalization of said concept.

I would say the software design patterns are rather special case, because they involve code readable by computer. In contrast, the original design patterns in architecture don't need to relate to computer code (there is no code reuse), so they are perfectly fine with not being formally defined.

Re: Design Patterns – A comprehensible guide

#92
post #89

Earlier quoted context omitted.

so, if i'd noticed you were dang before i responded i probably wouldn't have. only because i was trying to form a consensus. i didn't realize the consensus was being explained to me. :)

Not sure I know what you mean but I'm glad you responded—I like it when people respond :)

i appreciate your rational/educational/hands-on style of guiding culture.

so i was trying to say, without sounding like a pushover, that i may not have responded in fear of undermining your hard work.

cheers & thanks sir!

Re: Design Patterns – A comprehensible guide

#93
post #69
post #67

Earlier quoted context omitted.

My main point (just to make sure we are on the same page) was that whatever patterns are, we should also tell computers "look, here I use this pattern", and not rely just on humans to see it. Unfortunately, computers are idiot savants, so this very well might require those to be formally defined. Anyway, I think we have an ontological disagreement here. I don't believe the "design patterns" which cannot be formally d…

There are downsides to abstraction, too. The result of the urge of explicitly abstract every pattern can end up being a brittle network of dependencies. It can become really hard to adapt the formal abstractions to small requirement changes—either that or the abstractions end up byzantinely parameterized. Or you have to spend decades doing category theoretical research to discover the platonic essence of your pattern…

I think formalization and abstraction are two different things, and you conflate them in your comment.

Formalization, in my view, is about "knowing what you are talking about". So you have a perfectly defined set of basic operations on the concepts you use, and you know what you can do with them and what happens if you do; you cannot cheat by making stuff up as you go along.

On the other hand, abstraction deals with "how general I can make this thing" (AKA reusability).

What I mean by "formalization has won in mathematics" is that when you write a paper, all concepts you are using have to be formalized, or at least it must be obvious how they can be, typically through a shared context of standard theories (so you don't have to use formalism everywhere, although it would certainly be desirable and eventually I think it will happen).

But that doesn't mean you have to always use the maximal level of abstraction. It's perfectly valid mathematics, for instance, to prove a theorem just for Euclidean spaces even though there is nothing that could stop you from proving it for topologies. (And I think Bourbaki group learned about the cost of abstractions the hard way.)

The same is fine with code - if you think abstraction hurts it, absolutely go for lower level of abstraction. But it will hurt reusability of said code, no doubt.

But if you want to talk about some reusable concept, you should be able to show the code at the correct level of abstraction (or at least be able to show that you are able to show it).

So that's my beef with software design patterns - they are abstractions, but aren't formally defined. It's like eating a cake and wanting it, too. They are at best transient thoughts ("funny, this thing here looks awfully similar to that thing there, how so") before somebody should abstract them formally. And I cringe when people think that they help communication, because in mathematics, we already went through that.

Re: Design Patterns – A comprehensible guide

#94

why on github and not on like... medium?

Off the top of my head: 1. GitHub is a broadly-adopted tool that the author probably already knew how to use 2. It's hard to accept PRs on Medium 3. It allows the author to list the repository on his profile, thereby helping them convey competency to potential employers 4. It's easier to archive a git repo than a Medium post, and easier to rehost elsewhere in the future if/when GitHub dies. 5. Git allows change track…

lol - that's a good list. thank you.

Re: Design Patterns – A comprehensible guide

#95
post #88

Earlier quoted context omitted.

> I disagree. Why not call a duck a duck, and instead invent your own terminology, just because you're in a different field? Mathematicians invented those concepts first, whether you like it or not. Mathematicians discovered the existence of these structures first and gave them names. Programers also came across them, and there is no shame in giving the structures better names more appropriate to their own field - wh…

> Mathematicians discovered the existence of these structures first and gave them names. Programmers also came across them, and there is no shame in giving the structures better names more appropriate to their own field - whether mathematicians like it or not. Actually this is not what happened here - when programmers added the concepts you mentioned, they were very much aware of the mathematical counterparts. Regard…

> Actually this is not what happened here - when programmers added the concepts you mentioned, they were very much aware of the mathematical counterparts.

Yes, I am aware of it. I have read Wadler's papers pointing out that list comprehensions are a specific instance of a Monad and proposing Monads as a way to structure functional programs. But I wish the Haskell did not directly copy the term Monad into the language, setting off this bad precedent. Like CAR and CDR in Lisp, unfortunately, this one will stay in Haskell. Hopefully future languages will introduce more sensible terminology, like how Lisps have evolved over the years.

> Regardless, I think it is a shame to call the same thing differently just for the sake of it.

We have to agree to diasgree on this. IMO the intended usage of a concept should dictate its name, not how humans first arrived at it.

Re: Design Patterns – A comprehensible guide

#96

Earlier quoted context omitted.

You're absolutely right but you're not answering my objection. Show me an example of a type class with five functions and then how I can reuse it while overriding one of these five.

> Show me an example of a type class with five functions and then how I can reuse it while overriding one of these five. Huh? As I'm sure you're aware "type classes" != "classes", so I'm not sure why you're expecting them to be 'interchangeable' in this manner. It would be better to ask for some functionality (not a mechanism, as you're asking) and then show how one could be achieved[1] in one, but not the other. Per…

If two things (typeclasses, interfaces, whatever) are very similar, I just want to write how they're different. Without something like inheritance I also have to redundantly restate all the ways they're the same, which nobody benefits from, it's only an opportunity to make a mistake.

Re: Design Patterns – A comprehensible guide

#97
post #88

Earlier quoted context omitted.

> Mathematicians discovered the existence of these structures first and gave them names. Programmers also came across them, and there is no shame in giving the structures better names more appropriate to their own field - whether mathematicians like it or not. Actually this is not what happened here - when programmers added the concepts you mentioned, they were very much aware of the mathematical counterparts. Regard…

> Actually this is not what happened here - when programmers added the concepts you mentioned, they were very much aware of the mathematical counterparts. Yes, I am aware of it. I have read Wadler's papers pointing out that list comprehensions are a specific instance of a Monad and proposing Monads as a way to structure functional programs. But I wish the Haskell did not directly copy the term Monad into the language…

So what names do you think should be used instead of Monad, Applicative, Functor, .. ? (There was an interesting discussion about this on HN: https://news.ycombinator.com/item?id=9887728)

Funny, I actually prefer CAR and CDR in Lisp to FIRST and SECOND, and I learned it only a few years ago. (It seems to me that it's more poignant since the lists are composed of cons cells.)

I think it ultimately doesn't matter - the usage of the term dictates its meaning as much as the other way around (but this can again be my mathematical background talking, which explicitly tries to unteach you to intuit based on the names of things).

Re: Design Patterns – A comprehensible guide

#98
post #93
post #69

Earlier quoted context omitted.

There are downsides to abstraction, too. The result of the urge of explicitly abstract every pattern can end up being a brittle network of dependencies. It can become really hard to adapt the formal abstractions to small requirement changes—either that or the abstractions end up byzantinely parameterized. Or you have to spend decades doing category theoretical research to discover the platonic essence of your pattern…

I think formalization and abstraction are two different things, and you conflate them in your comment. Formalization, in my view, is about "knowing what you are talking about". So you have a perfectly defined set of basic operations on the concepts you use, and you know what you can do with them and what happens if you do; you cannot cheat by making stuff up as you go along. On the other hand, abstraction deals with…

I was using abstraction in the sense of "lambda abstraction", like a formally specified function with parameters.

Well, I had to remind myself what the actual design patterns "movement" is, and I get the impression that it's a dead movement with no development since the classic book and a very limited influence.

It seems that maybe the bigger problem is that there is no "theory of software" aside from a few interesting attempts like "algebra of programming" etc. That's why I can't really blame people for using software concepts that aren't formally specified.

What's your favorite alternative to design patterns, or like the path you think is more fruitful and good?

Re: Design Patterns – A comprehensible guide

#99

Earlier quoted context omitted.

> Show me an example of a type class with five functions and then how I can reuse it while overriding one of these five. Huh? As I'm sure you're aware "type classes" != "classes", so I'm not sure why you're expecting them to be 'interchangeable' in this manner. It would be better to ask for some functionality (not a mechanism, as you're asking) and then show how one could be achieved[1] in one, but not the other. Per…

If two things (typeclasses, interfaces, whatever) are very similar, I just want to write how they're different. Without something like inheritance I also have to redundantly restate all the ways they're the same, which nobody benefits from, it's only an opportunity to make a mistake.

You do not understand what a typeclass is or how it's meant to be used. If you are redundantly restating a single thing in a Haskell program, you have taken a very wrong turn.

Give me a single example of something that it turns out is truly better expressed through inheritance, and you will be on the shortlist for a Turing Award.

Re: Design Patterns – A comprehensible guide

#100

Earlier quoted context omitted.

> Show me an example of a type class with five functions and then how I can reuse it while overriding one of these five. Huh? As I'm sure you're aware "type classes" != "classes", so I'm not sure why you're expecting them to be 'interchangeable' in this manner. It would be better to ask for some functionality (not a mechanism, as you're asking) and then show how one could be achieved[1] in one, but not the other. Per…

If two things (typeclasses, interfaces, whatever) are very similar, I just want to write how they're different. Without something like inheritance I also have to redundantly restate all the ways they're the same, which nobody benefits from, it's only an opportunity to make a mistake.

My point is that it's not "(typeclasses, interfaces, whatever)". They're similar, yes, but my point is that they aren't similar enough in the "mechanical" sense that the parent poster seems to be assuming.

EDIT: Btw, I think it may actually be possible to encode what the parent poster wants by just having a type class per method, but it's obviously a weird and non-idiomatic encoding given the presumed lack of any laws.

Post reply on HN