gpt4 book ai didi

java - 以良好的类(class)设计为目标时需要注意哪些事项?

转载 作者:太空狗 更新时间:2023-10-29 22:46:17 25 4
gpt4 key购买 nike

<分区>

昨天我参加了一家领先的 IT 服务公司的面试。技术面试很好,没有问题,然后我转到了另一轮关于管理、设计和流程的面试。除了以下问题,我已经回答了所有问题。

面试官提问:

Let say you are developing a class, which I am going to consume in my class by extending that, what are the key points you keep in mind? Ex, Class A, which has a method called "method A" returns a Collection, let say "list". What are the precautions you will take?

我的回答:我会考虑以下几点,例如:

  1. 类和方法需要公开
  2. 方法1返回一个列表,那么这个需要是泛型。所以我们可以避免类转换异常
  3. 如果在多线程环境下访问该类,则需要同步该方法。

但是面试官并不相信我的观点。他期待我的不同答案,但我无法理解他的思考过程,他在排除什么。

所以请提供您的建议。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com