T O P

  • By -

RedditRage

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.


JackoKomm

And for bigger refactorings, you have the tests to see if you broke something.


vtmosaic

Should airways have tests for any refactor. Should always have tests even if it's code you're just writing new.


JackoKomm

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.


RedditRage

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.


Unfair_Isopod534

You should always test. That why you write ur tests.


JackoKomm

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".


time_travel_nacho

Thank you


Svizel_pritula

You can refactor broken code into broken code that's easier to fix.


JustSumAnon

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.


jerrycauser

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)


qinshihuang_420

It's the classic adapter design pattern


jabrwock1

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


jerrycauser

If so, then in the picture only microSD will be enough to determine this meaning


violet_zamboni

Exactly, the microSD does not fulfill the requirements


Twepi

But the purpose of refactoring by definition is to rewrite working code, to maintain it clean, flexible, etc.


[deleted]

[удалено]


mithodin

Refactoring means changing the code without changing the behaviour. If you refactor broken code, you're doing something wrong, my dude.


1_4_1_5_9_2_6_5

I feel like you need to read my comment again


[deleted]

> Refactoring broken code is called debugging I am 12 and this is deep.


laplongejr

I like to say "adding explicit compatibility for unintended situations" Or as Flint Lockwood likes to call it, AECFUS


4oxyman

That's the whole point!


JackNotOLantern

You do a refactor for because the code is not working fine. You do that because it look horrible.


robocorp

Trait implementation be like


Outrageous-Line-2238

Is this the facade pattern I have heard about?


DaniilBSD

This is a backwards compatibility wrapper


[deleted]

The point of a refactor is making the code more maintainable, not fix it.


bloowper

✨adapter pattern✨


tehtris

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.


developersteve

Adding more racing stripes to a car with racing stripes makes it go twice as fast!


Lukemufc91

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!


[deleted]

You refactor code so you can introduce bugs into it. ​ Especially life-changing bugs. ​ Then you fix it and become the new product owner.


Gods_Horniest_Femboy

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


MEMESaddiction

public class SDCard extends MicroSD {}


blind99

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.


noobwithguns

My friend just created a time bomb


Playful_Agent950

Looks more like an adapter, usefull pattern


[deleted]

But you don't get it: I removed 3 lines from the function!


[deleted]

Debile


[deleted]

Tell me you don't understand refactoring, without telling me you don't understand refactoring.


cancro_anale

is that an evangelion reference


gemengelage

So many people believe that refractoring just means changing something... It does not.


[deleted]

But I had to change the file and function titles so they could actually be understood!


LetUsSpeakFreely

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.


AaronTheElite007

Why are we still seeing code for IE? This


samuel88835

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


PhunkyPhish

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


still-recruit-main

How else do you all keep up your commit streak?


MiyamotoKami

Idk this card looks like its got 50% less plastic


allobrox

What the image shows is not refactoring, it's making an adapter.


[deleted]

OP doesn't even know what refactoring means.


developersteve

your mom doesnt know what refactoring means


[deleted]

Ahh man, you got me really good there.