軟件測試中什么是正交實驗法
正交性 (Orthogonality)
In software engineering, a system is considered orthogonal if changing one of its components changes the state of that component only.
在軟件工程中,如果更改系統的組件之一僅更改該組件的狀態,則認為該系統是正交的。
For instance, consider a program with three variables: a, b, and c. Changing the value of a should not change the value of b or c, provided they are independent.
例如,考慮一個具有三個變量的程序:a,b和c。 更改a的值不應更改b或c的值,只要它們是獨立的。
This property is particularly critical in debugging a program since one relies on narrowing down the number of moving parts of a program to identify the root cause of the problem.
此屬性在調試程序時特別重要,因為人們依賴于縮小程序的移動部分的數量來確定問題的根本原因。
See the following quote from Eric S. Raymond’s “Art of UNIX programming”:
請參見Eric S. Raymond的“ UNIX編程藝術”中的以下引用:
Orthogonality is one of the most important properties that can help make even complex designs compact. In a purely orthogonal design, operations do not have side effects; each action (whether it’s an API call, a macro invocation, or a language operation) changes just one thing without affecting others. There is one and only one way to change each property of whatever system you are controlling.
正交性是最重要的屬性之一,可以幫助使復雜的設計變得緊湊。 在純正交設計中,操作沒有副作用。 每個操作(無論是API調用,宏調用還是語言操作)都只會改變一件事而不會影響其他事情。 只有一種方法可以更改您所控制的任何系統的每個屬性。
Orthogonality is a software design principle for writing components in a way that changing one component doesn’t affect other components. It is the combination of two other principles, namely strong cohesion and loose coupling.
正交性是一種軟件設計原理,用于編寫組件,而更改一個組件不會影響其他組件。 它是另外兩個原理的結合,即強內聚和松散耦合。
It's actually is a term borrowed from mathematics. For example, two lines are orthogonal if they are perpendicular. In software design, two components are orthogonal if a change in one does not affect the other.
它實際上是一個從數學借來的術語。 例如,如果兩條線是垂直的,則它們是正交的。 在軟件設計中,如果一個組件的更改不影響另一個組件,則兩個組件是正交的。
Applying this concept to classes or other sections of code results in less coupling. To be orthogonal two classes cannot depend on each others implementation. They also cannot share global data. Changing the internals of one class does not affect the other class. Components should be independent and have only a single responsibility.
將此概念應用于類或代碼的其他部分可減少耦合。 要正交,兩個類不能互相依賴。 他們也不能共享全局數據。 更改一個類的內部結構不會影響另一類。 組件應該是獨立的,并且只有一個責任。
Consider a method that reads a list of numbers from a file and returns them in sorted order. Now the requirements change and the numbers are in a database. Modifying this method to access the database would cause client code to change. If this were two different methods, then a new source would not affect the sorting method. Only the client code would have to know the source of the numbers.
考慮一種從文件中讀取數字列表并按排序順序返回數字的方法。 現在,需求已更改,并且編號已存儲在數據庫中。 修改此方法以訪問數據庫將導致客戶端代碼更改。 如果這是兩種不同的方法,那么新的來源將不會影響排序方法。 只有客戶代碼才需要知道數字的來源。
強大的凝聚力 (Strong Cohesion)
Inside a software component, code should be strongly connected. This is an indication that the code is correctly divided.
在軟件組件內部,應牢固地連接代碼。 這表明代碼已正確劃分。
If a component had two or more relatively disconnected parts, that may indicate that those parts should be in a different component, or on its own.
如果一個組件具有兩個或多個相對斷開的部分,則可能表明這些部分應位于不同的組件中,或單獨存在。
松耦合 (Loose Coupling)
Between software components, there should be few connections. If two components are strongly coupled, it may indicate that they need to be one component, or that they need to be differently divided into more components.
在軟件組件之間,應該很少有連接。 如果兩個組件緊密耦合,則可能表明它們需要是一個組件,或者需要以不同的方式將它們分為更多的組件。
翻譯自: https://www.freecodecamp.org/news/orthogonality-in-software-engineering/
軟件測試中什么是正交實驗法