Developing Reusable .NET Components
Posted by archworx on June 10, 2007
I have been developing Custom ASP.NET Server Controls for a while now and I think it is worthwhile to write a series of blog posts about how to develop them. So here we go with the first introductory blog. First, let us think why developing .NET components is important. Well, first of all Microsoft has developed a decent set of components and controls for the .NET framework, but surely these preexisting components don’t fit every scenario that you might need when you are developing your application, so this is why creating new components (or extending existing ones) is needed. More importantly it is the concept of reusability that particularly makes developing such components useful. Identifying certain recurring scenarios and common functionalities and developing a certain component that can be reused by yourself and others without having to re-write the same code again is very valuable. A friend of mine has recently told me that “A good developer only writes code once”. This proverb, albeit an oversimplification, captures the essence of reusability. Great, so what implications does this have on you as a developer? Well, being able to capture repetitive scenarios into reusable code is very important. So next time you write code try to think if you have written this code before (or if you are going to write it again in the future) and if so then you can try to encapsulate it into a component that can be reused (even if this means creating a simple code snippet). This doesn’t only apply to code that you write, but if you are smart enough you can identify recurring patterns inside applications that your organization is developing and hence suggest how reusable components can be used within the company to improve the development process. So, with this introduction over we will turn to talking about Custom Controls in .NET and how they differ from User Controls. But alas, this will have to wait till the next blog.