Decisions an SDE has to make daily
Although software development looks pretty straightforward, once you develop a passion for building a product, you start realizing the potential of optimizing it.
Here is one such decision an SDE makes —
Say an engineer is calculating the running sum of an array. You can find the details of the problem here. Now you know that most programming languages pass arrays as references. This means any change done to the array inside the running sum function will directly change the array outside the function.
Another approach is to return a new array with the modified values.
Both approaches are valid but the decision-making process kicks in when —
- Say your algorithm has a strict memory budget. Maybe it is running on a device and not a web browser. Saving memory is of paramount importance in that case. So making changes to the array in place will make more sense and keep the space complexity to O(1) instead of O(n).
- But if you have no such constraints, then probably you will go ahead and make a new array and return it so that the input is immutable and best practices are preserved.
Software engineering is a continuous improvement process and there is no end to how much you can better a program. A reason why projects run for decades sometimes. Hence the name SDLC — SD Life Cycle.
It’s a way of life!