3 ms·
How do you not realize at the 10th or 11th time you are writing the insert/remove from a doubly linked list that you should be making a reusable function to to
by alkonaut 4y ago
How do you not realize at the 10th or 11th time you are writing the insert/remove from a doubly linked list that you should be making a reusable function to to the job?
- kqr 4y agoI have seen junior developers do far worse things and consider it their job. It's easy to think that you were (in a sense) hired to type out that code over and over to realise the vision of the designer. If nobody tells you otherwise, you'll be more and more convinced of it for every time you type the code out.
- ramchip 4y agoGiven all the optimizations mentioned, I'd guess they used intrusive lists, which aren't straightforward to abstract. You'd have to use C++ templates or mess with the pre-processor to instantiate a copy of the functions for each type. Hence from the article: > Among its many features, storm contained an excellent implementation of doubly-linked lists using templates in C++.
- evouga 4y agoI mean, adding to a doubly linked list is just four lines of code and deleting is just two, right? A bit more if it’s possible for the list to become completely empty.
- desertrider12 4y agoI think the issue was more that they would copy-paste those lines from somewhere else and then forget to change one of the expressions.
- AshamedCaptain 4y agoIt's difficult to know without the context, but inserting/removing from a linked list is so simple it's probably shorter than a function call, and due to the limitations about how parameter passing works in C and many other languages, the code may even be cognitively simpler without the function call. In such a context, the only cost of not creating a function is that you make the code harder to refactor... hardly a concern for a game developer.
- desertrider12 4y agoI think Visual Studio at the time could inline functions - VS 6.0 from 1998 definitely could: http://www.cs.cmu.edu/~rbd/doc/optcode.htm http://www.cs.cmu.edu/~rbd/doc/optcode.htm. Especially if explicitly marked 'inline', then it would happen at lower optimization settings. I wonder if devs at the time were skeptical of relying on automatic optimizations, when a few years earlier doing it themselves was the only option. I could definitely see myself falling into that mindset.