プログラミング「ChatGPT にコーディングを依頼するだけ」は嘘?

こんな記事がありました。

👉 Jay Little - Software Obsessionist - Low Code Software Development Is A Lie hatena-bookmark

Sometimes a client falls into the trap of believing that there is some kind of silver bullet they can employ which will negate the inherent complexity around coding custom solutions. Nowadays the most cliche form of this is to say, "Well I'll just ask ChatGPT to code that for me". I call bullshit. While ChatGPT can handle some simple coding tasks, anything beyond that causes it to rapidly devolve into an unmanageable mess.

「コーディングの複雑さを解消する特効薬がある」という言葉を信じて罠に陥ることがあります。最近のこの決まり文句は「ChatGPT にコーディングを依頼するだけ」というものです。 私はデタラメだと思います。ChatGPT はいくつかの単純なコーディングタスクを処理できますが、その後急に、管理不能な混乱に陥ります。

Beyond the in vogue AI Chatbot example, there are a wide variety of other snake oil tools lingering about. All of them sell prospective buyers on the premise of allowing them to cut through the cruft and quickly pump out custom software without going through the years of training that professional Software Developers tend to go through. The most relevant example of this syndrome are so-called low code tools. As it so happens, I work with one of these at my current job.

流行りのAIチャットボットの他にも、様々なゴミツールが出回っています。これらはすべて、プロのソフトウェア開発者が経験するような長年のトレーニングを受けることなく、厄介なものを切り捨て、好みのソフトウェアを素早く作り出せるという前提で、購入希望者に売り込んでいます。この問題の最もよく見られる例は、いわゆるローコードツールです。たまたま、私は現在の職場でこのうちの1つを使用しています。

This low-code tool is called ***** and my review of it is that its a steaming pile of shit. I won't go into the technical specifics of why as that probably deserves it's own post. While it has enabled some non-developers to produce custom logic and screens, it hasn't actually removed the inherent complexity around designing proper data structures, writing fault tolerant software and validating the quality of the resulting software. Because a lot of the coders in question don't have this expertise, the end result is a custom software system that is poorly thought through, is brittle and as a result will require constant fire fighting on the part of the future members of the team in an effort to keep it functional.

このローコードツールは ***** というもので、私がみたところ、とんでもないクソの山です。その理由についての技術的な詳細については、ここでは触れません。非開発者でもロジックや画面を作成できるようになりましたが、適切なデータ構造の設計、耐障害性のあるソフトウェアの作成、出来上がったソフトウェアの品質の検証など、固有の複雑さを取り除くことはできません。多くのコーダーはこのような専門知識を持ち合わせていないため、最終的にソフトウェアは、十分に考え抜かれておらず、脆弱で、その結果、機能を維持するために未来のチームメンバーによる絶え間ない消火活動が必要となります。

I haven't even mentioned the best part: Tools like this aren't cheap and they tend to structure their licenses / billing so that you end up paying for as long as you use the software you produce with the tool. On top of which, all of these tools seem to involve accepting some level of vendor lock-in. So the more time you put into tools like these, the tighter their grip on your proverbial balls becomes.

一番大事なことは、このようなツールは安くはなく、ツールで作成したソフトウェアを使用する限り、最終的には、支払いが発生するような ライセンス/請求 の仕組みとなっています。その上、これらのツールはすべてベンダーロックインを受け入れなければならず、このようなツールに時間を費やすほどベンダーロックから抜けられなくなります。

In both the AI Chatbot and the Low Code tool scenarios, the solutions each promise a shortcut around the complexity as perceived by a non-practitioner. That's the essence of the trap. Practitioners know that the writing of the code is merely the last step in a long process that involves a lot of thinking, discussion and planning. The code is generally the end result and producing it is relatively easy once you truly understand the problem at hand.

AIチャットボットとローコードツールの両方で、各ソリューションは、非専門家の複雑さを回避する近道を約束しています。それが罠の本質です。開発者は、コードの記述が、多くの思考、議論、および計画を含む長いプロセスの最後のステップにすぎないことを知っています。コードは通常、最終結果であり、目前の問題を本当に理解していれば、それを作ることは比較的簡単なことです。

