Benjamin Tinker Team : Web Development Tags : Web Development

Reuse the code if it’s reusable

Benjamin Tinker Team : Web Development Tags : Web Development

Sometimes when churning out code it can be of great use to be able to re-use some previous code. There comes a point you are building a segment of code when you realise ‘hey, this code is probably going to be used again and again. Maybe I should re-factor it?’ Once you get to this you hope you have not already used the code too many times in the source to go back and replace it with a better control to cover all. Having a good piece of code that you write once and then ‘include’ in multiple locations like a .NET User Control is always the way to go..

However, when writing those ‘one control does all’ .NET User Controls be careful not to get too carried away. You could end up writing a piece of code that is so complex it becomes a bloated piece of code more that it does become useful. And be sure to check that the time spent making this perfect control does not take too much time that it would have been easier to use the CTRL-C, CTRL-V combination throughout the site. Re-useable code is good as long as you keep it simple (KISS).