9

What I absolutely love to do is refactoring. With strongly typed languages, I often just remove or change something and then follow the compiler errors to finish the refactoring by fixing them.
It‘s not just a matter of renaming something. I will reliably get all the places in code which are affected by the change.

How do you handle that with weakly typed languages like JS? I can only imagine how horrible of an experience refactoring would be.

Comments
  • 2
    In weakly typed languages like JS I switch to TypeScript instead. And if that's not possible then, well, hope the change isn't too comprehensive and then run a lot of tests hoping you don't get "can't access xyz of undefined" or something like that.

    Maybe I'm overlooking something but I don't get it either. Good typing is just such a big help.
  • 3
    does not always work for retarded reflection or when you work with string literals instead of property names eg.

    refactoring is great but there are traps - even in strongly typed languages
  • 3
    That’s not even really refactoring as I see it, more like restructuring. Refactoring is a process encompassing a series of structured well defined small steps where the code is at no point in time at a broken state. If you get errors at any point, you are doing it wrong.

    If you do refactoring right, it should be really manageable and non-threatening regardless of language.
  • 0
  • 0
    @craig939393 not really, because the kind of changes that I am talking about would also require changes in the test code to adopt to the new requirements.
    And, without a strict type system, you would need to make these changes very cautiously.
    Tdd is not a solution here. It is a further victim of weak typing.
  • 1
    @Lensflare 1101100 or w/e comment about true refactoring relies on tests is what I meant

    And strong types don't replace tests btw
  • 1
    @craig939393 ah ok. I agree.

    Also, tests don‘t replace strong types :)
Add Comment