TLDR: Designing a solution worth a damn is actually the most difficult part of the software development process. Low Code tools lie to customers by implying that the writing of code is the hardest part. The reality is that No Low Code tool can spare you from having to take the time to properly design your custom software or the consequences you will experience when you build solutions around a half-ass design.

TLDR:価値のあるソリューションを設計することは、実はソフトウェア開発プロセスの中で最も難しい部分です。ローコードツールは、コードを書くことが最も難しい部分であるかのように、顧客に嘘をついています。現実には、どんなローコードツールも、ソフトウェアを適切に設計するための時間や、中途半端な設計でソリューションを構築したときの結末から逃げることはできません。

 

🤔 この意見についてどう思うか ChatGPT に聞いて見た

この意見についてあなたはどう思いますか。関西弁で答えて。

めっちゃ同感やわ。コーディングの複雑さを解消する特効薬があると思ったら大間違いやで。そんなもんあったら、開発者はみんなそれを使って楽々コーディングやろうて思うてるわ。AIチャットボットやローコードツールなんか、一部の単純なタスクをこなすのには使えるやろうけど、それだけや。複雑なタスクをやるには、経験や専門知識、センスが必要なんや。ローコードツールを使っても、適切なデータ構造の設計や品質検証など、ソフトウェア開発の複雑さは取り除けへん。プロの開発者に頼るべきやな。

めっちゃ大事なことは、この手のツールは高くて、ツールで作ったソフトをつかう限り、最終的には、支払わなあかんライセンスか請求のシステムになってるねん。それだけやなくて、全部のツールはベンダーロックインを受け入れなあかんから、この手のツールに時間を使うほど、ベンダーロックから抜け出せなくなることもあるで。

AIチャットボットとローコードツールは、どっちも非専門家でも使いやすいっていうのが売りやけど、それが落とし穴なんよ。開発者たちは、コード書くのは思考や議論、計画が必要な長いプロセスの最後のステップってことを知っとる。コードは普通、最終的な結果であって、問題を本当に理解してたら、それを作ることは比較的簡単なんやで。

要するに、簡単にソリューションを作ることはできへんってことや。どんなローコードツールでも、適切にソフトを設計するための時間や、中途半端な設計から逃げられへんのや。そんなことを顧客に嘘をついて、コード書くのは難しいとか言ってるんや。

 

🤔 まとめ

それを3行にして

1. 特効薬でコーディングが楽になるというのは誤解やで。
2. AIチャットボットやローコードツールは一部のタスクにしか使えへん。
3. 開発には経験や専門知識が必要や。

ナニワ金融道ぽくてワロタ。



【Git】.gitignore の状態を確認するコマンドたち

git status --ignored

まずは、状態の確認をしましょう。

以下は、基本的な Android プロジェクトでの例。


 

■ 位置を確認する


❯ find . -name .gitignore                          
./app/.gitignore
./.gitignore
./.idea/.gitignore

👉 AndroidStudio 新規プロジェクトテンプレートから考える .gitignore hatena-bookmark

 

■ git status


❯ git status          
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

 

■ git status --ignored


❯ git status --ignored
On branch main
Your branch is up to date with 'origin/main'.

Ignored files:
  (use "git add -f <file>..." to include in what will be committed)
        .gradle/
        .idea/workspace.xml
        app/build/
        local.properties

nothing to commit, working tree clean

→ ignore 対象が確認できます。

 

■ git clean -ndX


❯ git clean -ndX
Would remove .gradle/
Would remove .idea/workspace.xml
Would remove app/build/
Would remove build/
Would remove local.properties

 

■ git check-ignore -v


❯ git check-ignore -v .gradle/           
.gitignore:2:.gradle    .gradle/

❯ git check-ignore -v .idea/workspace.xml
.idea/.gitignore:3:/workspace.xml       .idea/workspace.xml

