last day (26 days later) » 

14:43
So I was speaking to a manager today who said that refactoring is evil and you should never do it because it introduces more bugs :D
Not my manager thankfully
Managers are evil, refactoring isn't.
6
@DanPantry facepalm
He said this because an airplane controls ystem (or something) didnt' allow refactoring at all
that he worked on.. or his company worked on
Why would it be bad?
Because it can introduce bugs
Which is true, it can
But so can, you know, writing any code
14:44
High-profile stuff has it's own rules, it's where legacy code is holy.
But if a manager for a regular company would spout stuff like that, I'd leave.
Don't break stuff if it ain't fixed
Refactoring may also uncover old bugs
I can understand that there's no reason to refactor if things are working as intended and barely require any maintenance
@Mast It's a company that is a consultancy for the program we ar working on right now
Said code has plenty of italian-dish-style code
@IsmaelMiguel Not in those circles, they usually test very thoroughly.
14:45
It's mostly that bad code + maintenance results in a hell
And zero unit tests
@Mast I guess Dan proved you wrong, a bit
And I said "why dont' we refactor this?"
"refactoring is evil, you will just introduce more bugs"
You mean, you want me not to refactor and to copy-paste this url everywhere?
You can't introduce bugs if you write adequate automated tests.
And then when we have to change it, copy paste it all over again?
because that won't introduce bugs, right?
his response was, I shit you not
14:46
@IsmaelMiguel If you don't refactor AND don't unit test, you're creating a disaster.
"That's what find and replace is for"
3
@nhgrif You can't introduce bugs if you write adequate code
@jacwah false
Yes you can, @jacwah
every code has bugs in it
14:47
@jacwah Very, very false.
You should always assume your code has a bug in it
s/a bug/bugs/
I mean, you can have bugs in your unit tests too
Yes, you can, @jacwah
My bugs have plenty of code.
2
14:47
If you can't find a bug, you are doing it wrong
However, if you have bugs in your unit tests
@jacwah Yes, but then you need to have an overlapping bug in two systems
@DanPantry That... I don't even
Then your unit tests are too complex
@jacwah I think I just spotted another padawan, like me! :D
14:48
That's far more unlikely than one bug you didn't find because you didn't have a test
@DanPantry I heard you like unit-testing, so I wrote a unit-test to test your unit-tests so you can unit-test while you unit-test.
2
@Mast Oh, I do that.
Most people tend to think that "test code" is just "test", they tend to forget that it's also "code"
I write tests for my testing framework as well
What I'm saying is that you can never be sure there are no bugs, even if you have tests
Something that's fun is spending days debugging a script only to find it was the trigger script that had the bug.
And honestly, eschewing unit tests because "you might wrong your unit tests wrong" makes no sense. If you're writing bugs with that frequency you shouldn't be writing production code in the first place.
14:49
But in the end, your unit tests should boil down to such clear statements it's hard to introduce a bug in it.
@jacwah unit tests do not prove the absence of a bug
but neither does manual testing
For example, if I test DOM in JavaScript I have a few base functions I always use
@DanPantry That's what I'm saying
and unit testing is a hell of a lot faster and cheaper to do and less error prone than manual testing
Those functions must be trusted, so I test them as well
So yeah, testing your test code is a good thing
Eventually, you can't really be 100% sure
But 99% is a whole lot better than 0.
14:50
The point being that of course you can introduce bugs when refactoring with tests
TLDR though, manager says refactoring is bad because it introduces bugs, his developers don't know how to unit test
@jacwah Again, though, your integration tests should catch any bugs that affect existing functionality
@jacwah Of course you can, but you are almost sure to introduce bugs when refactoring without tests.
@jacwah There are ways to ensure that you have no bugs
Even though it's less likely
When something breaks, two tests should fail.
One unit test, and one integration test.
14:51
Any regressions can be caught by the tests you have written
@skiwi How?
That's why tests are awesome
@jacwah Formal verification
I use unit tests to only cover defined behavior.
If a test doesn't break and you still have a bug, then you write a test, fix the bug, and there you go - You'll never find that bug again
@DanPantry That is something a lot of companies don't seem to understand
@skiwi Well, to be fair, it's not always that simple.
Sometimes, manual testing > automated testing
There are structural and architectural things to consider more often than not.
@JohnSnow Why not both?
But there are occasions when bugs recur like 5 times in new patches
14:52
What's stopping you from testing things manually, but then also writing automated tests so that you don't have to do the same manual testing over and over again?
@JohnSnow that's when you should think over your architecture
You know that tool that does repetitive and annoying tasks very efficiently, very quickly and without complaining?
@MadaraUchiha well, in the cases where manual testing > automated testing, the automated testing already run and failed to find the bug :P
Yeah, it's called a Computer, let it do its work for you :P
@JohnSnow Then you need to improve your automated test code.
@JohnSnow That's when you find the bug, replicate the steps you took in code, and then fix the bug
14:53
@Vogel612 Probably,still doesn't change the fact that sometimes, you have to do manual tests because the automated ones can't catch it.
If the bug ever appears again, your test will show it
@MadaraUchiha Undefined behavior should default to a certain state though. Try to catch as much as you can.
you should never be writign a program monolithic enough (or badly enough) that you can't test it with automation
@Mast undefined behavior = nasal demons
I don't care, and neither should you.
@JohnSnow true, but strong indicator you should refactor
14:54
(key word: should, obviously, you do have to do this sometime)
If it defaults to a certain behavior, it was defined.
@Vogel612 Agreed
@JohnSnow The only "bugs" an automated test cannot find, is structural problems
I recently wrote a server. Whatever happens, if it's not defined it should still not hang-up the server.
When in doubt, the connection gets severed.
"This layer leaks abstraction, and cause weirdness with global state"
An automated test can't catch that bug, and even a manual test will take a skilled developer to
14:55
I'm agreeing with you
But that's not a bug that should happen
You make it seem like I said manual testing is ALWAYS better than automated
If that's the bug you're having, you may need to make super extensive refactors and maybe even a rewrite.
@JohnSnow On the contrary
I claim that automated tests are nearly always better than manual ones
No one said that, @JohnSnow. However, manual testing should never be the only testing you do, and automated testing is almost better in every single aspect to manual testing
Manual testing is great for sanity checks
14:57
@DanPantry Agreed
Not much more
automating testing will follow instructions as you wrote them 100x in a row without making a mistake and will do it in milliseconds
The only way an automated test will ever be wrong is if you gave it the wrong instructions
But hey, you can do that to a human, and a human may just execute them wrong as well :P
I had a function whose input consisted of any of the 127 characters in the standard ASCII first half
1
Q: Standard deviation of hourly temperatures of 2 days

CodyIt seems that when I program in lisp my brain goes on auto pilot and I end up solving the problem somehow. I don't even think I just do and it works out. That said this is some horrible lisp code that was hacked together in about 20mins just to see if I could do it. The c++ program that this is...

@DanPantry Unless you sleep for multithreaded code
14:58
To test it manually, you'd have to sit and insert character by character, whereas in an automated test, I just wrote a for loop :P
@skiwi Why the hell are you using sleep()? :P
When would manual tests be OK? For a sanity check to make sure that you don't have stupid errors
You check for one or two characters and move on
@DanPantry Well, I'm not, but it's a proven way (tm) to write broken test code that does not validate broken code
@Madara or for UX reasons in terms of web dev
But the actual test, the one that fails the build, is automated
14:59
@skiwi If you show anyone a test that uses sleep, they will immediately say "Why teh hell are you using sleep()". Then you have the peer test failing :P
@DanPantry Well, those cannot really be quantified in the form of "pass" or "fail"
@MadaraUchiha No, but you can write perfectly good automated tests in selenium that look like rubbish in the browser
That's basically the only manual tests I do in my own projects

  last day (26 days later) »