コード嗅覚16 - リップル効果
8039 ワード
小さな変化は予期しない問題をもたらす
問題
デカッププル. テストでカバー. リファクターとは何が変化して孤立します. はインターフェイスに依存します.
遺産システム サンプルコード
それが起こる前に問題を見つけるのは簡単ではありません.Mutation Testingとsingle points of failuresの根本原因分析は助けるかもしれません. 遺産 結論
クレジット
TL;DR: If small changes have big impact, you need to decouple your system.
問題
のカップリング
結合:唯一のソフトウェア設計問題
マキシ・コンティ・ 2月6日・ 5分読む
#webdev
#programming
#oop
#tutorial
解決策
レガシーシステムを分離する方法
マキシ・コンティ・ Mar 1 ' 21・ 7分読む
#codenewbie
#programming
#poo
#tutorial
例
サンプルコード
間違い
class Time {
constructor(hour, minute, seconds) {
this.hour = hour;
this.minute = minute;
this.seconds = seconds;
}
now(){
//call operating system
}
}
//Adding a TimeZone will have a big Ripple Effect
//Changing now() to consider timezine will also bring the effect
右
class Time {
constructor(hour, minute, seconds, timezone) {
this.hour = hour;
this.minute = minute;
this.seconds = seconds;
this.timezone = timezone;
}
//Removed now() since is invalid without context
}
class RelativeClock {
constructor(timezone){
this.timezone = timezone;
}
now(timezone){
var localSystemTime = this.localSystemTime();
var localSystemTimezone = this.localSystemTimezone();
//Do some math translating timezones
//
return new Time(..., timezone);
}
}
検出
class Time {
constructor(hour, minute, seconds) {
this.hour = hour;
this.minute = minute;
this.seconds = seconds;
}
now(){
//call operating system
}
}
//Adding a TimeZone will have a big Ripple Effect
//Changing now() to consider timezine will also bring the effect
class Time {
constructor(hour, minute, seconds, timezone) {
this.hour = hour;
this.minute = minute;
this.seconds = seconds;
this.timezone = timezone;
}
//Removed now() since is invalid without context
}
class RelativeClock {
constructor(timezone){
this.timezone = timezone;
}
now(timezone){
var localSystemTime = this.localSystemTime();
var localSystemTimezone = this.localSystemTimezone();
//Do some math translating timezones
//
return new Time(..., timezone);
}
}
タグ
結論
レガシーで結合されたシステムに対処する複数の戦略があります.我々の目の下で爆発する前に我々はこの問題に対処すべきだ.
関係
詳しい情報
クレジット
Jack TindallのUnsplashによる写真
Architecture is the tension between coupling and cohesion.
ネールフォード
ソフトウェア工学大引用
マキシ・コンティ・ Dec 28 ' 20・ 13分読む
#codenewbie
#programming
#quotes
#software
この記事はCodesmellシリーズの一部です.
あなたのコードの臭い部分を見つける方法
マキシ・コンティ・ May 21 ' 21・ 4分読む
#codenewbie
#tutorial
#codequality
#beginners
最終更新日: 2021/06/24
Reference
この問題について(コード嗅覚16 - リップル効果), 我々は、より多くの情報をここで見つけました
https://dev.to/mcsee/code-smell-16-ripple-effect-3881
テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol
Architecture is the tension between coupling and cohesion.
ソフトウェア工学大引用
マキシ・コンティ・ Dec 28 ' 20・ 13分読む
#codenewbie
#programming
#quotes
#software
あなたのコードの臭い部分を見つける方法
マキシ・コンティ・ May 21 ' 21・ 4分読む
#codenewbie
#tutorial
#codequality
#beginners
Reference
この問題について(コード嗅覚16 - リップル効果), 我々は、より多くの情報をここで見つけました https://dev.to/mcsee/code-smell-16-ripple-effect-3881テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol