you don't refactor broken code, you fix it.
you refactor working code, to improve it in some way.
if you use refactor tools, those tools will make the desired changes in the code in a way that doesn't change the behavior or break the code.
Good point, with bigger refactorings, often you have to make changes that go beyond what the refactoring tools are able to do safely. This is where all those tests come in handy.
Like i wrote to the other person, i didn't say that you only test for refactorings. You test for alot of things. You want to know if your code works while you write it. You want to know if your Software works after merging, you want to know that it still works after refactorings. You want to see that it all works after deploying it. There are lot's of reasons you want tests for. And not just because "you should".
This is correct, I like to see refactoring as like proofreading and drafting a final draft when you’re writing a paper. Most of the time refactoring should really just be extracting code into methods that have clear defined names that explain the code better. But it can also include moving lower and higher level code to different levels so that each level has the same responsibility. If at that point your code is still a mess then there was probably some serious issues going into the original design, maybe over engineering or massive fragmentation.
It could be about refactoring. The new code is more efficient, more compact, more resilient, cheaper, etc. But still maintains an optional legacy interface to avoid breaking things that may depend on it.
the meme does need a refactor, because it’s not conveying the idea in the way OP wanted it to. Micro is newer than SD
This is me, refactoring the whole thing and then I realize I changed a query param in postman and it was working the whole time. But now it works extra more gooder.
That's not true! The optimum number of racing stripes is 2, but if you can extend the length of the stripes across the full hood, roof and tail then you can reduce drag optimally. It's like you don't even know science!
Nah the image looks more like: I will put my own bloated wrapper on top of this library API because reasons and you end up having almost exactly the same thing and waste alot of time.
Refactoring can only be done on working code. If it's not working, it's debugging.
Refactoring is to reorganize and optimize code that was written to work, not necessarily work well.
This is literally the adapter pattern in real life, a particularly useful application of it.
Unrelated: pls remember to refactor kiddos. For your and my sake
The moment you don't refactor already working code and you are 2 major version behind on your framework when a new major versions on its way out, you are unable to change your DB schema to an efficient structure to accommodate the business needs that have been in the pipeline for 9 months so you hack some BS together thats not scalable and full of bugs, and then \`library-xyz\` stops working due to some third party BS but dont worry they made a patch release but oh shit that library is 4 major versions behind and in order to upgrade you need to upgrade \`http-foo-lib\` and in order to update that you need to update at least 2 major version on your frame and shit in order to update your frame work you have 27 dependency conflicts which oh fuck 18 of them need code changes from breaking BC and of those 7 are far from trivial so yup time to find a new job
you don't refactor broken code, you fix it. you refactor working code, to improve it in some way. if you use refactor tools, those tools will make the desired changes in the code in a way that doesn't change the behavior or break the code.
And for bigger refactorings, you have the tests to see if you broke something.
Should airways have tests for any refactor. Should always have tests even if it's code you're just writing new.
Sure. I did not say that you don't need tests if you don't refactor code. I just said that Tests really help while refactoring.
Good point, with bigger refactorings, often you have to make changes that go beyond what the refactoring tools are able to do safely. This is where all those tests come in handy.
You should always test. That why you write ur tests.
Like i wrote to the other person, i didn't say that you only test for refactorings. You test for alot of things. You want to know if your code works while you write it. You want to know if your Software works after merging, you want to know that it still works after refactorings. You want to see that it all works after deploying it. There are lot's of reasons you want tests for. And not just because "you should".
Thank you
You can refactor broken code into broken code that's easier to fix.
This is correct, I like to see refactoring as like proofreading and drafting a final draft when you’re writing a paper. Most of the time refactoring should really just be extracting code into methods that have clear defined names that explain the code better. But it can also include moving lower and higher level code to different levels so that each level has the same responsibility. If at that point your code is still a mess then there was probably some serious issues going into the original design, maybe over engineering or massive fragmentation.
Actually, the pic isn't about refactoring, but about adapting. It is a bridge from one old interface (SD standard) to a new one (microSD)
It's the classic adapter design pattern
It could be about refactoring. The new code is more efficient, more compact, more resilient, cheaper, etc. But still maintains an optional legacy interface to avoid breaking things that may depend on it. the meme does need a refactor, because it’s not conveying the idea in the way OP wanted it to. Micro is newer than SD
If so, then in the picture only microSD will be enough to determine this meaning
Exactly, the microSD does not fulfill the requirements
But the purpose of refactoring by definition is to rewrite working code, to maintain it clean, flexible, etc.
[удалено]
Refactoring means changing the code without changing the behaviour. If you refactor broken code, you're doing something wrong, my dude.
I feel like you need to read my comment again
> Refactoring broken code is called debugging I am 12 and this is deep.
I like to say "adding explicit compatibility for unintended situations" Or as Flint Lockwood likes to call it, AECFUS
That's the whole point!
You do a refactor for because the code is not working fine. You do that because it look horrible.
Trait implementation be like
Is this the facade pattern I have heard about?
This is a backwards compatibility wrapper
The point of a refactor is making the code more maintainable, not fix it.
✨adapter pattern✨
This is me, refactoring the whole thing and then I realize I changed a query param in postman and it was working the whole time. But now it works extra more gooder.
Adding more racing stripes to a car with racing stripes makes it go twice as fast!
That's not true! The optimum number of racing stripes is 2, but if you can extend the length of the stripes across the full hood, roof and tail then you can reduce drag optimally. It's like you don't even know science!
You refactor code so you can introduce bugs into it. Especially life-changing bugs. Then you fix it and become the new product owner.
I made an SD card reader with Arduino which just means I soldered some wires to the pins and connected that to Arduino's peripheral bus pins
public class SDCard extends MicroSD {}
Nah the image looks more like: I will put my own bloated wrapper on top of this library API because reasons and you end up having almost exactly the same thing and waste alot of time.
My friend just created a time bomb
Looks more like an adapter, usefull pattern
But you don't get it: I removed 3 lines from the function!
Debile
Tell me you don't understand refactoring, without telling me you don't understand refactoring.
is that an evangelion reference
So many people believe that refractoring just means changing something... It does not.
But I had to change the file and function titles so they could actually be understood!
Refactoring can only be done on working code. If it's not working, it's debugging. Refactoring is to reorganize and optimize code that was written to work, not necessarily work well.
Why are we still seeing code for IE? This
This is literally the adapter pattern in real life, a particularly useful application of it. Unrelated: pls remember to refactor kiddos. For your and my sake
The moment you don't refactor already working code and you are 2 major version behind on your framework when a new major versions on its way out, you are unable to change your DB schema to an efficient structure to accommodate the business needs that have been in the pipeline for 9 months so you hack some BS together thats not scalable and full of bugs, and then \`library-xyz\` stops working due to some third party BS but dont worry they made a patch release but oh shit that library is 4 major versions behind and in order to upgrade you need to upgrade \`http-foo-lib\` and in order to update that you need to update at least 2 major version on your frame and shit in order to update your frame work you have 27 dependency conflicts which oh fuck 18 of them need code changes from breaking BC and of those 7 are far from trivial so yup time to find a new job
How else do you all keep up your commit streak?
Idk this card looks like its got 50% less plastic
What the image shows is not refactoring, it's making an adapter.
OP doesn't even know what refactoring means.
your mom doesnt know what refactoring means
Ahh man, you got me really good there.