Langsung ke konten
Skillpedia
Pemrograman umum40k · #7259

java-refactoring-remove-parameter

Fungsinya

Tool ini membantu merapikan kode Java dengan menghapus informasi yang tidak perlu dan dikirim ke dalam fungsi. Hal ini membuat kode lebih mudah dipahami dan digunakan.

Kapan dipakai

  • ✓Saat sebuah fungsi menerima data yang tidak dipakainya.
  • ✓Untuk menyederhanakan fungsi yang memiliki terlalu banyak argumen.
  • ✓Saat merapikan kode agar lebih jelas.

Link skill

https://github.com/github/awesome-copilot/blob/main/skills/java-refactoring-remove-parameter/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/github/awesome-copilot/blob/main/skills/java-refactoring-remove-parameter/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit →

Contoh permintaan ke AI

“Hapus parameter 'isCloud' dari fungsi 'selectBackendForGroupCommit' karena tidak digunakan.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

AI menganalisis fungsi-fungsi Java Anda untuk menemukan parameter yang tidak digunakan. Setelah itu, AI menghapus parameter tersebut dan memperbarui kode agar tetap berjalan dengan benar, tetapi dengan cara yang lebih rapi.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Refactoring Java Methods with Remove Parameter

Role

You are an expert in refactoring Java methods.

Below are 2 examples (with titles code before and code after refactoring) that represents Remove Parameter.

Code Before Refactoring 1:

public Backend selectBackendForGroupCommit(long tableId, ConnectContext context, boolean isCloud)
        throws LoadException, DdlException {
    if (!Env.getCurrentEnv().isMaster()) {
        try {
            long backendId = new MasterOpExecutor(context)
                    .getGroupCommitLoadBeId(tableId, context.getCloudCluster(), isCloud);
            return Env.getCurrentSystemInfo().getBackend(backendId);
        } catch (Exception e) {
            throw new LoadException(e.getMessage());
        }
    } else {
        return Env.getCurrentSystemInfo()
                .getBackend(selectBackendForGroupCommitInternal(tableId, context.getCloudCluster(), isCloud));
    }
}

Code After Refactoring 1:

public Backend selectBackendForGroupCommit(long tableId, ConnectContext context)
        throws LoadException, DdlException {
    if (!Env.getCurrentEnv().isMaster()) {
        try {
            long backendId = new MasterOpExecutor(context)
                    .getGroupCommitLoadBeId(tableId, context.getCloudCluster());
            return Env.getCurrentSystemInfo().getBackend(backendId);
        } catch (Exception e) {
            throw new LoadException(e.getMessage());
        }
    } else {
        return Env.getCurrentSystemInfo()
                .getBackend(selectBackendForGroupCommitInternal(tableId, context.getCloudCluster()));
    }
}

Code Before Refactoring 2:

NodeImpl( long id, long firstRel, long firstProp )
{
     this( id, false );
}

Code After Refactoring 2:

NodeImpl( long id)
{
     this( id, false );
}

Task

Apply Remove Parameter to improve readability, testability, maintainability, reusability, modularity, cohesion, low coupling, and consistency.

Always return a complete and compilable method (Java 17).

Perform intermediate steps internally:

  • First, analyze each method and identify parameters that are unused or redundant (i.e., values that can be obtained from class fields, constants, or other method calls).
  • For each qualifying method, remove the unnecessary parameters from its definition and from all its internal calls.
  • Ensure that the method continues to function correctly after parameter removal.
  • Output only the refactored code inside a single java block.
  • Do not remove any functionality from the original method.
  • Include a one-line comment above each modified method indicating which parameter was removed and why.

Code to be Refactored:

Now, assess all methods with unused parameters and refactor them using Remove Parameter

Pertanyaan umum

Mengapa menghapus parameter membuat kode lebih baik?

Menghapus parameter yang tidak perlu membuat kode lebih mudah dibaca, dipahami, dan diuji, karena informasi yang harus dikelola jadi lebih sedikit.

Apakah kode tetap berjalan setelah perubahan?

Ya, tujuannya hanya menghapus bagian yang tidak digunakan, sehingga fungsionalitasnya tetap sama.

Apakah ini memengaruhi bagian lain dari program saya?

Jika fungsi yang diubah dipanggil di tempat lain, AI juga akan menyesuaikan pemanggilan tersebut agar semuanya tetap berjalan bersama.

Detail

Deskripsi asli dari pembuat

Refactoring using Remove Parameter in Java Language

repo: github/awesome-copilot

Popularitas

Bintang GitHub
40k
Peringkat
#7259
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa