4 Comments

Like GPT, I could use a few more concrete examples for what _intralate_ looks like.

Expand full comment

Here's a before and after:

public static ArrayList<TaskDesc> descsByMonth(ArrayList<TaskDesc> descs, int month, int year) {

ArrayList<TaskDesc> filteredDescs = new ArrayList<>();

Calendar calendar = Calendar.getInstance();

for (TaskDesc desc : descs) {

calendar.setTime(desc.date);

int recordMonth = calendar.get(Calendar.MONTH);

int recordYear = calendar.get(Calendar.YEAR);

if (recordMonth == month && recordYear == year) {

filteredDescs.add(desc);

}

}

return filteredDescs;

}

Now the after:

import java.time.LocalDate;

import java.time.ZoneId;

import java.util.ArrayList;

import java.util.Date;

public static ArrayList<TaskDesc> descsByMonth(ArrayList<TaskDesc> descs, int month, int year) {

ArrayList<TaskDesc> filteredDescs = new ArrayList<>();

for (TaskDesc desc : descs) {

// Intralate Date to LocalDate

LocalDate recordDate = desc.date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();

int recordMonth = recordDate.getMonthValue(); // 1-based month

int recordYear = recordDate.getYear();

// Adjusting month for 1-based comparison

if (recordMonth == month + 1 && recordYear == year) {

filteredDescs.add(desc);

}

}

return filteredDescs;

}

I suppose I should post a chat.

Expand full comment

In addition to telling ChatGPT what Intralating is, you could also train it to know what smells such a refactor can fix. Then if you ask ChatGPT to look at your code and suggest refactorings, Intralate would be included as an option along with the existing Fowler & Feathers canon. :) I can even imagine a scenario where books like Refactoring, Working Effectively with Legacy Code, or Refactoring to Patterns would come with an access code for digital content you can dump into your ChatGPT session to train it in all the book's smells and fixes.

Expand full comment

This seems like it shares some characteristics with wrap parameter, and that the next step would be to extract method on the part that only uses the new type then inline the original method, kind of cool!

Of course what is really neat is seeing in what ways were can use GPT to remove drudgery and be more accurate.

Expand full comment