Live data from Hacker News

How to join a team and learn a codebase (2020)

samueltaylor.org

51–58 of 58 posts

Re: How to join a team and learn a codebase (2020)

#51
post #41
post #10

Earlier quoted context omitted.

I recently joined a new team and codebase. There was no 'getting started', no docs. I was left on my own. So I muddled through. And documented everything in Makefiles. Not readme, but working code. Now `make clean` `make install` etc, all run, deploy, install, clean etc the project. A great way to learn. But unfortunately worthless to others in the team, as they all were entrenched in their own ways and setups. I jus…

What is the benefit of makefiles over bash scripts?

A Bash script is a linearization of the dependency graph, a Makefile is a description of the graph itself.

Re: How to join a team and learn a codebase (2020)

#52
post #41
post #10

Earlier quoted context omitted.

I recently joined a new team and codebase. There was no 'getting started', no docs. I was left on my own. So I muddled through. And documented everything in Makefiles. Not readme, but working code. Now `make clean` `make install` etc, all run, deploy, install, clean etc the project. A great way to learn. But unfortunately worthless to others in the team, as they all were entrenched in their own ways and setups. I jus…

What is the benefit of makefiles over bash scripts?

- Make is a standard utility, so anyone that has used make before will know what 'make', 'make clean', etc will do without having to read any documentation.

- Make has the ability built-in to only run certain commands based on the files that have changed, which can be handy.

- Makefiles usually have a lot of handy variables for configuring the project like $CC or $DESTDIR. While you could have these in a bash script as well, there's a standard convention for variables in Make[1].

In my experience, Makefiles are usually better documented and follow more conventions than scripts. There are of course many exceptions to every rule.

Make files are very similar to bash scripts, and while I would prefer a Makefile any day, it's really a matter of preference.

[1]: https://www.gnu.org/prep/standards/html_node/Makefile-Conven...

Re: How to join a team and learn a codebase (2020)

#54

Earlier quoted context omitted.

I just joined a new team as a lead and #2 is killing me, to the point where I have felt like giving up. The documentation my team was given was a hastily thrown-together hack that was full of missing and incorrect steps. It should not take more than a few days to set up a local development environment, but I’ve had to fight for admin rights, ask a million questions, and have other leads work with me for days on end (…

Yeah, it's crazy to me how common it is to just let basic dev environment polish languish. In a small enough place, I usually will just fix whatever is slowest and most annoying about it myself. At bigger places... good luck. Sometimes you can get away with hacking together some scripts that do things for your personal setup, but if there isn't buy in to fix the problem you're often out of luck.

But I think this one point is the one item that ultimately decides on the lifetime of a project and whether it will turn legacy. If the README doesn't even describe how to start the project or successfully invoke a single unit test, how is anyone going to deploy this or change anything of the core code? Also not having this usually means unreliable deployments, broken CIs and constant firefighting. This might be considered acceptable for 1-person-projects until that one person might change projects or jobs.

Re: How to join a team and learn a codebase (2020)

#55

I wonder why no one has not mentioned tests. For me, the tests are more valuable for system or service understanding than, for example, documentation. But the best scenario when you combine tests and documentation. I have joined the new team recently. They have a lot of e2e BDD tests implemented using the Cucumber framework. It helps me to get a complete view of the system in the shortest possible time.

Somewhat related; I've always been very curious why a lot of developers I've worked with seem to think testing isn't worth the effort, and I've been keeping a mental checklist of all the reasons/excuses I hear so that I can reflect on them as well against my own experiences - sort of a way to challenge myself and ensure I'm not just cargo-culting methodologies. Recently I decided to go through `Growing Object-Oriente…

I agree. Everyone should consider the costs and benefits of testing to arrive at a system that works for them.

Early on in a system design, I prefer going overboard with integration tests.

The architecture is hard to predict early on, so I don't want to get paralyzed on figuring it out. Just get the tests passing without overthinking.

Once I find a better way to do things, I can rip apart and restructure the internals with the safety net of end to end tests.

I rarely write unit tests at this stage because the effort of writing and rewriting them adds friction to getting the software working and restructuring the code.

If every time I redraw a boundary, I need to rewrite a bunch of unit tests, I'll be less likely to improve the code quality.

Re: How to join a team and learn a codebase (2020)

#56
post #52
post #41

Earlier quoted context omitted.

What is the benefit of makefiles over bash scripts?

- Make is a standard utility, so anyone that has used make before will know what 'make', 'make clean', etc will do without having to read any documentation. - Make has the ability built-in to only run certain commands based on the files that have changed, which can be handy. - Makefiles usually have a lot of handy variables for configuring the project like $CC or $DESTDIR. While you could have these in a bash script…

I think we also need to be careful. The OP on this thread did not specify what kind of project. Make may be completely appropriate. It might also not be and just what they are used to. The proverbial hammer.

If someone came in and tried to build my Java project with Make, I would definitely call them crazy and not use it either. If someone came to my Java project and tried to put Gradle on it to build it, I might also not use it but at least its appropriate for the language and if everyone on the team/project was OK with it, I would probably be OK with it and use it.

