你的大型语言模型并不真正实现面向对象编程,问题在于结构

📄 中文摘要

生成式人工智能每天都在编写代码,包括类、服务、模型和控制器。表面上看,这些代码似乎都是正确的,能够编译、通过测试并完成任务。然而,生成的代码往往存在一个反复出现的问题:封装性差。具体表现为类中充满了 getter 和 setter,几乎没有行为,业务逻辑分散在各处,导致代码呈现出数据导向而非面向对象的特征。这种现象的根源在于对面向对象编程的理解缺失,尤其是对其初衷的遗忘。要改善这一点,需要在使用人工智能时采取更好的方法。

📄 English Summary

Your LLMs don't do real OOP, and it's structural.

Generative AIs write code daily, including classes, services, models, and controllers. At first glance, this code appears correct, compiling, passing tests, and fulfilling its purpose. However, a recurring issue arises: code generated by LLMs is often poorly encapsulated. Specifically, classes are filled with getters and setters, exhibit little to no behavior, and scatter business logic throughout, resulting in data-oriented rather than object-oriented code. This issue stems from a misunderstanding of what object-oriented programming originally meant, particularly the neglect of its foundational principles. To address this, better practices must be adopted when utilizing AI.

Powered by Cloudflare Workers + Payload CMS + Claude 3.5

数据源: OpenAI, Google AI, DeepMind, AWS ML Blog, HuggingFace 等