コード匂い94 -あまりに多くの輸入
7199 ワード
あなたのクラスがあまりにも多くの他のものに依存するならば、それは結合されて、壊れます.長い輸入リストは良い指標です.
問題 カップリング 一責任原則違反 低粘着力
解決策 クラスを破る 中間の偶然の実施を隠してください
サンプルコード
間違い
右
検出
我々は、我々のプリンターに警告閾値をセットすることができます.
タグ カップリング 波及効果
結論
リプル効果を最小にするために解決策を構築する際に依存性について考える必要がある.
関係
詳しい情報 Namespaces on Wikipedia
クレジット
写真でZdeněk Macháček on Unsplash
デイヴィッドベロン🌊 🗡
ベロンダビド
あまりにも多くのことをしているクラスのインジケータ-そう、それはSRPに対して-インポートされた名前空間の数です.あまりにも多くの参照された名前空間があるならば、それはあなたのクラスがすぐにあまりに多くのことをしていることを意味します.少し、より良い!
午後18時02分- 2021年10月11日
アランペリス
この記事はCodesmellシリーズの一部です.
TL;DR: Don't import too much.
問題
解決策
サンプルコード
間違い
import java.util.LinkedList;
import java.persistence;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException
import java.util.Queue;
import org.fermi.common.util.ClassUtil;
import org.fermi.Data;
//We rely on too many libraries
public class Demo {
public static void main(String[] args) {
}
}
右
import org.fermi.domainModel;
import org.fermi.workflow;
//We rely on few libraries
//and we hide their implementation
//So maybe transitive imports are the same
//but we don't break encapsulation
public class Demo {
public static void main(String[] args) {
}
}
検出
我々は、我々のプリンターに警告閾値をセットすることができます.
タグ
結論
リプル効果を最小にするために解決策を構築する際に依存性について考える必要がある.
関係
Code Smell 61 - Coupling to Classes
Maxi Contieri ・ Feb 4 '21 ・ 2 min read
#webdev
#tutorial
#codenewbie
#programming
詳しい情報
クレジット
写真でZdeněk Macháček on Unsplash
デイヴィッドベロン🌊 🗡
ベロンダビド
あまりにも多くのことをしているクラスのインジケータ-そう、それはSRPに対して-インポートされた名前空間の数です.あまりにも多くの参照された名前空間があるならば、それはあなたのクラスがすぐにあまりに多くのことをしていることを意味します.少し、より良い!
午後18時02分- 2021年10月11日
Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it.
アランペリス
Software Engineering Great Quotes
Maxi Contieri ・ Dec 28 '20 ・ 13 min read
#codenewbie
#programming
#quotes
#software
この記事はCodesmellシリーズの一部です.
How to Find the Stinky parts of your Code
Maxi Contieri ・ May 21 '21 ・ 4 min read
#codenewbie
#tutorial
#codequality
#beginners
Reference
この問題について(コード匂い94 -あまりに多くの輸入), 我々は、より多くの情報をここで見つけました https://dev.to/mcsee/code-smell-94-too-many-imports-4n14テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol