Cov txheej txheem:

Tus lej cyclomatic suav li cas?
Tus lej cyclomatic suav li cas?

Video: Tus lej cyclomatic suav li cas?

Video: Tus lej cyclomatic suav li cas?
Video: NPAU SUAV POM Nas Xov Txhais Li Cas/ Tus Lej 2024, Tej zaum
Anonim

Cyclomatic complexity yog qhov chaw code nyuaj kev ntsuas uas raug cuam tshuam nrog a tus lej ntawm coding yuam kev. Nws yog xam los ntawm kev tsim lub Control Flow Graph ntawm cov cai uas ntsuas qhov tus lej ntawm linearly-independent paths los ntawm ib qho kev pab cuam module.

Nyob rau hauv kev hwm rau qhov no, dab tsi yog lub mis rau cyclomatic code complexity?

Cyclomatic Complexity formula N = Number of nodes.

Ib yam li ntawd, dab tsi yog cyclomatic complexity piv txwv? Cyclomatic complexity ntawm ib qho code seem yog qhov ntsuas qhov ntau ntawm cov lej ntawm txoj hauv kev ywj pheej hauv nws. Rau piv txwv , yog hais tias qhov chaws tsis muaj kev tswj cov dej ntws ces nws cyclomatic complexity yuav yog 1 thiab qhov chaws muaj ib txoj hauv kev hauv nws.

Hauv qhov no, McCabe tus lej suav li cas?

Yuav ua li cas xam Cyclomatic Complexity (McCabe)

  1. P = tus naj npawb ntawm qhov cuam tshuam ntawm cov kab hluav taws xob ntws (piv txwv li kev hu xov tooj thiab cov txheej txheem subroutine)
  2. E = tus naj npawb ntawm ntug (hloov tswj)
  3. N = tus naj npawb ntawm cov nodes (ib pawg ntawm cov nqe lus uas tsuas muaj ib qho kev hloov ntawm kev tswj)

Lub hom phiaj ntawm cc3 cyclomatic complexity yog dab tsi nws ua li cas?

CYCLOMATIC COMPLEXITY yog software metric siv los ntsuas qhov nyuaj ntawm ib qho program. Nws yog ib qho kev ntsuas ntau ntawm txoj kev ywj pheej hauv qhov chaws ntawm qhov kev zov me nyuam. Txoj kev ywj pheej txhais tau tias yog txoj hauv kev uas muaj tsawg kawg yog ib qho ntug uas tsis tau hla ua ntej hauv lwm txoj kev.

Pom zoo: