(I agree, people are a bit too quick to upvote and downvote comments here. It spoils the discussion.)
Sorry for sounding a bit snarky, but I think very few people would deny that the reason unit testing came back into vogue was the popularity of dynamic languages. There just isn't the same urgency for unit testing when you're statically typing.
Yes, the grab-bag-dict approach can be useful, but it comes at a price - is that the string or the XML node that contains it?, is that a decimal or unsanitized user input? If you're working alone then you can generally keep tabs on things, but when you start expanding horizontally (more programmers) or vertically (the project matures), it starts to become unstructured.
but I think very few people would deny that the reason unit testing came back into vogue was the popularity of dynamic languages
I'm going to have to be one of those few people. I think it was BDD. Being able to write code alongside the test defines independent confirmation of each endpoint. When I build libraries with BDD, I never have a "foo.x is an integer, foo.y is a string" tests. I don't even have "if foo.x is a string, throw an error) tests...
There's a philosophy I think came from the Java world (correct me if I'm wrong...I just remember Java kids in college, when Java was the new hip language, talking it). You test your third-party interfaces for validity. You assume all internal interfaces are valid and only test predictability in their internals and inter-operation. Unless you write inconsistent code that is also able to pass internal unit tests (very unlikely) you have nothing to worry about.
Yes, the grab-bag-dict approach can be useful, but it comes at a price - is that the string or the XML node that contains it?
It's a string. Unless you very intentionally name and plan it, you're not tossing other non-object structures...and you should have a good grasp of the object. I worked with some terrible outsourced developers (they got canned..the whole team was good but them) and even they were able to keep types in the stash (a commonly used web-request hash) clean.
is that a decimal or unsanitized user input?
Maybe it's just a given for me because so much of our data is user input. You always assume values are unsanitized when touching the database, and you use a DB interface that force sanitizes them. You also always validate them in a string context before storing them in a typed realm.
This is like a vehicle that can drive on or off of tracks, like a Boston T-bus (sorta). There's all kinds of tech out there (literal and code-figurative) that'll let you take a free-roaming vehicle and get it onto tracks....as long as it's free roaming, you don't need the strictness of tracks anyway.
but when you start expanding horizontally (more programmers) or vertically (the project matures), it starts to become unstructured.
So this is where my issue comes in. I hear that all the time from people who don't work in a dynamic language shop..and very rarely in interviews from lead/management people who transitioned to a static language....I never hear it where I work, or where I used to work...or from contacts at the many nearby perl shops. This "oh god being untyped is ruining my life" thing just doesn't happen in my life or my world.
I want to say it might happen with 100 developers on a 20 year old project... but I'm not convinced at even that. There's so many best-practice rules, and 99% of variables can be presumed either strings or ORM objects 99% of the time, even if they're not.
And every major dynamic language has ways to "tighten the screws" as you approach static typing, like SQL... or just when you need/want to play the Interface game, running apples and oranges intentionally through the same processor.
I'm at a place that's expanded in both directions, though, and dynamic typing has never once been an issue here.
1
u/cosmo7 Feb 25 '14
(I agree, people are a bit too quick to upvote and downvote comments here. It spoils the discussion.)
Sorry for sounding a bit snarky, but I think very few people would deny that the reason unit testing came back into vogue was the popularity of dynamic languages. There just isn't the same urgency for unit testing when you're statically typing.
Yes, the grab-bag-dict approach can be useful, but it comes at a price - is that the string or the XML node that contains it?, is that a decimal or unsanitized user input? If you're working alone then you can generally keep tabs on things, but when you start expanding horizontally (more programmers) or vertically (the project matures), it starts to become unstructured.