How Crappy Is Your Java Source Code?くだらないしてJavaのソースコードはどのようですか?
Crap4J crap4j claims to be able to quantify crappiness in Java code with a simple formula (applicable to a method):くだらなさを定量的に主張できるようにJavaコードで、単純な数式(適用して法) :
CRAP(m) = comp(m)^2 * (1 – cov(m)/100)^3 + comp(m) crap (オス) =のCOMP (オス) ^ 2 * ( 1 -c ov(オス) / 1 00) ^ 3 +のC OMP(オス)
Where comp(m) is the cyclomatic complexity of method m, and cov(m) is the test code coverage provided by automated tests (eg JUnit tests, not manual QA).どこのCOMP (オス)は、条件分岐の複雑さのメソッドm 、およびcov (オス)は、テストコードのカバレッジ自動テスト提供される(例えば、 JUnitのテストではなく、マニュアルのQA )です。 Cyclomatic complexity is a well-known and widely used metric and it’s calculated as one plus the number of unique decisions in the method.条件分岐の複雑さは、よく知られて、広く使われて計算さの指標とそれに加えて1つの番号の固有の意思決定は、メソッドを使用します。 For code coverage we use basis path coverage.年代的にパスコードカバレッジを使用します。 Low CRAP numbers indicate code with relatively low change and maintenance risk – because it’s not too complex and/or it’s well-protected by automated and repeatable tests.低crap比較的低い数字を示すコードを変更するとメンテナンスの危険性-それはあまりにも複雑なため、および/またはそれを十分に保護され、再現性の高い自動テストを実行します。 High CRAP numbers indicate code that’s risky to change because of a hazardous combination of high complexity and low, or no, automated test coverage.高crap数字を示すコードを変更することの危険性の高い組み合わせのため、危険性の複雑さと低か、またはいいえ、自動テストカバレッジします。
Generally speaking, you can lower your CRAP score either by adding automated tests or by refactoring to reduce complexity.一般的に言えば、することができます。 crapによるスコアのいずれかを引き下げてくださいを追加する、または自動テストの複雑さを減らすためにリファクタリングします。
Now you can go to your boss and quantitatively show him that your code is less crappier than your colleague*.今すぐあなたの上司とすることができます。定量的に詳細に行く彼してくださいコードは、あなたの同僚よりも少ないcrappier *. After all managers like numbers, even if they have crappy & dubious validity.すべてのマネージャーのような数字した後、たとえ彼らはくだらない&怪しげな。
*Remember to forget that Crap4J even exists, or discount it heavily at any mention, if your code turns out to be crappier than your competitor. *を忘れずにさえ存在を忘れてcrap4jか、または割引が大きく、いつに言及、もしあなたのコードはこれまでに、お客様の競合他社よりもcrappierです。
Note: CRAP stands for Change Risk Anti-Patterns according to their definition.注:変更の危険性抗crapスタンドパターンによると定義されています。
Crap4J comes as an Eclipse plugin and can also be integrated with Ant. crap4jはEclipseのプラグインとして統合されることもアリです。 Check the video for a nice demonstration.ビデオをチェックして、ニースのデモです。 The authors decided to use 30 as a threshold for crappiness.作家としてのしきい値30を使用することを決めたのくだらなさです。
I partially agree with the idea but I am not comfortable with the formula.私部分的に同意する考えしかし、私は快適に、数式です。 Also it ignores cross-method complexity introduced and complexity of a class as a whole which may not always be the sum of the complexity of the methods.また、法を無視し、クロスクラスの複雑さを紹介し、全体としての複雑さが5月の合計は、常に特定の複雑な方法を使用します。
Filed under提出されて Enterprise Softwareエンタープライズソフトウェア , 、 Headline Newsニュースの見出し , 、 How Toどのように , 、 Humorユーモア , 、 Java Software Javaソフトウェア , 、 Open Source Softwareオープンソースのソフトウェア , 、 Programmingプログラミング | |
| |
RSS 2.0 RSS 2.0を | |
Trackbackトラックバック this Article |この記事|
Email this Article電子メールこの記事
You may also like to readを読むようにすることも可能 |




