techhub.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A hub primarily for passionate technologists, but everyone is welcome

Administered by:

Server stats:

4.6K
active users

#refactoring

4 posts4 participants0 posts today
Continued thread

The ranged W command was great to perform a Move Method #refactoring to another class.

W appends a selected block from the current file to another file. Then you can edit the other file and move the appended block to its correct position with the m command. A few substitutions later, and the Move Method was done without leaving ed.

Continued thread

It's going well so far:

*!git log --oneline | cut -d' ' -f2- | tac
Starting point
Simplify for loop
Invert the first if
Split first if
Invert if on sulfuras
Permute ifs for sulfuras
Join first 'if else's

I think I can now say it's totally doable and even worth repeating this kata a few times.

Continued thread

Example of scope, I currently want to invert the condition on the name here:

*34,40n
34 } else {
35 if (item.quality > 0) {
36 if (!item.name.equals("Sulfuras, Hand of Ragnaros")) {
37 item.quality = item.quality - 1;
38 }
39 }
40 }

This is fine if I do one thing at a time.

Also: ed edits could be a great format for #refactoring toots 🤔

Totally random thought: would I be able to do the Gilded Rose kata using only the ed text editor in a reasonable time?

Goals:
1) have fun,
2) look like a fool,
3) learn enough ed to later be able to script complex text changes across files,
4) also level up in sed and vim

Reason: ed(1) is the standard Unix text editor.

Well, another one bites the dust... Code Climate is shutting down and their new replacement service (only upgrade option) with the fascinating strapline "Code With Vibes, Merge With Confidence" does inspire anything but... 🙄

(Been using CC for years and even though it produced a lot of false positives, it generally was a very useful tool which sent me off on several major refactoring journeys over the years, from which not only I benefited as a maintainer, but all users of my libraries/tools did too... c'est la vie...)