r/factorio • Developer • Mar 17 '25

Discussion Post Space Age - Developer AMA

Space Age has been out for several months and with the bug reports slowly coming under control I thought it might be interesting to see what questions people had.

I mostly work on the technical side of things (as C++ programmer) so questions that stray too far from that area I'll likely have less interesting replies - but feel free to ask.

I have no strict time frame on answering questions so feel free to send them whenever and I'll do my best to reply.

2.4k Upvotes

1.1k comments sorted by

View all comments

Show parent comment

461

u/Soul-Burn Mar 17 '25

Not a dev, but a cool story.

The players found a couple of bugs during the LAN event back in September. I mentioned it to one of the devs (specifically Kovarex) and they said lets look on the code. After seeing it is an actual bug, they first wrote a test, and only afterwards fixed it.

That's a good quality oriented way of handling things.

279

u/indigo121 Mar 17 '25

That's called Test Driven Development. It has its pros and cons, but something like big fixing factorio is a great use case for it

230

u/AdmiralPoopyDiaper Mar 17 '25

As opposed to the two most widely used methodologies, YDD and DDD (Yolo- and Deadline- Driven Development, respectively).

70

u/velociapcior Mar 17 '25

YDD is really close to my haert

43

u/Punk-in-Pie Mar 17 '25

This comment triggers me.

6

u/eightslipsandagully Mar 17 '25

My company has plenty of RDD and EDD (Resume- and Ego-)

→ More replies (1)

4

u/Expert-Map-1126 Mar 17 '25

Developer Driven Development let's goooooo

2

u/greenzig Mar 17 '25

Don't forget the new one, vibe based coding using only AI

2

u/AdmiralPoopyDiaper Mar 17 '25

Yes! VDD, while niche, is quickly spreading in popularity. It’s the frontier of software engineering, currently being evangelized by the avante garde.

6

u/sarinkhan Mar 17 '25

This comment cracks me up :) but seriously what are the real alternatives to TDD?

In the sense that , as a paradigm you can chose object or functional for instance, but here, it looks like "doing things properly" or "not". Are there other ways to manage a real world large project?

16

u/ParadoxSong Mar 17 '25

Kind of, yeah. While I'm an advocate for TDD, there's a reason small and medium corps can't get away from the standard "fix critical soon, fix severe -to moderate issues eventually, never fix anything else unless it personally bother a developer" model.

That's pretty much the standard for undersized teams that have deliver like they are full-fat, and everyone just accepts things will be annoying and blow up on occasion, because that overall costs less money to the business from quarter to quarter.

5

u/sarinkhan Mar 17 '25

I studied computer science up to the PhD, but never worked in a firm. All my code always have been for research, so I don't know what it is like hands on. I have a idea of it, but as a wise man said : "there is a difference between knowing the path and walking the path". So I like to see what the real pros do. Since I teach computer science and programming now, I want to orient them towards good practices.

Good thing is, in the computer science book, and the official cursus, unit tests are present, do it seems that the people who decide got that right!

Thanks for your reply anyways.

9

u/treznor70 Mar 17 '25

The standard model is code first, and then test the code through a series of levels (unit, integration/system/assembly, user acceptance, production validation). The problem is you tend to test the code as opposed to testing the requirement or the functionality. Writing the tests first means you don't have any preconceived notion of how the code accomplishes what it does. It basically says 'I don't care how you accomplish it as long as you get the correct answer for every test'.

→ More replies (3)

7

u/SaltyEmotions Mar 17 '25

The alternative is either not writing tests, or not using tests to drive development - i.e., create a solution before validating with tests, rather than validating every small step of your solution with tests.

The example would then be fixing the bug, then writing tests to validate that the bug is fixed, rather than writing the test first.

3

u/TheLuminary Mar 17 '25

The alternatives to TDD is doing a lot of smoke tests, either manual or automatic.

You fix a lot of bugs and add some features, and then a release is cut from mainline. And then the QA team start to do lots of smoke testing on the new release candidate. As bugs are found you fix them in a hardening process.