December 7th, 2007 at 9:19 pm 2007年12月7日の午前4:19
OHH NO, Another plugin ohhいいえ、別の差込式
Don’t we already have plugins that do that ?我々はすでにプラグインがないのですか?
Also, It seem’s to check for two things only (complexity and coverage)また、それをチェックするための2つのことのように見えるだけ(の複雑さや年代)
Anyway,I don’t know anybody who wants their code to be called crap.とにかく、私には分からない彼らのコードを誰でも望むと呼ばwhoはナンセンスですよ。 But it’sa nice way to get our attention for their plugin.しかし、これは良い方法に差込式私達の注意を取得します。
I use IntelliJ IDE and most of what I do is web developement (JSP,javascript and form handlers).私は何を使用intellij IDEと私には、ほとんどのウェブ開発( JSPやJavaScriptとフォームハンドラ)です。
My experience tells me that spending a little time in the beginning to think through the problem will go a long way in writing quality code and you don’t need as my test cases(especially trivial ones).私の経験ではないかと思うと支出の初めには少し時間がこの問題を考えるを通じて書面では、遠くまで行く必要はありません。品質のコードと私のテストケースとして(特にtrivialもの)です。
Coming back to IntelliJ , the IDE has many inspections by default that it can run on your code and I went back to check for this and found it. intellijに戻ってきつつ、デフォルトのIDEには多くの査察をしてコードを実行することができると私は先頭をチェックするためこれを発見してください。
The inspection say’s this :言ってやるの検査のこの:
This inspection reports any instances of methods that have too high a cyclomatic complexity.この検査報告書のインスタンスを任意のメソッドを持つサイクロマティック複雑度が高すぎるのです。 Cyclomatic complexity is basically a measurement of the number of branching points in a method.条件分岐の複雑さは、基本的に分岐点の数を測定し、メソッドを使用します。 Methods with too high a cyclomatic complexity may be confusing and difficult to test.メソッドをサイクロマティック複雑度が高すぎるのは混乱と困難をテストする。
Another reason for me to love itもう一つの理由は私を愛して
BTW, your spam guard kicked me out twice when using Opera.ところで、私を追い出したのお客様の迷惑メールガードを使用してオペラの2倍です。 Iam trying this with FF.Let’s see今これをしようとしff.let '秒を参照
December 9th, 2007 at 9:42 am 2007年12月9日は9:42アム
> Anyway,I don’t know anybody who wants their code to be called crap. >とにかく、私には分からない彼らのコードを誰でも望むと呼ばwhoはナンセンスですよ。
I have seen code worse than crap.私は見たコードの見通しに比べ悪いはナンセンスですよ。 However as you said nobody would like toしかし、誰もあなたによるとしたい call their own code crapコール独自のコードcrap .です。
> My experience tells me that spending a little time in the beginning to think through the problem will go a long way in writing quality code and you don’t need as my test cases(especially trivial ones). > "マイ経験的に知ってて医療費を初めには少し時間がこの問題を考えるを通じて書面では、遠くまで行く必要はありません。品質のコードと私のテストケースとして(特にtrivialもの)です。
While it may be true for the experienced programmers, even they can benefit from good unit testing.真のかもしれないが、経験豊富なプログラマーでも良いユニットテストの恩恵を受けることができます。 As for the rest unit tests go a long way in creating reusable quality code.また、残りのユニットテストの作成遠くまで行く品質のコードを再利用可能です。
I have sent you an email wrt.私はあなたに電子メール送信wrtで変わった。 your problem with our comment protection.お客様の問題が私たちのコメント無しです。
December 9th, 2007 at 11:48 am 2007年12月9日の11:48時
In my first comment I said ‘Not another plugin’.私の最初のコメントを私によると'は別の差込式' 。 I did that because often times I question the motives behind what some of the OSS guys are upto.私はその問題にするため、しばしば回私の背後にある動機はどのようないくつかのOSSの人までです。
My suggestion for anyone coming up with an open source product is to provide justification for it by 1) Telling what they are doing.私の提案を、誰が間近に迫って、オープンソース製品は、正当性を提供することによって1 ) telling彼らはどのようなことです。
2) What’s out there in the market (both free and commercial) that does the same thing(or similar). 2 )そこには何のアウト市場(無料と商業の両方)には、同じこと(または類似) 。
3) If there are any OSS products, why did they choose to create this one instead of contributing to the other. 3 ) OSSの製品があれば、なぜ彼らを作成し、この1つの代わりに選択に貢献するには、他のです。
3) Why is their product different. 3 )なぜ、自社の製品は異なっています。
I think, lot of people , who wasted countless hours evaluating these products can relate to what Iam saying.私が思うに、多くの人々 、 who無駄に数えきれないほどの時間の評価に関連し、これらの製品は、今は何と言っています。
Another metric I apply to OS products is this: If it costed x dollars would I buy it?別の指標を私は、このOS製品に適用さ:もしそのせいでxドルで購入することは何ですか?