Live data from Hacker News

A Theory of Software Architecture

danuker.go.ro

91–100 of 246 posts

Re: A Theory of Software Architecture

#91

I understand that the point of his example is to introduce the reader to a variant of the very classic multitier architecture with layers. https://en.wikipedia.org/wiki/Multitier_architecture But I prefer the first version of the example, because while it's named "complex code" I think it's the simplest version. I think that there is no need to decouple this simple and straightforward function in three functions that…

This reminds me of Brian Will's "Object-orientation is Bad" where he makes the case that most decoupling tends to be more confusing than long-form code that's got sufficient comments. https://youtu.be/QM1iUe6IofM?t=2235

I think that

    fn x() {
        doStuff();
        moreStuff();
        forgotSomething();
    }
is pretty bad code, but that's probably because I consider procedures with no arguments and no return value a sign that something is poorly factored. However,

    fn x(y) {
       foo = doStuff(y);
       bar = moreStuff(foo);
       if (isSomething(bar)) {
           return theRest(bar)
       } else {
           return theBest(bar);
       }
    }
can be a good way to separate the why from the how and clearly communicate what's going on, especially with conditionals in the mix.

It's important, however, that these helper functions are not haphazardly strewn around the code base and accessible to things that don't need them. Depending on the language/context, I'd reach for nested function definitions or public/private keywords (or a combination), because definitely, it can be very hard to approach a big file with a bunch of (often poorly-named) functions that are defined at the same hierarchical level but not meant to be used at the same level.

Re: A Theory of Software Architecture

#92
post #69

Earlier quoted context omitted.

This reminds me of Brian Will's "Object-orientation is Bad" where he makes the case that most decoupling tends to be more confusing than long-form code that's got sufficient comments. https://youtu.be/QM1iUe6IofM?t=2235

I love his series. Eye opener for beginner coders.

Agreed. IMO it's an eye opener for experienced coders too.

Re: A Theory of Software Architecture

#93
post #2

Move most of your code to pure functions, that is the number one mantra to solve most scaling problems in software development. Even in an OOP paradigm, it makes sense to make almost all objects as purely functional, with limited use of internal state. The second mantra is to think a thousand times before you name something. I actually keep a list of names (..Manager, ..aggregator,etc.) gleaned from various sources,…

This reminds me of:

https://steve-yegge.blogspot.com/2006/03/execution-in-kingdo...

Re: A Theory of Software Architecture

#94
post #87

When I see a subroutine with a verb in its name I think of side-effects. In my book a pure function should be named after the result it returns, so in this case I would use the name `definition' instead of `find_definition' and `definition_url' instead of `build_url'. For predicates I try to avoid an "is" prefix when a simple adjective is sufficient.

Map, reduce, filter, fold, project, transform, group_by, bind, apply - any functional API you care to look is all verbs.

Functions do work. That doesn't mean they have to have side-effects; if they're functional, they do work on the input and produce output. Doing is a verb. It's natural.

Using a noun as a function name is at best justified when you have a situation where you want to hide whether data is being calculated on demand, or fetched from some storage or lookup table. Some languages bake this in, in the form of properties - attributes of a structure which look like fields, but are actually functions. Those things have nouns as names.

Re: A Theory of Software Architecture

#95

A few years ago I was on a team and the dev lead had a practice of sharing Gary Bernhardt's Boundaries talk every time there was some degree of rotation or churn on the team. Almost part of the onboarding. As a functional programming aficionado, I didn't need the sales pitch, but it was the presentation that was gripping. Keep in mind, Ruby isn't a functional language, but here was this presenter describing essential…

What is a functional language - something that encourages programming in a functional style, or actively outlaws imperative programming?

IMO it's pleasant to use Ruby in a functional style, much more pleasant than Python owing to the ease of chaining calls that take lambda arguments (blocks). Every time I try to do something similar to a big chained Enumerator stream in Ruby in Python using a list comprehension, I have to invert my thinking - as far as I'm concerned, those things are written backwards and inside out.

Re: A Theory of Software Architecture

#96

Way off the mark. "Software architecture" is about how you make the disparate parts of a software system work together towards a common goal. Most of these parts aren't code: hardware, programmers, tech support, HR, licensing and legal, etc.

I think you're confusing a software architect with a systems or enterprise architect.

It's true though that software architect is a vague term in our unregulated industry. Many companies never have software complex enough to need an architect; and many struggle through lack of a global plan, and just have lots of local decision making and get slower and slower over time.

Re: A Theory of Software Architecture

#97
post #91

Earlier quoted context omitted.

This reminds me of Brian Will's "Object-orientation is Bad" where he makes the case that most decoupling tends to be more confusing than long-form code that's got sufficient comments. https://youtu.be/QM1iUe6IofM?t=2235

I think that fn x() { doStuff(); moreStuff(); forgotSomething(); } is pretty bad code, but that's probably because I consider procedures with no arguments and no return value a sign that something is poorly factored. However, fn x(y) { foo = doStuff(y); bar = moreStuff(foo); if (isSomething(bar)) { return theRest(bar) } else { return theBest(bar); } } can be a good way to separate the why from the how and clearly com…

The former example was much easier for me to understand than the latter, even if it wasn't factored well. But I'm assuming that the functions aren't mucking about with global state or something equally distasteful.

Re: A Theory of Software Architecture

#99

I understand that the point of his example is to introduce the reader to a variant of the very classic multitier architecture with layers. https://en.wikipedia.org/wiki/Multitier_architecture But I prefer the first version of the example, because while it's named "complex code" I think it's the simplest version. I think that there is no need to decouple this simple and straightforward function in three functions that…

As someone who's been coding for 25 years, I agree with you.

I want code to be "clean and simple". Thats how I judge my own code and everyone else's. And the first example is indeed cleaner and simpler.

In my theory, you are only allowed to introduce more complexity (functions, frameworks, etc), when it makes it overall simpler and cleaner than before.

Re: A Theory of Software Architecture

#100
post #91

Earlier quoted context omitted.

This reminds me of Brian Will's "Object-orientation is Bad" where he makes the case that most decoupling tends to be more confusing than long-form code that's got sufficient comments. https://youtu.be/QM1iUe6IofM?t=2235

I think that fn x() { doStuff(); moreStuff(); forgotSomething(); } is pretty bad code, but that's probably because I consider procedures with no arguments and no return value a sign that something is poorly factored. However, fn x(y) { foo = doStuff(y); bar = moreStuff(foo); if (isSomething(bar)) { return theRest(bar) } else { return theBest(bar); } } can be a good way to separate the why from the how and clearly com…

Haven't you just described functional vs procedural programming?
Post reply on HN