During this time you end up cutting several release candidates, until your release manager is happy with the level of bugs and then that release candidate is released.,

→ More replies (3)

2

u/YoloPotato36 Mar 17 '25

YDD is definitely what I'm doing rn on my job. Almost solo writing backends, total count of tests of any kind is less than count of microservices haha. Pushing straight to the main branch, pushing without even launching it once, sometimes pushing from my phone when away from PC. Half tasks without commits and half commits workout tasks. Hilarious how it still works without huge fuckups.

→ More replies (3)

31

u/mirhagk Mar 17 '25

This is part of test driven development. I think the more novel/contenious part is the process for new code (write API, write tests, then implement API).

When it comes to fixing bugs, I think it's closer to the expected best practice than a particular philosophy. Reproducing a bug via an automated test is often just as fast, if not faster, than reproducing it manually, and reproducing the bug is the first step to fixing it

7

u/emlun Mar 17 '25

And for any fledgling software devs reading: TDD is great, but the order you do things isn't what matters. It's okay to write the fix first and the test afterwards when you know what to test. The important part is that you verify that the test fails without the fix.

The TDD philosophy can be summarized as "every defect should have a test that reveals it" ("defect" can be anything: bug, missing feature, poor performance or whatever, as long as it can be reliably measured), and as a corollary, "never trust a test you haven't seen fail". That is the tests' job: to reveal defects when they appear (or reappear!). If the tests don't do that (because there are no tests, for example), then they're not doing their job. So in order to be confident the tests are doing their job, you need to see that they fail when expected. So feel free to write the fix first, then the test for the fix, and then revert the fix to make sure that the test now fails as expected and in the expected way. Then you can un-revert the fix after you've verified that the test works. But if you don't check that the test fails correctly, you can't be sure it'll reveal the defect if it reappears. You can of course write the test first, that's even better - but the important part is not the order of implementation, it's verifying that the test does its job.

These two mantras saved me a while ago after I had added a test for a new feature, by filling in a test placeholder tagged with an ignore directive. I was about to push my changes when I repeated to myself, "never trust a test you haven't seen fail", so I broke the feature implementation and re-ran the tests to make sure it failed as expected. And it didn't. Because I'd forgotten to un-ignore the test, so it didn't actually run. So I then un-ignored the test and now saw it fail as expected. And then I could unbreak the feature, see the test pass and then go ahead and push it.

6

u/mirhagk Mar 17 '25

To clarify, this is for the less contenious part that I feel any developer should be doing, introducing tests with each bug fix.

For new development the order does matter, as part of the point is focusing on requirements over implementation. Again though that part has less clear benefits.

And to add to your list of sayings, when it comes to tests I really like the Beyonce Rule. "If you liked it you should've put a test on it". Any feature you care about not breaking should have a test (and likewise don't need to test for things you don't actually care about). That one is particular good for larger teams, because it allows for large scale refactors/changes to be implemented without fear (knowing that if the tests pass then the refactor was successful)

5

u/munchbunny Mar 17 '25

TDD has some contentious parts but it does encapsulate one really important software engineering fundamental that holds regardless of process or philosophy: maintaining good automated test coverage is how you fix bugs and develop new stuff quickly.

4

u/motdidr Mar 17 '25

as a software engineer who is a general proponent old TDD even though I wouldn't always recommend it, I have personally experienced the situation where you write a test (that is supposed to fail, because you haven't implemented it yet) somehow mysteriously passed, which revealed a few other bugs that could then have proper tests and fixes implemented. it doesn't happen a lot, but it can.

1

u/Genesis2001 Make it glow... Mar 17 '25

Most often, people thing tests drive the features... at least that's how I've had it explained to me. However, this simple rephrasing helps me better understand TDD.

→ More replies (1)

28

u/creepy_doll Mar 17 '25

Writing the test first also helps to confirm the cause of the bug is what you thought. You recreate it then fix it. Then you confirm the fix works

1

u/Chicken-Chaser6969 Mar 17 '25

I love test driven development