News for hackers. Stuff that matters.
Re:Ask HN: Is TDD/BDD hampering your startup's agility? by mcantor on Saturday February 19, 2011 @10:23PM (#2240885)

    Refactoring breaks a lot of test cases (mostly with renaming variables).
This is a red flag to me. Your tests should not know or care what variable names are used by your code.

It sounds in general like you might not be doing TDD correctly. Your test cases shouldn't be slow to run, either. Are you actually hooking up with the database in your tests, or are you isolating them properly?

Re:Ask HN: Is TDD/BDD hampering your startup's agility? by MartinCron on Saturday February 19, 2011 @11:13PM (#2240981)
The other red flag: This is 2011, there are good automated refactoring tools out there that make renaming variables/methods/classes trivial.
Re:Ask HN: Is TDD/BDD hampering your startup's agility? by mcantor on Sunday February 20, 2011 @12:31AM (#2241136)
Yeah, there's one built into Vim!

    :bufdo %s/^R-w/new_name/gc
Re:Ask HN: Is TDD/BDD hampering your startup's agility? by billmcneale on Sunday February 20, 2011 @12:56AM (#2241169)
This is exactly the kind of action that leads to build breaks.

Don't do it, use a real IDE.

Re:Ask HN: Is TDD/BDD hampering your startup's agility? by dasil003 on Sunday February 20, 2011 @01:16AM (#2241198)
Unless you're using Smalltalk, then no, I'm not willing to use a watered down language for the simple ability to make variable renames bulletproof.
Re:Ask HN: Is TDD/BDD hampering your startup's agility? by joske2 on Sunday February 20, 2011 @02:48AM (#2241352)
There are other dynamic languages besides smalltalk that have a good IDE. Jetbrains provides IDEs with refactoring support for JavaScript, python, ruby, php and others.
Re:Ask HN: Is TDD/BDD hampering your startup's agility? by dasil003 on Sunday February 20, 2011 @10:25AM (#2242025)
not bulletproof refactoring though.
Re:Ask HN: Is TDD/BDD hampering your startup's agility? by IgorPartola on Sunday February 20, 2011 @09:47AM (#2241946)
Sorry but you are wrong. Every IDE I've seen is big, bloated and the useful features it provides are more cumbersome that sed, grep and find. OTOH vim is fast, universally available, and because of it's nature much faster to code in. I look at it this way: when you first switch to vim, you will be working WAY slower than in your favorite IDE. Take one hour to learn the basics. Then you will be just as fast. Then, anything new you learn is just going to give you that much more speed over your old way.

Also, in general, it doesn't matter what you program in: be it an IDE, vim, cat, or a magnetized needle. A good hacker finds a way to write good code.

Re:Ask HN: Is TDD/BDD hampering your startup's agility? by billmcneale on Sunday February 20, 2011 @04:56PM (#2243253)
If you are writing Java code in vim, I guarantee you that you will be faster and more productive with an IDE.

I can't believe you actually think that typing all these characters (imports, renaming by hand, creating methods by hand, etc..), navigating between classes, finding symbols is making you faster.

vim is great for general text editing, but for Java, nothing can beat an IDE. Try it, you'll be surprised.

Re:Ask HN: Is TDD/BDD hampering your startup's agility? by IgorPartola on Monday February 21, 2011 @01:27PM (#2246511)
Heh. True, I do most of my development in Python, PHP, JavaScript, and C. vim is all about saving you keystrokes though. NERDTree is for navigating files, and autocomplete plugins are abound.
Re:Ask HN: Is TDD/BDD hampering your startup's agility? by xiongchiamiov on Sunday February 20, 2011 @03:07AM (#2241379)
Refactoring support has nothing to do with IDEs. Nothing.

An IDE is, well, an integrated development environment - I find the idea of mashing my editor, VCS, build system, debugger, etc. into one tool to be incredibly distasteful.

What you want is a competent editor. Unfortunately, most editors that provide support for things like automated refactoring are bundled into IDEs, hence your confusion.

