コード嗅覚95 -早熟な分類
7314 ワード
我々は一般化している.十分なコンクリートを見るまでは抽象化を起こすべきではない.
文脈
アリストテレス分類は計算機科学の大きな問題である.
我々は、十分な知識と文脈を集める前に、分類して、名前をつける傾向があります.
問題 未来学 不良設計
解決策 具体的に待つ リファクタ
サンプルコード
間違い
右
検出
つのサブクラスを持つ抽象クラスは、早期分類の指標である
タグ 不良設計 分類
結論
クラスで作業するとき、我々は彼らが現れるとすぐに、抽象化を命名します.
私たちのルールは行動の後に選ぶことです.
具体的なサブクラスに名前を付けるまでは、抽象化の名前をつけてはいけません.
関係
詳しい情報
クレジット
写真でFaye Cornish on Unsplash
ドナルド・E
この記事はCodesmellシリーズの一部です.
TL;DR: Don't guess what the future will bring you.
文脈
アリストテレス分類は計算機科学の大きな問題である.
我々は、十分な知識と文脈を集める前に、分類して、名前をつける傾向があります.
問題
解決策
サンプルコード
間違い
class Rectangle
{
int length;
int breadth;
int area()
{
return length * breadth;
}
}
//We are creating a premature abstraction
//And misusing is-a relation since a Square "is a" Rectangle
class Square extends Rectangle
{
int length;
int area()
{
return length * length;
}
}
右
class Rectangle
{
int length;
int breadth;
int area()
{
return length * breadth;
}
}
class Square
{
int length;
int area()
{
return length * length;
}
}
//Square might-be a Rectangle
//But it does not follow behaves-like relation so we won't go ahead
//and create a strong relation between them
//Maybe they are shapes. We don't have enough examples and protocol yet
//We will not guess until further knowledge
検出
つのサブクラスを持つ抽象クラスは、早期分類の指標である
タグ
結論
クラスで作業するとき、我々は彼らが現れるとすぐに、抽象化を命名します.
私たちのルールは行動の後に選ぶことです.
具体的なサブクラスに名前を付けるまでは、抽象化の名前をつけてはいけません.
関係
Code Smell 11 - Subclassification for Code Reuse
Maxi Contieri ・ Oct 30 '20 ・ 2 min read
#oop
#codenewbie
#tutorial
詳しい情報
クレジット
写真でFaye Cornish on Unsplash
Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.
ドナルド・E
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
この問題について(コード嗅覚95 -早熟な分類), 我々は、より多くの情報をここで見つけました https://dev.to/mcsee/code-smell-95-premature-classification-14haテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol