2 ms·
It stores it as a collection of edges? Why not use adjacency list representation? You iterate through all of the edges every time to find a nodes neighbors? i
by whimsicalism 4y ago
It stores it as a collection of edges? Why not use adjacency list representation?
You iterate through all of the edges every time to find a nodes neighbors?
idk, this code just looks terrible to me.
- sdevonoes 4y agoBut TDD (the main topic being discussed here) has nothing to do with that, right? I mean, how on earth is TDD going to help you decide between a) using a simple data structure like a collection and b) a more sophisticated data structure like the adjacency list, if you have no idea what an adjacency list is?
- whimsicalism 4y agoYeah I was only commenting on what was being discussed in this particular subthread about whether this was good code/design.
- rmetzler 4y agoBut now you have the tests to be able to refactor the implementation and improve it. I’ve been in too many projects where devs almost never write tests. They cut corners by neither writing tests nor documentation because of time pressure. Then the code breaks in production with simple edge cases like NullPointerException and they need to fix it, so they don’t have time to write unit tests for the next feature. And it’s definitely harder to write tests after you implemented something.