Re:Ask HN: Is TDD/BDD hampering your startup's agility? by billmcneale on Sunday February 20, 2011 @04:57PM (#2243256)
> Refactoring support has nothing to do with IDEs. Nothing.

Uh?

The strength of an IDE is that it understands your code. It knows what a method, a class, a variable, a package is. Because of that, it can give you more assistance in writing your code than any editor that bases its highlighting on regular expressions ever will.

Re:Ask HN: Is TDD/BDD hampering your startup's agility? by bdclimber14 on Sunday February 20, 2011 @02:50AM (#2241356)
I used the term variables to include a lot like attributes, and even some methods. If you are testing a model's attribute, then the test case definitely needs to know about it.

Technically, they are hooking up with the database since the attributes are automagically generated from the DB schema (using ActiveRecord on Rails). Maybe there's a better way? I'd love to know.

Re:Ask HN: Is TDD/BDD hampering your startup's agility? by ollysb on Sunday February 20, 2011 @03:59AM (#2241462)
I love developing in rails but let's be clear, refactoring ruby is just painful at the moment. Yesterday I decided to rename a model, it took over an hour to get the tests passing again. Ok there's rubymine but it's only partially effective, it misses things like renaming relationships and references in templates. Given the difficulty of static analysis I've been wondering if a refactoring tool might look a little different with a dynamic language. Given that refactorings are effectively replacement patterns perhaps a find/replace workflow tool would be the way to go. The workflow might go something like: specify broad regex which matches all potential changes. View matches and then partition them with further rules like file type and tighter regexes. Once you've grouped the matches provide appropriate replacements. Run tests. Refine if required. Obviously you could follow this workflow using command line tools but the refinement process is difficult because you don't retain any of the context. Having said that it wouldn't be too hard to use existing commands to put something like this together. Looks I've got a project for this afternoon.
Re:Ask HN: Is TDD/BDD hampering your startup's agility? by jasonkester on Sunday February 20, 2011 @06:49AM (#2241692)
That there is the big reason I can never convince myself to stick with a language like Ruby or Python. I do about one project a year in one or the other, and am always re-amazed at the lack of proper tools. It's a shame, because in other ways they're so good.

The refactor you mention is single right click in C# (with ReSharper, and without the frankly terrifying idea of using Regexes to do it). Compounding matters is the fact that a huge portion of your unit tests simply evaporate once you realize that you simply can't have typos or type mismatches in an old dinosaur language like C#. So it's entirely possible that that big suite of testcases it took so long to refactor would not be necessary at all (replaced instead by the occasional int x;).

Once somebody gets the tools together so I can be as productive in Rails as I am in ASP.NET, I'm jumping ship. Until then, I'm hanging tight.

Re:Ask HN: Is TDD/BDD hampering your startup's agility? by ollysb on Sunday February 20, 2011 @10:18AM (#2242005)
I'm a java refugee and used to make heavy use of the refactoring tools in eclipse. It's definitely something I miss from my old workflow. Given you're using BDD there isn't really anything to be concerned about when using regexes etc. to manipulate the code. I'd say that learning to use the command line better is essential if you move to a dynamic language. With regards to the test suites being larger due to type checking I think it's been fairly well established now that this isn't the case. Those types of errors are always shown up when testing other aspects of your code, I can't think of a single case where I've written tests that do any type checking. In the end I find that losing the refactoring assistance is a tradeoff that I'm happy to make in exchange for the increased expressivity and productivity I enjoy with rails.
Re:Ask HN: Is TDD/BDD hampering your startup's agility? by jasonkester on Sunday February 20, 2011 @11:22AM (#2242198)
You've piqued my curiosity. Why would a developer ever need to do anything (that affected his code) from the command line?
Re:Ask HN: Is TDD/BDD hampering your startup's agility? by ollysb on Sunday February 20, 2011 @11:43AM (#2242264)
Find and replace is probably the only time I use the command line to actually modify the code. I could use a text editor to do this but favour the power I get with the command line(using ack and sed). Using the command line isn't necessary to work with rails but it is favoured within the culture. Generally people use it for everything from running the server to checking code in and as mentioned, refactoring.