No need to go in detail over this issue. When you write code, always separate your development into tiers. Even if it’s a simple “Hello World” project, it’s not overkill to have a data layer with your strings, a business logic layer that will manipulate or handle the string and a UI layer that does your console/window/website display logic.
It pains me to see how many times in the industry, this is not adhered to. Today, I was reminded why I do this. I created a separate layer (Project under Visual Studio) of my application that connects to a web-service and returns a ReadOnlyCollection<SomeCustomObject>. It handles my data manipulation and craziness. When my boss said “Hey, let’s try doing your application with an Access front-end as opposed to Word” I was able to swap the front-end with minimum effort.
End of the day, I had three front-end technologies… I used a console window for my own personal testing, a Word VSTO document for the original application front-end and a Access file with multiple reports for the final front-end. By encapsulating all of my business logic in another layer, switching front-ends is as easy as selecting which project to build.