Live data from Hacker News

Ask HN: Best codebases to study to learn software design?

news.ycombinator.com

31–40 of 94 posts

Re: Ask HN: Best codebases to study to learn software design?

#31

My immediate reaction to this question is: "your team's". Nothing will teach you more about how to design software then really understanding why good and bad solutions were adapted to solve a certain real problem. Software exists precisely because there is still a messy layer connecting user requirements to actions on a computer. If there was not messiness then we could just automate it all. Approaching software from…

What if the question is born out of the insight that his team's software is poorly designed, motivating the desire to get outside input? What if the question is asked by a college student?

I would be interested in recommendations for those who have a poor example or no examples

In my case, I'm a junior engineer that has recently been given more responsibility designing aspects of our product. I'm just trying to learn all I can so my designs will be good!

Re: Ask HN: Best codebases to study to learn software design?

#32
Trying to learn software design by looking at code is kind of like trying to learn about architecture looking at the bricks that make up a building.

To learn about design you need a wider perspective. You can theoretically learn it from code but it won’t be most effective. Look at great documentation and literature about design instead.

Re: Ask HN: Best codebases to study to learn software design?

#33

Maybe I’m just not good enough at paying attention, but for me it seems like you have to actually run into problems over and over and figure out how to avoid the problems. Then you end up being able to mentally simulate what problems you will run into, and design is basically all about avoiding future problems of various kinds (and balancing tradeoffs about which future problems to avoid and how much effort to put in…

This is pretty much how I've learned up to this point (and will of course continue). Trying to learn from real world code will be a new experience for me. Not sure how valuable it will be but should be fun either way.

Re: Ask HN: Best codebases to study to learn software design?

#34

Maybe I’m just not good enough at paying attention, but for me it seems like you have to actually run into problems over and over and figure out how to avoid the problems. Then you end up being able to mentally simulate what problems you will run into, and design is basically all about avoiding future problems of various kinds (and balancing tradeoffs about which future problems to avoid and how much effort to put in…

That's kinda like saying you can learn to drive by just getting into a car, crashing then thinking about how not to crash it next time.

In reality both things are necessary. The car analogy doesn't hold for road driving because we drive well within the limits, but for racing it really is necessary to know exactly where the limits are. I don't think we should really be treating our profession like a race, though.

But if you don't read it's going to be an incredibly long slow process and a lot of car crashes and mangled gearboxes etc. So I say read, read, and read some more. Even if you don't see the point of it right now your experience will later find a place for it and you won't end up descending a hill for the first time not knowing to shift to a lower gear.

Re: Ask HN: Best codebases to study to learn software design?

#35
I think there is value in groking entire code bases. It's not just about whether or not they are well designed though. It is an important skill to be able to analyze and see the big picture of how things work together in large systems. For me it often involves drawing diagrams (sometimes UML) to map things out. Being able to view systems in this way is a pre-requisite to intentionally designing your own systems at this level. And yes, once you can work at this level you can learn from good designs, but also see problems with bad ones.

EDIT: and to answer your question, if you're working on something that is "like X but different" then read the source code for X. You could also look at source code for software that you use from day to day: software where you already know what it does. For example, if you're in web, maybe the web framework, or web server, if you write python, maybe a core library that you use, or maybe the python interpreter, or if you use vscode ..., if you use android ..., you get the idea. At the start I would suggest smaller programs, and programs where you already know the domain (e.g. cpython might not be the best place to start if you never implemented an interpreter before, you may spend more time learning about interpreters than the design of this one, still a good thing to learn of course.)

Re: Ask HN: Best codebases to study to learn software design?

#36
post #32

Trying to learn software design by looking at code is kind of like trying to learn about architecture looking at the bricks that make up a building. To learn about design you need a wider perspective. You can theoretically learn it from code but it won’t be most effective. Look at great documentation and literature about design instead.

Yeah, I guess without the context I wouldn't really understand why it was designed that way. Or know what situations a design like that would be good for.

Is there any documentation or literature that has helped you?

Re: Ask HN: Best codebases to study to learn software design?

#39

Your own. Everyone else's is trash. Never understand someone else's code-- the whole point is that there should be just a handful of functions of yours I can call, and shouldn't ever care to see how the sausage is made. Otherwise, your abstraction sucks

I agree that the internals of my code should be abstracted away from my users. But don't I still want the internals to be well designed so they are maintainable and extendable?

Re: Ask HN: Best codebases to study to learn software design?

#40
post #26

I dont think this is a good idea, actually. Good design is about making good trade offs at the right point in time. A code base with excellent design will show you the end state but not how it got there but probably not the trade offs and decisions involved. Practicing refactoring on subpar code bases and dealing with the consequences of your decisions is a better way to improve.

Are there any books or websites you'd recommend I read to learn more about design instead? I 100% need to learn by doing, but wouldn't it also be good to learn what has already been discovered so I don't have to reinvent the wheel? Or is it best to discover good design on your own?
Post reply on HN