❯ git check-ignore -v app/build/         
app/.gitignore:1:/build app/build/

❯ git check-ignore -v local.properties
.gitignore:15:local.properties  local.properties

❯ git check-ignore -v **/*
app/.gitignore:1:/build app/build
app/.gitignore:1:/build app/build/generated
app/.gitignore:1:/build app/build/generated/ap_generated_sources
app/.gitignore:1:/build app/build/generated/ap_generated_sources/debug
app/.gitignore:1:/build app/build/generated/ap_generated_sources/debug/out
app/.gitignore:1:/build app/build/generated/res
...

→ そのファイルを ignore するパターン記述を特定することができます。

 

■ git ls-files --other --ignored --exclude-standard


❯ git ls-files --other --ignored --exclude-standard
.gradle/7.5.1/checksums/checksums.lock
.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock
.gradle/7.5.1/dependencies-accessors/gc.properties
.gradle/7.5.1/executionHistory/executionHistory.bin
.gradle/7.5.1/executionHistory/executionHistory.lock
...

→ 実際に ignore されたファイル一覧が確認できます。Adroid プロジェクトでは出力行が多くなるので省略しています。

 

■ 参考

👉 Git のステータス: リポジトリの検査 | Atlassian Git Tutorial hatena-bookmark


ChatGPT で調べる Singleton Pattern

試してみます。


👉 ChatGPT hatena-bookmark

日本語ではどうなのか。

👉 Singleton パターン - Wikipedia hatena-bookmark

 

■ "java singleton"

In Java, a singleton is a design pattern that ensures that a class has only one instance and provides a global point of access to it. This is useful when you need to have only one instance of a class for the entire application, such as for managing a shared resource.

To implement a singleton in Java, you would typically create a static member in the class that holds the sole instance of the class, and provide a static method that returns the instance. This method is typically called getInstance(). Here is an example:


public class Singleton { 
    private static Singleton instance; 

    private Singleton() { 
        // Private constructor to prevent instantiation 
    } 

    public static Singleton getInstance() { 
        if (instance == null) { 
            instance = new Singleton(); 
        } 
        return instance; 
    } 

}

To use the singleton, you would call the getInstance() method, like this:


Singleton instance = Singleton.getInstance();

It is important to note that a singleton in Java is not thread-safe by default. If multiple threads can access the getInstance() method simultaneously, it is possible for two or more instances of the class to be created. To make the singleton thread-safe, you can use synchronization in the getInstance() method, like this:


public static synchronized Singleton getInstance() { 
    if (instance == null) { 
        instance = new Singleton(); 
    } 
    return instance; 
}

This ensures that only one thread can execute the getInstance() method at a time, which prevents multiple instances of the class from being created.

 

■ "javaでシングルトン"

Javaでシングルトンとは、あるクラスが1つのインスタンスだけを持ち、そのインスタンスに対するグローバルなアクセスポイントを提供するデザインパターンです。これは、アプリ全体で1つのクラスのインスタンスだけが必要な場合に役立ちます。例えば、共有リソースの管理などです。

Javaでシングルトンを実装するには、通常はクラス内にクラスの唯一のインスタンスを保持するための静的メンバーを作成し、そのインスタンスを返す静的メソッドを提供します。このメソッドは通常、getInstance()と呼ばれます。以下に例を示します。


public class Singleton {
    private static Singleton instance;

    private Singleton() {
        // Private constructor to prevent instantiation
    }

    public static Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }
}

シングルトンを使用するには、getInstance()メソッドを呼び出します。以下はその例です。


Singleton instance = Singleton.getInstance();

Javaでのシングルトンはデフォルトでスレッドセーフではありません。複数のスレッドが同時にgetInstance()メソッドにアクセスできる場合、クラスの2つ以上のインスタンスが作成される可能性があります。シングルトンをスレッドセーフにするには、getInstance()メソッド内で同期を使用します。以下に例を示します。


public static synchronized Singleton getInstance() {
    if (instance == null) {
        instance = new Singleton();
    }
    return instance;
}

これにより、1つのスレッドだけがgetInstance()メソッドを実行できるようになり、クラスの複数のインスタンスが作成されることを防ぎます。

 

■ "java で singleton"

Javaでのシングルトンとは、あるクラスが1つのインスタンスだけを持ち、そのインスタンスに対するグローバルなアクセスポイントを提供するデザインパターンです。これは、アプリ全体で1つのクラスのインスタンスだけが必要な場合に役立ちます。例えば、共有リソースの管理などです。

Javaでシングルトンを実装するには、通常はクラス内にクラスの唯一のインスタンスを保持するための静的メンバーを作成し、そのインスタンスを返す静的メソッドを提供します。このメソッドは通常、getInstance()と呼ばれます。以下に例を示します。


public class Singleton {
    private static Singleton instance;

    private Singleton() {
        // Private constructor to prevent instantiation
    }

    public static Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }
}

シングルトンを使用するには、getInstance()メソッドを呼び出します。以下はその例です。


Singleton instance = Singleton.getInstance();

Javaでのシングルトンはデフォルトでスレッドセーフではありません。複数のスレッドが同時にgetInstance()メソッドにアクセスできる場合、クラスの2つ以上のインスタンスが作成される可能性があります。シングルトンをスレッドセーフにするには、getInstance()メソッド内で同期を使用します。以下に例を示します。


public static synchronized Singleton getInstance() {
    if (instance == null) {
        instance = new Singleton();
    }
    return instance;
}

これにより、1つのスレッドだけがgetInstance()メソッド

 

■ "kotlin singleton"

In Kotlin, a singleton is a design pattern that ensures that a class has only one instance and provides a global point of access to it. This is useful when you need to have only one instance of a class for the entire application, such as for managing a shared resource.
To implement a singleton in Kotlin, you can use the object keyword. This keyword is used to create a single instance of a class. Here is an example:


object Singleton { 
    fun doSomething() {
        // Code to perform some operation 
    } 
}

To use the singleton, you can simply call its methods like any other object, without the need to call a getInstance() method:


Singleton.doSomething()

One advantage of using the object keyword to implement a singleton in Kotlin is that it is thread-safe. Because the object keyword creates a single instance of the class, and because this instance is created when the class is loaded, multiple threads cannot access the getInstance() method simultaneously, and so it is not possible for multiple instances of the class to be created. This means you do not need to use synchronization to make the singleton thread-safe.

 

■ kotlin で singleton

Kotlinでのシングルトンとは、あるクラスが1つのインスタンスだけを持ち、そのインスタンスに対するグローバルなアクセスポイントを提供するデザインパターンです。これは、アプリ全体で1つのクラスのインスタンスだけが必要な場合に役立ちます。例えば、共有リソースの管理などです。

Kotlinでシングルトンを実装するには、objectキーワードを使用します。このキーワードは、クラスの1つのインスタンスを作成するために使用されます。以下は例です。


object Singleton {
    fun doSomething() {
        // Code to perform some operation
    }
}

シングルトンを使用するには、getInstance()メソッドを呼ぶ必要がないので、他のオブジェクトのように単にそのメソッドを呼び出します。以下はその例です。


Singleton.doSomething()

Kotlinでシングルトンを実装する際に、objectキーワードを使用する利点の1つは、それがスレッド

 

■ "dagger singleton"

Dagger is a dependency injection framework for the Java and Android platform. It is not itself a singleton, but rather a framework for creating and managing objects that are singletons or have other specific scope.
To create a singleton with Dagger, you would first define a class that provides the singleton instance. This class is called a "module" in Dagger terminology. Here is an example of a singleton module in Dagger:


@Module 
public class SingletonModule { 
    private static Singleton instance; 

    @Provides 
    @Singleton 
    public Singleton provideSingleton() {
        if (instance == null) {
            instance = new Singleton(); 
        }
        return instance; 
    } 
}

Next, you would define a "component" that uses the module to provide the singleton instance to other classes. Here is an example of a component that uses the above module:


@Component(modules = {SingletonModule.class}) 
public interface SingletonComponent { 
    Singleton getSingleton(); 
}

To use the singleton in your code, you would create an instance of the component and use it to get the singleton instance. Here is an example:


SingletonComponent component = DaggerSingletonComponent.create(); 
Singleton singleton = component.getSingleton();

In this example, the DaggerSingletonComponent class is generated by Dagger at compile time, based on the SingletonComponent interface. The create() method is a static factory method that creates an instance of the component.
By using Dagger to manage the singleton, you can avoid the need to use synchronization to make the singleton thread-safe, as Dagger takes care of this for you. Additionally, Dagger allows you to easily replace the singleton instance with a mock or test double in unit tests, which can make your tests more robust and easier to write.

 

■ "dagger2 singleton"

Dagger 2 is a dependency injection framework for the Java and Android platform. It is not itself a singleton, but rather a framework for creating and managing objects that are singletons or have other specific scope.
To create a singleton with Dagger 2, you would first define a class that provides the singleton instance. This class is called a "module" in Dagger terminology. Here is an example of a singleton module in Dagger 2:


@Module 
public class SingletonModule { 
    private static Singleton instance; 

    @Provides 
    @Singleton 
    public Singleton provideSingleton() { 
        if (instance == null) { 
            instance = new Singleton(); 
        }
        return instance; 
    } 
}

Next, you would define a "component" that uses the module to provide the singleton instance to other classes. Here is an example of a component that uses the above module:


@Component(modules = {SingletonModule.class}) 
public interface SingletonComponent { 
    Singleton getSingleton(); 
}

To use the singleton in your code, you would create an instance of the component and use it to get the singleton instance. Here is an example:


SingletonComponent component = DaggerSingletonComponent.builder().singletonModule(new SingletonModule()).build(); 
Singleton singleton = component.getSingleton();

In this example, the DaggerSingletonComponent class is generated by Dagger at compile time, based on the SingletonComponent interface. The builder() method is a static factory method that creates a builder for the component, which you can use to specify the module(s) to use.
By using Dagger 2 to manage the singleton, you can avoid the need to use synchronization to make the singleton thread-safe, as Dagger takes care of this for you. Additionally, Dagger 2 allows you to easily replace the singleton instance with a mock or test double in unit tests, which can make your tests more robust and easier to write.

 

■ "hilt singleton"

Hilt is a dependency injection framework for the Android platform, built on top of Dagger. It is not itself a singleton, but rather a framework for creating and managing objects that are singletons or have other specific scope.
To create a singleton with Hilt, you would first define a class that provides the singleton instance. This class is called a "module" in Hilt terminology. Here is an example of a singleton module in Hilt:


@Module 
@InstallIn(ApplicationComponent.class) 
public class SingletonModule { 
    private static Singleton instance; 

    @Provides 
    @Singleton 
    public Singleton provideSingleton() { 
        if (instance == null) { 
            instance = new Singleton(); 
        } 
        return instance; 
    } 
}

Next, you would annotate the class that wants to use the singleton with the @Inject annotation. Here is an example:


public class MyClass { 
  @Inject Singleton singleton; 
  // Code that uses the singleton goes here 
}

To use the singleton in your code, you would create an instance of the class and use the singleton. Hilt will automatically inject the singleton into the class when it is created. Here is an example:


MyClass myClass = new MyClass(); 
Singleton singleton = myClass.singleton;

By using Hilt to manage the singleton, you can avoid the need to use synchronization to make the singleton thread-safe, as Hilt takes care of this for you. Additionally, Hilt allows you to easily replace the singleton instance with a mock or test double in unit tests, which can make your tests more robust and easier to write.

 

■ "Flutter singleton"

In Flutter, a singleton is a design pattern that ensures that a class has only one instance and provides a global point of access to it. This is useful when you need to have only one instance of a class for the entire application, such as for managing a shared resource.
To implement a singleton in Flutter, you can use the Singleton class from the singleton_pattern package. Here is an example of how to use it:


import 'package:singleton_pattern/singleton_pattern.dart'; 
class MySingleton extends Singleton<MySingleton> { 
    // Code for your singleton goes here 
}

To use the singleton in your code, you would call the instance property of the class, like this:


MySingleton singleton = MySingleton.instance;

The Singleton class uses Dart's Isolates feature to ensure that the singleton is initialized only once and is thread-safe. This means you do not need to use synchronization to make the singleton thread-safe.

 

■ "Dart singleton"

In Dart, a singleton is a design pattern that ensures that a class has only one instance and provides a global point of access to it. This is useful when you need to have only one instance of a class for the entire application, such as for managing a shared resource.
To implement a singleton in Dart, you can use the Singleton class from the singleton_pattern package. Here is an example of how to use it:


import 'package:singleton_pattern/singleton_pattern.dart'; 
class MySingleton extends Singleton<MySingleton> { 
    // Code for your singleton goes here 
}

To use the singleton in your code, you would call the instance property of the class, like this:


MySingleton singleton = MySingleton.instance;

The Singleton class uses Dart's Isolates feature to ensure that the singleton is initialized only once and is thread-safe. This means you do not need to use synchronization to make the singleton thread-safe.
Alternatively, you can implement a singleton in Dart using a static property and a private constructor. Here is an example:


class MySingleton { 
    static final MySingleton instance = MySingleton._(); 
    MySingleton._(); // Private constructor 
    // Code for your singleton goes here 
}

To use the singleton, you would call the instance property, like this:


MySingleton singleton = MySingleton.instance;

This implementation is not thread-safe, so you would need to use synchronization if multiple threads can access the instance property simultaneously. For example:


class MySingleton { 
    static final MySingleton _instance = MySingleton._(); 
    static MySingleton get instance { 
        return _instance; 
    } 
    MySingleton._(); // Private constructor 
    // Code for your singleton goes here 
}

In this example, the instance property is a getter that uses synchronization to ensure that only one thread can access it at a time. This prevents multiple instances of the class from being created.

 

■ "swift singleton"

In Swift, a singleton is a design pattern that ensures that a class has only one instance and provides a global point of access to it. This is useful when you need to have only one instance of a class for the entire application, such as for managing a shared resource.

To implement a singleton in Swift, you would typically create a static constant property in the class that holds the sole instance of the class, and provide a static method that returns the instance. This method is typically called shared or sharedInstance. Here is an example:


class Singleton {
    static let shared = Singleton()

    private init() {
        // Private initializer to prevent instantiation
    }

    // Code for your singleton goes here
}

To use the singleton, you would call the shared property, like this:


let singleton = Singleton.shared

It is important to note that a singleton in Swift is not thread-safe by default. If multiple threads can access the shared property simultaneously, it is possible for two or more instances of the class to be created. To make the singleton thread-safe, you can use synchronization in the shared property, like this:


class Singleton {
    static let shared: Singleton = {
        let instance = Singleton()
        return instance
    }()

    private init() {
        // Private initializer to prevent instantiation
    }

    // Code for your singleton goes here
}

This ensures that only one thread can execute the shared property at a time, which prevents multiple instances of the class from being created.

 

■ まとめ

日本語で技術的なことを問う場合、英語、カタカナ、区切りなど複雑なので困ったりします。

コードについては、分かる人が見ればすぐに分かります。

どこかで見たような微妙なコードも含まれています。

「とりあえずそれっぽい」ので分からない人には分かりません。

逆に、Google検索と同じように使う側の技量が問われることになりそうです。

👉 Temporary policy: ChatGPT is banned - Meta Stack Overflow hatena-bookmark

👉 Kotlin で書きたい「正しいシングルトン(Singleton)」 hatena-bookmark

👉 チャットできるAI、ChatGPTが「そこまですごくない」理由。見えてしまった限界 | Business Insider Japan hatena-bookmark