Click here to Skip to main content
15,887,434 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
AnswerRe: Refactoring the code or dessign? Pin
led mike30-Jun-08 5:31
led mike30-Jun-08 5:31 
GeneralRe: Refactoring the code or dessign? Pin
fateme_developer30-Jun-08 22:57
fateme_developer30-Jun-08 22:57 
GeneralRe: Refactoring the code or dessign? Pin
led mike1-Jul-08 4:38
led mike1-Jul-08 4:38 
AnswerRe: Refactoring the code or dessign? Pin
Scott Dorman30-Jun-08 23:30
professionalScott Dorman30-Jun-08 23:30 
GeneralRe: Refactoring the code or dessign? Pin
led mike1-Jul-08 4:41
led mike1-Jul-08 4:41 
GeneralRe: Refactoring the code or dessign? Pin
Scott Dorman1-Jul-08 6:20
professionalScott Dorman1-Jul-08 6:20 
GeneralRe: Refactoring the code or dessign? Pin
led mike1-Jul-08 7:28
led mike1-Jul-08 7:28 
GeneralRe: Refactoring the code or dessign? Pin
dojohansen22-Jul-08 23:00
dojohansen22-Jul-08 23:00 
It's not so strange. There are many cases where constructing unit tests would in itself represent a huge development effort, and I for one disagree that it is a necessarily a good idea to do so when about to embark on a refactoring.

The project I work on is a point in case. It is a web application and it isn't easy to unit test, among other reasons because intrinsic asp.net objects (request, response, session state, application state, httpserverutility) are used indiscriminately anywhere, so to make a unit test for some business class you need to make mocks of these, which you can't, because they are all sealed classes. Even if you could it would be quite a bit of extra work. And if your refactoring involves removing all these objects from your business logic you don't get any long-term benefit from doing all that work - once your tests are developed your refactoring then breaks them!

And that leads me to the more general observation: Refactoring isn't (usually) just about changing implementation details; it usually involves interface changes, decoupling of objects, and construction logic changes - perhaps introducing a factory somewhere. Most of these changes are of a nature that make them very likely to break any tests. So why do all the development effort to make a bunch of tests that you will immediately go about invalidating? In my view, far better to refactor and make tests for your *new* code as you go. In the end, if you had bugs that are still there after the refactoring there is no reason to think the refactoring itself would make them harder to fix afterwards, and if your refactoring introduced bugs that is no different to if you had made the unit tests for the "before refactoring" version of the application.

So I don't get it. What would be the great benefit of developing tests to know that some code you're about to change works, when those tests cannot be reused to test the code after the changes?
GeneralRe: Refactoring the code or dessign? Pin
led mike23-Jul-08 5:57
led mike23-Jul-08 5:57 
GeneralRe: Refactoring the code or dessign? Pin
dojohansen24-Jul-08 0:22
dojohansen24-Jul-08 0:22 
GeneralRe: Refactoring the code or dessign? Pin
led mike24-Jul-08 6:35
led mike24-Jul-08 6:35 
GeneralRe: Refactoring the code or dessign? Pin
Pete O'Hanlon24-Jul-08 8:45
mvePete O'Hanlon24-Jul-08 8:45 
GeneralRe: Refactoring the code or dessign? Pin
led mike24-Jul-08 8:58
led mike24-Jul-08 8:58 
GeneralRe: Refactoring the code or dessign? Pin
Pete O'Hanlon24-Jul-08 9:05
mvePete O'Hanlon24-Jul-08 9:05 
GeneralRe: Refactoring the code or dessign? Pin
led mike24-Jul-08 9:25
led mike24-Jul-08 9:25 
GeneralRe: Refactoring the code or dessign? Pin
Pete O'Hanlon24-Jul-08 9:42
mvePete O'Hanlon24-Jul-08 9:42 
GeneralRe: Refactoring the code or dessign? Pin
led mike24-Jul-08 10:18
led mike24-Jul-08 10:18 
GeneralRe: Refactoring the code or dessign? Pin
dojohansen25-Jul-08 2:04
dojohansen25-Jul-08 2:04 
GeneralRe: Refactoring the code or dessign? Pin
led mike25-Jul-08 4:46
led mike25-Jul-08 4:46 
GeneralRe: Refactoring the code or dessign? Pin
dojohansen25-Jul-08 4:53
dojohansen25-Jul-08 4:53 
GeneralRe: Refactoring the code or dessign? Pin
led mike25-Jul-08 5:18
led mike25-Jul-08 5:18 
GeneralException Handling in Desktop Application Pin
Brady Kelly25-Jun-08 2:54
Brady Kelly25-Jun-08 2:54 
GeneralRe: Exception Handling in Desktop Application Pin
Steven A. Lowe13-Sep-08 17:06
Steven A. Lowe13-Sep-08 17:06 
QuestionObject Composition Pin
Leslie Sanford24-Jun-08 17:27
Leslie Sanford24-Jun-08 17:27 
AnswerRe: Object Composition Pin
led mike25-Jun-08 4:30
led mike25-Jun-08 4:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.