> Write everything twice There's an enhancement in a software I use/maintain that I wrote once and lost (the PC I wrote kaput and I was writing offline so I also didn't backup). It was an entire weekend of coding that I got very in the zone and happily coded. After I lost that piece of code I never could get the will to write that code again. Whenever I try to start that specific enhancement I get distracted and can'…
That's a good point. Particularly good pieces of work are hard to rewrite. I remember rewriting some piece of infrastructure once when I moved to another job, but I failed to summon the energy to rewrite it a second time at another job.
Algorithms we develop software by
41–50 of 108 posts
Re: Algorithms we develop software by
#42This is one of the best "programming advice" posts I've ever read, right up there with the grug brained developer.
Re: Algorithms we develop software by
#43Earlier quoted context omitted.
Of course they don't, how could they? How could anything, for that matter? (Apart from guarantees you could ensure statically, natch.)
> Of course they don't, how could they? How could anything, for that matter? Uh, that's literally what unit tests do? They tell you if you broke any of the cases they test for, before you release your implementation to other people...
Re: Algorithms we develop software by
#44Write everything (generally, new features) twice has turned out to be really good strategy for me, but it doesn't sit well with bizdev or project managers and tends to be perceived as unnecessary slowness. But if you plow through a feature and get it "working," you'll do much of that work cleaning up the logic and refactoring through your first pass. What rewriting allows you to do is crystalize the logic flow you de…
A project manager or bizdev person writes, rewrites, and rewrites again the document they produce do they not? Or do they write the perfect document at first go?
Re: Algorithms we develop software by
#45I’d say « Write everything three times » because it usually take 3 versions to get it right: first is under-engineered, second is over-engineered and third is hopefully just-right-engineering
Re: Algorithms we develop software by
#46Earlier quoted context omitted.
> Of course they don't, how could they? How could anything, for that matter? Uh, that's literally what unit tests do? They tell you if you broke any of the cases they test for, before you release your implementation to other people...
Well, that's a mutual misunderstanding then. I meant quite literally neither assertions nor unit tests prevent you from breaking things. Of course they'll help you to catch those mistakes before release. I didn't think that counts as prevention, my bad. Assertions should trigger during system testing if any contracts are broken, so under your interpretation they do prevent breakage as much as units test (meaning befo…
How do you "system test", say, string.indexOf(string)? Could you write a system test for this example to show us what you mean and help us see how they're superior to unit tests?
And how long and complicated are your system tests to catch breakages "as much as" a unit test would, for this example?
Re: Algorithms we develop software by
#47Re: Algorithms we develop software by
#48Of course, there are exceptions. ClickHouse implemented dozens of variations of HashTable just to squeeze out as much performance as possible. The algorithms used in ClickHouse came from many recent papers that are heavy and deep on math, which few people could even understand. That said, that's just exception instead of norm.
Don't get me wrong. Having a stable list of algorithms is arguably a hallmark of modern civilization and everyone benefits from it. It's just that I started studying CS in the early 2000s, and at that time we still studied Knuth because knowing algorithms in-depth was still a core advantage to ordinary programmers like me.
Re: Algorithms we develop software by
#49Earlier quoted context omitted.
Unit tests are a waste of time. Design by Contract + system tests are a far superior technique that take less time and find more bugs.
Confused, how do you ensure that a change to your implementation of some function isn't going to break clients after deployment if you don't have a unit test?
You might have realized users of software do things the engineers don't expect, which are not covered in unit tests.
Re: Algorithms we develop software by
#50Earlier quoted context omitted.
Confused, how do you ensure that a change to your implementation of some function isn't going to break clients after deployment if you don't have a unit test?
The client doesn't run your unit tests, but will run you contracts (because contracts deploy with you software while unit tests dont). You might have realized users of software do things the engineers don't expect, which are not covered in unit tests.
That's kinda the whole point... you run them to catch bugs and fix them so your clients never see the bugs you caught in the first place.
> but will run you contracts (because contracts deploy with you software while unit tests dont).
So you'd prefer your contracts to blow up your bugs in your clients' faces, rather than catch bugs yourself prior to releasing the code to them?!