Coffeehouse Post

Single Post Permalink

View Thread: General Programmer Question : how much do you reuse code/classes?
  • User profile image

    @evildictaitor: I'm not saying your way is wrong, nor am I under any illusion that I'm in any way qualified to judge your method as 'wrong', if there is such a thing, but that approach sets off two alarm bells in my head.

    The first one is complexity: an application that is basically just a place where you import a gajillion libraries sounds pretty complex to wrap your head around.

    Secondly, I'm a firm believer in the whole "You aren't going to need it" thing. I used to write everything, everything I was working on as a reusable component/library, and I eventually realised that I spent a lot of my time on making things I wouldn't ever reuse reusable. Nowadays, I take the approach that I write it so that it works, and if I ever need something I know I've already written before, only then do I take what I wrote and make it reusable.

    For instance, if I need some sort of special value converter for a weird databinding, I just write the convert method with some rudimentary type checking and that's it. If I'm working on something else that needs the same value converter, only then do I take the one I originally built, stick it in a library, make sure it's robust enough to survive anything thrown at it, and implement the ConvertBack method. Maybe I won't need it a third time, but the fact that I needed it twice is a good indicator to me that it needs to be reusable. The fact that I needed it once isn't. Obviously I haven't kept any metrics on this, but it feels like I've saved lots of time with this approach.

    For context: I used to write a lot of ASP.NET webapps and some WPF stuff, now I primarily work on relatively single-use WPF applications and some Windows Runtime stuff.