Live data from Hacker News

Write code that is easy to delete, not easy to extend (2016)

programmingisterrible.com

101–102 of 102 posts

Re: Write code that is easy to delete, not easy to extend (2016)

#101
post #21

Earlier quoted context omitted.

There will always be edge cases, and yes they will make the code more complicated, but what really helps is automatic testing to make sure those edge cases don't break when making changes.

Setting up automatic testing alone tends to add its own layer of complexity. At least it's worth it.

It doesn't have to be difficult, for example when developing user interfaces I have a secret key combo for triggering the latest test, and another for running all tests. And I make mock functions that will trigger user interaction automatically. I inline the tests so they are next to the code being tested. I also place them inside comments so I can regexp remove the tests for the release because I don't want my program to be more then two MB, but if you don't care about size you could just leave the tests there so that they can be triggered by users in a prod environment as well. The problem with modern development is that the frameworks makes everything more complicated. Just ditch the leaky abstractions and increase your productivity 100x

Re: Write code that is easy to delete, not easy to extend (2016)

#102
post #3

C# is pretty good about these, with extension methods and event handlers. With event handlers instead of virtual methods, it's much easier to separate the pieces.

And yet the worst ever code I saw was in C#. I hope I won't offend anyone pointing at it [1]. This is a somewhat popular tool to evaluate macroeconomic policies in the EU. A combination of language choice (C# as a natural language Microsoft Excel bosses tend to request from their interns to use), the usual churn of academic undergrads and loads of other cultural failures are the reasons this monster exsts. Someone sh…

We agree with you. The state of the codebase is very bad.

We are rewriting the codebase from scratch in Rust and Svelte.

Post reply on HN