English 中文(简体)
镇压警告是否是一种良好做法?
原标题:Is it a good practice to suppress warnings?

有时,在Eclipse撰写Java时,我写的是引起警告的法典。 很常见的情况是,我在扩大<代码>Exception的类别时,可以这样做:

public class NumberDivideException extends Exception {

    public NumberDivideException() {
        super("Illegal complex number operation!");
    }

    public NumberDivideException(String s) {
        super(s);
    }
} // end NumberDivideException

警告:

序号编号不宣布一个固定的最终序列VersionUID的类型很长。

我知道这一警告是我的失败造成的,我说,以上是正确的。 我可以通过列入<条码>射电离心/代码”来解决这个问题,但这是一次长达一小时的学校派任;我不曾计划过任何时间。

当然,另一个选择是让Eclipse加入@Suppress Warnings (“serial”)

但每次我对<条码”的改动都会发生。 《禁止令》(<>/代码>)方案,我感到有些有罪。

总的说来,压制警告是否是一个好兆头?

(此外,作为一副问题,正在添加“生成的”<代码>航天器识别符号<>,例如<代码>航天飞机识别D = - 1049317663306637382L;。) 添加<密码>的恰当方式:


EDIT: Upon seeing answers, it appears my question may be slightly argumentative... Sorry! Too late for me to delete though...

最佳回答

它非常满意的是,它用警告汇编了法典,当你发出警告时,可以提醒你注意法典中的问题。

问题回答

In the particular case of eclipse, rather than suppress warnings as they happen, I prefer setting up eclipse to emit warnings I care about and automatically ignore all instances of the ones I don t. See Windows -> Preferences -> Java -> Compiler -> Error/Warnings

然而,这一点与 Java相当具体,我发现, Java往往比其他大多数语文更注意许多警告。 在其他语文中,我通常在提出警告和确定这些警告时都会这样做。

You shall supress warnings ONLY if you are absolutely sure of what you are doing and it whould be better to have this kind of thing documented for future alterations (java doc comments for example)

这样,你就隐藏了你知道的警告,这些警告会引发问题,并能够把注意力集中在导致你ble的人身上。

如果是你重新研究的一个方案,那么它将付出代价,以正确的方式——这意味着不压制警告,而是纠正警告。

然而,对于学校的任务,经常要求你重新承担轮椅/包裹三维的任务,因此,你对“打”的 together不感到任何污点。 不管怎么说,你都是按ding写的。

你们永远不应压制全球的警告,哪怕只是某种警告。 您还应使您的汇编者尽可能精彩。 有警告告诉你可能存在的问题。 你们要么支持你们的法典,要么以某种语言加入某种指令,无视引起具体警告的某种特定法典。 如果你知道是大韩民国,这将允许你审查警告,而忽视。

在实际情况下,仅以特定线或大部分特定档案的形式压制警告。

这不仅确保了你希望通过你发出的警告,而且作为一种明确的设计说明——指出你知道这个问题的下一位编辑(或在一个月的时间内编辑),并蓄意决定该守则是可以接受的。 这就使下个人不必再评估局势。

(我没有足够了解情况,无法做到这一点——这是适用于各种语文的一项一般原则。)





相关问题
XML-RPC Standard and XML Data Type

I was looking at XML-RPC for a project. And correct me if I m wrong, but it seems like XML-RPC has no XML datatype. Are you supposed to pass as a string? or something else? Am I missing something? ...

Is it exists any "rss hosting" with API for creating feeds

I am creating a desktop app that will create some reports. I want to export these reports as RSS or ATOM feeds. I can easily create feeds with Rome lib for Java. But I have no idea how to spread them. ...

Improving Q-Learning

I am currently using Q-Learning to try to teach a bot how to move in a room filled with walls/obstacles. It must start in any place in the room and get to the goal state(this might be, to the tile ...

High-traffic, Highly-secure web API, what language? [closed]

If you were planning on building a high-traffic, very secure site what language would you use? For example, if you were planning on say building an authorize.net-scale site, that had to handle tons ...

Def, Void, Function?

Recently, I ve been learning different programming langages, and come across many different names to initalize a function construct. For instance, ruby and python use the def keyword, and php and ...

热门标签