If someone tried to build my FE Javascript project with Make, I would not use it. If they used yarn instead of npm that would be a Gradle vs. Maven situation as above, so either's fine if there's nothing yet.

If there's a set of bash scripts that are perfectly adequate to build the project you have, fine, why use Make?

And let me tell you from experience, conventions are great but don't always work, i.e. no $CC and $DESTDIR are definitely not something every user of Make does appropriately. I've had to add that to a few back in the day. You install like you're used to with DESTDIR only to find that it just installed itself into your system. You swear, fix it and learn to _always_ check a newly downloaded project for whether they actually have the 'standard' features implemented before you build something.

Contrast that with many of the newer build and packaging tools, that basically take this choice away from the user, which is a great thing if you ask me. Sure you have to get over the "but I want to do it my way" defiance reaction but in the end it is awesome when each new project you come to you do _not_ have to check and learn how exactly that project does things because every Maven project has its stuff in the same place (unless someone re-configured it, which unfortunately does happen). But maven is bad nowadays, coz it uses XML :(

Re: How to join a team and learn a codebase (2020)

#57
post #52

Earlier quoted context omitted.

- Make is a standard utility, so anyone that has used make before will know what 'make', 'make clean', etc will do without having to read any documentation. - Make has the ability built-in to only run certain commands based on the files that have changed, which can be handy. - Makefiles usually have a lot of handy variables for configuring the project like $CC or $DESTDIR. While you could have these in a bash script…

I think we also need to be careful. The OP on this thread did not specify what kind of project. Make may be completely appropriate. It might also not be and just what they are used to. The proverbial hammer. If someone came in and tried to build my Java project with Make, I would definitely call them crazy and not use it either. If someone came to my Java project and tried to put Gradle on it to build it, I might als…

This was a Node, Rails and-then-some project.

Rails comes with Rake, the Ruby make. Node comes with 'scripts' and then gulp, grunt, or whatever the node-js-buildsystem of january 2021 is. 'and then some' is a bash script or four, custom rake tasks, bash-scripts+follow-some-wiki and so on.

Make's other great advantage is that it makes a great 'overarching' general setup. Whether I have a rails, node, ansible, cargo/rust, jekyll-project, `make install` installs it, `make [build]` builds it, `make test` tests it and `make deploy` deploys it. It solves the "yea, but here you need npx" and "this will only work with bundle exec prefixed" or "you have to run this with `python2` as `python` is python 3 and... We all know these cases.

Edit: or, in your examples: `JAVA_HOME="." maven build` is fine. As is `PDF_BUILD=true maven run test {integration,unit,model,jobs}` already less so (I don't know much about maven). All require the dev to know how to operate maven, to learn that this project uses maven and to know the intricacies of maven. But they could all be abstracted away beind one predictable `make build` and `make test`; and whould therefore work for your maven project, node project, that ancient ant-setup and whatnot: all the same (well, if they all have a Makefile, that is).

Re: How to join a team and learn a codebase (2020)

#58
post #57

Earlier quoted context omitted.

I think we also need to be careful. The OP on this thread did not specify what kind of project. Make may be completely appropriate. It might also not be and just what they are used to. The proverbial hammer. If someone came in and tried to build my Java project with Make, I would definitely call them crazy and not use it either. If someone came to my Java project and tried to put Gradle on it to build it, I might als…

This was a Node, Rails and-then-some project. Rails comes with Rake, the Ruby make. Node comes with 'scripts' and then gulp, grunt, or whatever the node-js-buildsystem of january 2021 is. 'and then some' is a bash script or four, custom rake tasks, bash-scripts+follow-some-wiki and so on. Make's other great advantage is that it makes a great 'overarching' general setup. Whether I have a rails, node, ansible, cargo/ru…

You seem to be assuming that people know make. People don't any longer. People that grew up with C, built their Linux system from scratch etc. know Make. For someone that doesn't know make, none of what you say comes natural or 'makes sense'.

Also, make is a very general purpose tool. You don't have to have a `test` target. I could easily call the target `analyze`. Do you store your compiled files in a `dist` folder? Or do they just end up right next to the source files? Where are your test files stored vs. your main project files?

In the Java world the equivalent of Make would have been ant at some point. People did exactly what you said you would do with make. Most people had the default ant run build the project, test would test it etc. but everything else was a complete free for all.

What Maven did was standardize a lot. The test goal (goal being maven speak for make targets) is always called test. All build output always goes to the `target` folder. maven always expects your test files nicely out of the way of regular source files and they never end up in the resulting package etc. The package(s) always end up in the target folder too. Most if not all of these things can actually be changed but it's work to do it and you can easily see it being reconfigured vs. build tools like Make or Ant, which are much more general purpose like shell scripts.

I could make the same assertions about maven btw. as you do about Make. Once you know maven, you can build anything you like with it and it takes care of all of the same things. In a previous life we actually regularly packaged non-java projects with maven, since that was the hammer we had and understood.

Post reply on HN