Live data from Hacker News

A Theory of Software Architecture

danuker.go.ro

181–190 of 246 posts

Re: A Theory of Software Architecture

#181
post #169

The only mantra about code organization I subscribe to is that it should be as simple as possible. Sometimes it means using several layers of abstraction like in this article. Usually it means just writing the damn thing in the most straightforward way because simple implementations are easy to adapt for future changes.

"Most things aren't rocket science."

Re: A Theory of Software Architecture

#183
post #166

I prefer the first example. It’s more straightforward and avoids accidentally creating dependencies (for example some other code calling pluck_definition) that will be make it harder to modify when you need to add features or the API changes. Testing pluck_definition by itself is completely pointless since it does nothing on its own. This is the “test public interfaces, not private implementation” principle. Similarl…

> I also dispute that it’s hard to unit test the first function—-you would simply mock the api response and then you have a great test. How many times have you seen a test pass or fail when it shouldn’t have because the mocks didn’t match the actual code? It’s a useful technique but it has drawbacks which are not easily prevented.

We use mocks a lot on my team, and I don't think we've ever seen what you describe. Maybe you're using mocks incorrectly?

Re: A Theory of Software Architecture

#185
I had discovered this recently too and asked a relevant StackOverflow question about how people deal with lots of I/O.

https://softwareengineering.stackexchange.com/questions/4160...

The premise is the imperative shell can become pretty riddled with decisions if your application contains a lot of I/O.

Some like the "Free Monad" solution, but I found that too be too coupling.

Re: A Theory of Software Architecture

#186
post #158

Earlier quoted context omitted.

> every reference to another object is injected via a DI framework And it's injected with an interface, not a concrete class, so you have to go on a giant easter egg hunt to even figure out which class is being injected... only to eventually discover that there's only one class that implements that interface.

> only to eventually discover that there's only one class that implements that interface I mean, in this case it's literally: * right click on "someInjectedService" * select "Go To Implementations" and you'll be there. Generally I do relate to the complaint though. DI makes your project feel like a "system" as opposed to a "program" (not that this is a bad thing or unnecessary).

That's the simple case. When it's a big chain of injected dependencies and you have to untangle the whole thing, it gets annoying quickly.

Re: A Theory of Software Architecture

#187
post #15
post #3

So applied Onion Architecture. I agree with this part. However, the functional part of the discussion, while I agree with its benefits, is highly depending on the domain within the onion.

Generally, to those of us who apply the functional approach everywhere, it comes naturally whatever the problem. There are idiomatic ways to program in particular languages (even in Python or JavaScript) which are strictly against the functional approach, even though nothing in those languages prohibits it. It gets trickier with external dependencies which are "forced" on you too. Do you have a concrete "domain" exam…

Multithreaded embedded systems. Yes, the functional people are absolutely correct that shared mutable state is evil. If that's the world you live in, though, you need to deal with it effectively. You need to have thread 1 able to respond to an external event by changing shared state that thread 2 sees, but in a controlled way so that thread 2 never sees an inconsistent state.

Now, there is a place for pure functions in that environment. But making decisions based on state can run so thoroughly through the code that "functional core" leaves very little core.

Re: A Theory of Software Architecture

#188

Earlier quoted context omitted.

> Use mostly functions, try to make most of them pure. This reminds me of: > Eat food, not too much, mostly plants > > -- Michael Pollan My new mantra: Write software, not too much, mostly functions.

"Not too much" is interesting. If I understand you correctly, you can write "too much software". I can think of at least three ways - bad architecture, too little abstraction forcing repetition, and just bad writing. Did you have something else in mind here?

I believe “Not too much” is a simple reminder that more code equals more bugs. So, try to write less code whenever possible.

Re: A Theory of Software Architecture

#189
I think what I would need mostly is: - dependency inversion, try to push decision as later as possible by using this technique + interfaces - separate pure functions vs side effects functions - static typing that can help me with structs and interfaces with optional value

It ends up with a lot of typing but I think it is worth the trouble. Down the road it is easier to maintain and it already saves you time anyway.

Re: A Theory of Software Architecture

#190
post #133

Earlier quoted context omitted.

Are you actually a programmer? You sound more like an academic with no real life experience on large software. You do realize that within those "neatly separated layers of yours" there will be an insane amount of complexity which will be impossible to separate in layers?

> Are you actually a programmer? Why, yes I am. > You sound more like an academic with no real life experience on large software. Well, I do work as a software engineer for a FANG, so that does fit the bill I guess. > You do realize that within those "neatly separated layers of yours" there will be an insane amount of complexity which will be impossible to separate in layers? Well, there really isn't you know? I mean…

Trust me I'm considered a very good developer and simplification is something I always put as top priority.

You on the other hand still belive you can make everything totaly managable forever and always and in any situation.

Your academic tone betrays you: you obviously believe you can always split things into neat little parts and then write books about it and how even in production this is so easy and always "just a bit of layering and it will work".

Anyone who worked on real production systems over years knows that unless your company has infinite money for developers and infinite time that you will sooner or later get parts on which complexity starts getting layered on.

But hey, "just add a few layers".

Also being a FANG developer means nothing. I've heard stories about FANG company developers, they are not very FANG-like to say the least.

Post reply on HN