News for hackers. Stuff that matters.
Re:A Short Cautionary Tale About Refactoring by taberiand on Sunday March 21, 2021 @12:44AM (#26528181)
A good example of why the fundamental rule of refactoring is don't change behaviour (such as taking a dependency on a http request where there wasn't one before)
Re:A Short Cautionary Tale About Refactoring by alkonaut on Sunday March 21, 2021 @04:12AM (#26528897)
The author didn’t consider that a changed behavior - the inlined image already had a dependency on http to be downloaded in the first place. No, this is all on the original author.
Re:A Short Cautionary Tale About Refactoring by taberiand on Sunday March 21, 2021 @05:21AM (#26529186)
I argue that the inline image had no such dependency, as it was an internal component of the control and could just as easily be used in a non-http context. By loading the image through a http request, the image component is effectively being injected with the http service in order to operate.

The correct refactoring is one the author fuelled with coffee, which is naturally the real lesson here.

Re:A Short Cautionary Tale About Refactoring by jacquesm on Sunday March 21, 2021 @06:39AM (#26529470)
Precisely that.

This isn't refactoring per-se it is focusing on the cosmetics of the code at the expense of functionality. There are many other reasons why an inlined image may have been appropriate and the author overruled all possible concerns by going for replacing a large block of 'ugly red' by a smaller block 'pretty green', which is a very bad reason to make a change in functionality, especially without understanding what is going on.

Re:A Short Cautionary Tale About Refactoring by sqldba on Sunday March 21, 2021 @03:21AM (#26528706)
The problem is noticing that you are changing a behaviour.
Re:A Short Cautionary Tale About Refactoring by faeyanpiraat on Sunday March 21, 2021 @03:47AM (#26528820)
Automated tests to the rescue
Re:A Short Cautionary Tale About Refactoring by TeMPOraL on Sunday March 21, 2021 @06:17AM (#26529390)
The problem is noticing that something is a behavior that needs to be tested.