是否有包含常用 Java 实体/类/Bean/数据结构的库/存储库/公共站点? (最好是Java)

发布于 2024-10-08 05:12:54 字数 522 浏览 6 评论 0原文

我们都重用我们的代码,但实际上,您发现自己重写了多少次这样的代码?

class Person{ 
    private String firtsName;
    private String lastName;
    private Date dob;
    ...
    private List<Address> addresses

那不是

class Address { 
    private String address1;
    private String address2;
    private String city;
    private String zip;
    ...

如果我们有一个免费的、成熟的、编写良好的最佳实践实体类型/bean/POJO/POCO 库,这样我们终于可以告别尝试用 Java/C#/ 克隆世界了, 很好吗? (替换为您最喜欢的语言)并开始编写实际代码。

有这样的事吗? 你同意这是必需的吗?

We all reuse our code, but really, how many times did you find yourself re-writing something like this?

class Person{ 
    private String firtsName;
    private String lastName;
    private Date dob;
    ...
    private List<Address> addresses

or this

class Address { 
    private String address1;
    private String address2;
    private String city;
    private String zip;
    ...

Wouldn't it be nice if we had a library of free, mature, well written, best practice Entity types / beans / POJOs / POCOs so we all can finally say good bye to trying to clone the world in Java / C# / (replace with your favorite language) and start writing actual code.

Is there something like that?
Do you agree it's required?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

柏林苍穹下 2024-10-15 05:12:54

有类似的事情吗?

我听说没有这样的图书馆。

您同意这是必需的吗?

不,我不。

有很多可能的方法可以编写这样的域对象(取决于业务需求),组织这样的库将是一场噩梦。

此外,这种对象通常仅由 getter 和 setter 组成,并且可以非常快速地编写......甚至可以从模型生成......因此通过使用库可以节省很少的时间/精力。

(相比之下,您在典型的可重用类库中找到的类要复杂得多,并且从头开始编写要困难得多。)

话虽如此,我认为大规模重用此类东西是有道理的;例如,用于管理客户数据库或网站帐户详细信息的现成组件或系统。

Is there something like that?

I've heard of no such library.

Do you agree it's required?

No, I don't.

There are so many possible ways that you could write domain objects like this (depending on the business requirements), that organizing such a library would be a nightmare.

Besides, this kind of object typically consists of just getters and setters, and can be written very quickly ... or even generated from a model ... so you save very little time / effort by using a library.

(By contrast, the kind of classes you find in typical reusable class libraries are much more complicated, and much more difficult to write from scratch.)

Having said that, I think there is justification for reuse of this kind of thing on a larger scale; e.g. off-the-shelf components or systems for managing customer databases, or website account details.

Bonjour°[大白 2024-10-15 05:12:54

您是否正在寻找类似于的内容。

Skyway 是一个开源工具,它可以根据您的需要生成代码,帮助您节省多余的 JAVA 代码输入。

Are you looking something similar to this.

The Skyway is an open source tool which does generate the code to your needs that helps you to save your redundant typing of JAVA code.

李不 2024-10-15 05:12:54

mvnrepository.com 包含大量不同性质的 Java 代码。您提出的问题中最困难的部分是在那里完成的——中央、可搜索的 Java 代码存储库,它被许多开发人员使用,并且是“常见做法”。

我不知道是否有一些图书馆的用途与您感兴趣的类似。但如果没有,您可以随时编写它并通过给定的链接与世界分享。

There's mvnrepository.com which contains tons of Java code of different nature. The most difficult part of you asking is done there -- central, searchable repository of Java code which is used by lots of developers and is "common practice".

I don't know if there's some library with purpose similar to what you interested in. But if there isn't you can always write it and share it with the world via given link.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文