Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"you can't refactor because your refactor just broke some code somewhere" - picking a language that is not matched with first-class automated refactoring (ReSharper, IDEA) was their first mistake (rather than lack of unit testing).


You couldn't rename things because they used AspectJ to bind certain method names to some validation methods. Of course this was well documented on a dark side of planet orbiting Andromeda.

Also the Javascript used #id an suffixes to call JSP fragments. You change the name of the div in that JSP fragment and you have to change any mention of it in any JS or Java files.


Renaming stuff and pushing variables around is not refactoring. It's just some editing work.


IDE refactoring is glorified grep/sed.

On the other hand an expressive static type system (with emphasis on expressive, because Java's type system doesn't qualify) can save you from countless of accidental bugs happening - and a single bug that's caught by the compiler is a bug that won't reach production.

Plus, static typing approaches the problem from a different perspective than unit testing. Through testing we try to prove that a piece of code conforms to the business logic that is being solved and to guard ourselves against regressions. A static type system on the other hand actually proves that your code has certain characteristics - for example depending on the language we are talking about, it can prove that you won't get any null pointer exceptions, or it can prove that the interface of this component is still the one expected by this other component, etc... for example I have a component modeled as a fairly complex FSM and I fixed a difficult non-deterministic bug by eliminating the possibility of it happening through the type-system - it was quite the eye opener.

Static typing doesn't negate the need for testing of course since they serve a different purpose, but if you find yourself writing tests for things that a compiler could prove, then you probably picked the wrong language.


You'd be surprised what transformation modern IDEs can do that IS refactoring, not just renaming and pushing variables around.

Plus, you're wrong: a lot of refactoring is also about renaming stuff and pushing variables around. You don't always have to rewrite everything in new hierarchies and patterns in order to do a refactor.


Renaming, pushing variables, changing their types, stuff like that. It's still editing work. Can any IDE split the class into two according to methods' responsibilities? Can it abstract a set of functions to a single generic function? Can it get rid of unnecessary boilerplate code scattered around in various classes? Can it change data structures used to store data?

Because refactoring is about making the code simpler and more flexible. Rearranging that IDEs do is only a method (and not the only one) to achieve that.


Anyone who doubts this should watch Jim Weirich's talk "Adventures in Functional Programming" - the last (and most mind-blowing) quarter of the talk is almost entirely made up of automatic refactoring.

[1] http://vimeo.com/45140590





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: