Question

I'm working as a software developer for around 8 years now and have worked with mostly companies offering outsourcing services.The challenge so far was mostly - learn the new tech, showcase through a prototype/POC and implement it in the assigned project. Over the years, technologies changed, but nature of work remained the same - javascript, jquery, webforms, silverlight, MVC, etc. But now, am trying to transition to a software consultant role and one of the feedbacks that I recieved was - "Try to think in depth, as to not just use a feature but to relate it to the most basic concept that you know." e.g. as a best practice for string concatenation in C#, we know that we should be using stringbuillder and also know why we should be using it (string immutability), but the question was - How would you implement a StringBuilder class from scratch?

I'm not sure how to train myself for becoming ready for design thinking and making myself ready for in-depth thinking and analysis (since most of day to day tasks never require such rigorous drill-down).

PS: Sorry for long question and also even though the question is not suitable for platform, I would still be happy if anybody could point to a correct forum/community where i can reach out for guidance.

Was it helpful?

Solution

How would you implement a StringBuilder class from scratch?

By thinking very seriously about why I have to implement StringBuilder from scratch.

The proper reaction to that question is to ask "why?". Without a good reason why all you're doing is showing off that you know how to implement your own StringBuilder if stranded on a desert island. Not typically useful.

Now if the current StringBuilder has a bug that's causing you trouble or is missing a feature that would be useful then being able to reimplement it would be handy. Being able to extend it would be convenient.

"Try to think in depth, as to not just use a feature but to relate it to the most basic concept that you know." e.g. as a best practice for string concatenation in C#, we know that we should be using StringBuilder and also know why we should be using it (string immutability) -

String immutability isn't why. A single concatenation of immutable strings works just fine without StringBuilder. The problem is multiple concatenations can't be optimized if you don't consider all the strings first. Doing that lets you allocate enough memory for all of them at the start without allocating O(n2) more memory. Big O optimization isn't just about CPU cycles. Memory use is important as well. Simply making strings mutable doesn't make this problem go away. This is about when you figure out how much memory you need, before or after you've used a bunch of memory you really don't.

Understand that and you might be able to reimplement StringBuilder without embarrassing yourself. Also might help you realize when fanatically insisting on using StringBuilder every time isn't warranted. If you've never heard the Shlemiel The Painter story I suggest you give it a read.

Try to think in depth

I read this as: show me you can do more than regurgitate rules to follow by rote. Show me you've thought about why. Software development is chuck full of people following rules they don't really understand. Are you just another one of them?

I'm not sure how to train myself for becoming ready for design thinking and making myself ready for in-depth thinking and analysis (since most of day to day tasks never require such rigorous drill-down).

Keep asking why. Keep trying to explain why. You haven't mastered a topic until you can explain it to someone who keeps asking why.

Licensed under: CC-BY-SA with attribution
scroll top