How can i reduce cyclomatic complexity from a model
i need to reduce cyclomatic complexity of this model because it has 26, this is a normal class for setters and getters
public class DetailRecord {
private int lengthReference1;
private int lengthReference2;
private int lengthPayersNit;
private int lengthTransactionAmount;
private String recordType;
private String payersNit;
private String payersName;
private String payersAccountBank;
private String accountNumberToBeDebited;
private String transactionType;
private String transactionAmount;
private String referenceOne;
private String referenceTwo;
private String expirationDateOrApplicationDate;
private String billedPeriods;
private String cycle;
private String reserved;
private String validationNit;
private String encabezadoTotal;
public DetailRecord() {
lengthReference1 = 30;
lengthReference2 = 30;
lengthPayersNit = 13;
lengthTransactionAmount = 17;
recordType = "6";
payersName = " ";
}
public int getLengthReference1() {
return lengthReference1;
}
public int getLengthReference2() {
return lengthReference2;
}
public int getLengthPayersNit() {
return lengthPayersNit;
}
public int getLengthTransactionAmount() {
return lengthTransactionAmount;
}
public String getRecordType() {
return recordType;
}
public String getPayersName() {
return payersName;
}
public String getPayersAccountBank() {
return payersAccountBank;
}
}
How can i reduce the cyclomatic complexity? Using a builder perhaps or what else can I do? Abstract the class or maybe create a interface?
java design-patterns getter-setter
add a comment |
i need to reduce cyclomatic complexity of this model because it has 26, this is a normal class for setters and getters
public class DetailRecord {
private int lengthReference1;
private int lengthReference2;
private int lengthPayersNit;
private int lengthTransactionAmount;
private String recordType;
private String payersNit;
private String payersName;
private String payersAccountBank;
private String accountNumberToBeDebited;
private String transactionType;
private String transactionAmount;
private String referenceOne;
private String referenceTwo;
private String expirationDateOrApplicationDate;
private String billedPeriods;
private String cycle;
private String reserved;
private String validationNit;
private String encabezadoTotal;
public DetailRecord() {
lengthReference1 = 30;
lengthReference2 = 30;
lengthPayersNit = 13;
lengthTransactionAmount = 17;
recordType = "6";
payersName = " ";
}
public int getLengthReference1() {
return lengthReference1;
}
public int getLengthReference2() {
return lengthReference2;
}
public int getLengthPayersNit() {
return lengthPayersNit;
}
public int getLengthTransactionAmount() {
return lengthTransactionAmount;
}
public String getRecordType() {
return recordType;
}
public String getPayersName() {
return payersName;
}
public String getPayersAccountBank() {
return payersAccountBank;
}
}
How can i reduce the cyclomatic complexity? Using a builder perhaps or what else can I do? Abstract the class or maybe create a interface?
java design-patterns getter-setter
3
How using getters/setters count towards cyclomatic complexity?
– user7
Jan 1 at 4:27
it counts each return
– Santiago Molano
Jan 1 at 5:19
1
As user7 said, Cyclomatic complexity mainly depends on branching conditions. I your case it is just a Bean, so I dont think this would count.
– Dush
Jan 1 at 7:57
add a comment |
i need to reduce cyclomatic complexity of this model because it has 26, this is a normal class for setters and getters
public class DetailRecord {
private int lengthReference1;
private int lengthReference2;
private int lengthPayersNit;
private int lengthTransactionAmount;
private String recordType;
private String payersNit;
private String payersName;
private String payersAccountBank;
private String accountNumberToBeDebited;
private String transactionType;
private String transactionAmount;
private String referenceOne;
private String referenceTwo;
private String expirationDateOrApplicationDate;
private String billedPeriods;
private String cycle;
private String reserved;
private String validationNit;
private String encabezadoTotal;
public DetailRecord() {
lengthReference1 = 30;
lengthReference2 = 30;
lengthPayersNit = 13;
lengthTransactionAmount = 17;
recordType = "6";
payersName = " ";
}
public int getLengthReference1() {
return lengthReference1;
}
public int getLengthReference2() {
return lengthReference2;
}
public int getLengthPayersNit() {
return lengthPayersNit;
}
public int getLengthTransactionAmount() {
return lengthTransactionAmount;
}
public String getRecordType() {
return recordType;
}
public String getPayersName() {
return payersName;
}
public String getPayersAccountBank() {
return payersAccountBank;
}
}
How can i reduce the cyclomatic complexity? Using a builder perhaps or what else can I do? Abstract the class or maybe create a interface?
java design-patterns getter-setter
i need to reduce cyclomatic complexity of this model because it has 26, this is a normal class for setters and getters
public class DetailRecord {
private int lengthReference1;
private int lengthReference2;
private int lengthPayersNit;
private int lengthTransactionAmount;
private String recordType;
private String payersNit;
private String payersName;
private String payersAccountBank;
private String accountNumberToBeDebited;
private String transactionType;
private String transactionAmount;
private String referenceOne;
private String referenceTwo;
private String expirationDateOrApplicationDate;
private String billedPeriods;
private String cycle;
private String reserved;
private String validationNit;
private String encabezadoTotal;
public DetailRecord() {
lengthReference1 = 30;
lengthReference2 = 30;
lengthPayersNit = 13;
lengthTransactionAmount = 17;
recordType = "6";
payersName = " ";
}
public int getLengthReference1() {
return lengthReference1;
}
public int getLengthReference2() {
return lengthReference2;
}
public int getLengthPayersNit() {
return lengthPayersNit;
}
public int getLengthTransactionAmount() {
return lengthTransactionAmount;
}
public String getRecordType() {
return recordType;
}
public String getPayersName() {
return payersName;
}
public String getPayersAccountBank() {
return payersAccountBank;
}
}
How can i reduce the cyclomatic complexity? Using a builder perhaps or what else can I do? Abstract the class or maybe create a interface?
java design-patterns getter-setter
java design-patterns getter-setter
edited Jan 3 at 13:06
Justin Albano
2,15411034
2,15411034
asked Jan 1 at 4:21
Santiago MolanoSantiago Molano
12
12
3
How using getters/setters count towards cyclomatic complexity?
– user7
Jan 1 at 4:27
it counts each return
– Santiago Molano
Jan 1 at 5:19
1
As user7 said, Cyclomatic complexity mainly depends on branching conditions. I your case it is just a Bean, so I dont think this would count.
– Dush
Jan 1 at 7:57
add a comment |
3
How using getters/setters count towards cyclomatic complexity?
– user7
Jan 1 at 4:27
it counts each return
– Santiago Molano
Jan 1 at 5:19
1
As user7 said, Cyclomatic complexity mainly depends on branching conditions. I your case it is just a Bean, so I dont think this would count.
– Dush
Jan 1 at 7:57
3
3
How using getters/setters count towards cyclomatic complexity?
– user7
Jan 1 at 4:27
How using getters/setters count towards cyclomatic complexity?
– user7
Jan 1 at 4:27
it counts each return
– Santiago Molano
Jan 1 at 5:19
it counts each return
– Santiago Molano
Jan 1 at 5:19
1
1
As user7 said, Cyclomatic complexity mainly depends on branching conditions. I your case it is just a Bean, so I dont think this would count.
– Dush
Jan 1 at 7:57
As user7 said, Cyclomatic complexity mainly depends on branching conditions. I your case it is just a Bean, so I dont think this would count.
– Dush
Jan 1 at 7:57
add a comment |
2 Answers
2
active
oldest
votes
You could use composition, breaking this class into multiple classes and decouple unrelated things. That way, you would have multiple classes, making it easier to maintain and scale, as well as reduce the cyclomatic complexity.
add a comment |
i have reduce the ciclomatyc complexity using factory method,
public class DetailRecord extends StringManager {
private final String RECORD_TYPE = "06";
private String userMainReference;
private String secondaryReferenceOfTheUser;
private static final String BILLER_PERIODS = "00";
private String cycle;
private String mainServiceValue;
private static final String BILLED_SERVICE_CODE_BY_ADDITIONAL_COMPANY = " ";
private static final String ADDITIONAL_SERVICE_VALUE = " ";
private String expirationDate;
private String collectingBankId;
private String targetAccountNumber;
private String billerAccountType;
private String noBillerId;
private String billerName;
private static final String SOURCE_BANK_CODE = " ";
private static final String RESERVED = " ";
private static final int lengthOfUserMainReference = 48;
private static final int lengthOfTheSecondaryReferenceOfTheUser = 30;
private static final int lengthOfTheCycle = 3;
private static final int lengthOfTheMainServiceValue = 14;
private static final int lengthOfTheCollectingBankId = 8;
private static final int lengthOfTargetAccountNumber = 17;
private static final int lengthOfNoBillerId = 10;
private static final int lengthOfBillerName = 22;
public DetailRecord(String userMainReference, String secondaryReferenceOfTheUser, String cycle, String mainServiceValue, String expirationDate, String collectingBankId, String targetAccountNumber, String billerAccountType, String noBillerId, String billerName) {
this.userMainReference = userMainReference;
this.secondaryReferenceOfTheUser = secondaryReferenceOfTheUser;
this.cycle = cycle;
this.mainServiceValue = mainServiceValue;
this.expirationDate = expirationDate;
this.collectingBankId = collectingBankId;
this.targetAccountNumber = targetAccountNumber;
this.billerAccountType = billerAccountType;
this.noBillerId = noBillerId;
this.billerName = billerName;
}
public static DetailRecord createWith(String userMainReference, String secondaryReferenceOfTheUser, String cycle, String mainServiceValue, String expirationDate, String collectingBankId, String targetAccountNumber, String billerAccountType, String noBillerId, String billerName) {
return new DetailRecord(userMainReference, secondaryReferenceOfTheUser, cycle, mainServiceValue, expirationDate, collectingBankId, targetAccountNumber, billerAccountType, noBillerId, billerName);
}
@Override
public String toString() {
return new StringBuilder()
.append(RECORD_TYPE)
.append(fillInWithZerosLeftPad(userMainReference, lengthOfUserMainReference))
.append(fillInWithBlanksLeftPad(secondaryReferenceOfTheUser, lengthOfTheSecondaryReferenceOfTheUser))
.append(BILLER_PERIODS)
.append(fillInWithBlanksLeftPad(cycle, lengthOfTheCycle))
.append(fillInWithZerosLeftPad(mainServiceValue, lengthOfTheMainServiceValue))
.append(BILLED_SERVICE_CODE_BY_ADDITIONAL_COMPANY)
.append(ADDITIONAL_SERVICE_VALUE)
.append(expirationDate)
.append(fillInWithZerosLeftPad(collectingBankId, lengthOfTheCollectingBankId))
.append(fillInWithBlanksLeftPad(targetAccountNumber, lengthOfTargetAccountNumber))
.append(billerAccountType)
.append(fillInWithBlanksLeftPad(noBillerId, lengthOfNoBillerId))
.append(fillInWithBlanksLeftPad(billerName, lengthOfBillerName))
.append(SOURCE_BANK_CODE)
.append(RESERVED).toString();
}
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53992987%2fhow-can-i-reduce-cyclomatic-complexity-from-a-model%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could use composition, breaking this class into multiple classes and decouple unrelated things. That way, you would have multiple classes, making it easier to maintain and scale, as well as reduce the cyclomatic complexity.
add a comment |
You could use composition, breaking this class into multiple classes and decouple unrelated things. That way, you would have multiple classes, making it easier to maintain and scale, as well as reduce the cyclomatic complexity.
add a comment |
You could use composition, breaking this class into multiple classes and decouple unrelated things. That way, you would have multiple classes, making it easier to maintain and scale, as well as reduce the cyclomatic complexity.
You could use composition, breaking this class into multiple classes and decouple unrelated things. That way, you would have multiple classes, making it easier to maintain and scale, as well as reduce the cyclomatic complexity.
answered Jan 1 at 5:58
Anindya DuttaAnindya Dutta
1,56411028
1,56411028
add a comment |
add a comment |
i have reduce the ciclomatyc complexity using factory method,
public class DetailRecord extends StringManager {
private final String RECORD_TYPE = "06";
private String userMainReference;
private String secondaryReferenceOfTheUser;
private static final String BILLER_PERIODS = "00";
private String cycle;
private String mainServiceValue;
private static final String BILLED_SERVICE_CODE_BY_ADDITIONAL_COMPANY = " ";
private static final String ADDITIONAL_SERVICE_VALUE = " ";
private String expirationDate;
private String collectingBankId;
private String targetAccountNumber;
private String billerAccountType;
private String noBillerId;
private String billerName;
private static final String SOURCE_BANK_CODE = " ";
private static final String RESERVED = " ";
private static final int lengthOfUserMainReference = 48;
private static final int lengthOfTheSecondaryReferenceOfTheUser = 30;
private static final int lengthOfTheCycle = 3;
private static final int lengthOfTheMainServiceValue = 14;
private static final int lengthOfTheCollectingBankId = 8;
private static final int lengthOfTargetAccountNumber = 17;
private static final int lengthOfNoBillerId = 10;
private static final int lengthOfBillerName = 22;
public DetailRecord(String userMainReference, String secondaryReferenceOfTheUser, String cycle, String mainServiceValue, String expirationDate, String collectingBankId, String targetAccountNumber, String billerAccountType, String noBillerId, String billerName) {
this.userMainReference = userMainReference;
this.secondaryReferenceOfTheUser = secondaryReferenceOfTheUser;
this.cycle = cycle;
this.mainServiceValue = mainServiceValue;
this.expirationDate = expirationDate;
this.collectingBankId = collectingBankId;
this.targetAccountNumber = targetAccountNumber;
this.billerAccountType = billerAccountType;
this.noBillerId = noBillerId;
this.billerName = billerName;
}
public static DetailRecord createWith(String userMainReference, String secondaryReferenceOfTheUser, String cycle, String mainServiceValue, String expirationDate, String collectingBankId, String targetAccountNumber, String billerAccountType, String noBillerId, String billerName) {
return new DetailRecord(userMainReference, secondaryReferenceOfTheUser, cycle, mainServiceValue, expirationDate, collectingBankId, targetAccountNumber, billerAccountType, noBillerId, billerName);
}
@Override
public String toString() {
return new StringBuilder()
.append(RECORD_TYPE)
.append(fillInWithZerosLeftPad(userMainReference, lengthOfUserMainReference))
.append(fillInWithBlanksLeftPad(secondaryReferenceOfTheUser, lengthOfTheSecondaryReferenceOfTheUser))
.append(BILLER_PERIODS)
.append(fillInWithBlanksLeftPad(cycle, lengthOfTheCycle))
.append(fillInWithZerosLeftPad(mainServiceValue, lengthOfTheMainServiceValue))
.append(BILLED_SERVICE_CODE_BY_ADDITIONAL_COMPANY)
.append(ADDITIONAL_SERVICE_VALUE)
.append(expirationDate)
.append(fillInWithZerosLeftPad(collectingBankId, lengthOfTheCollectingBankId))
.append(fillInWithBlanksLeftPad(targetAccountNumber, lengthOfTargetAccountNumber))
.append(billerAccountType)
.append(fillInWithBlanksLeftPad(noBillerId, lengthOfNoBillerId))
.append(fillInWithBlanksLeftPad(billerName, lengthOfBillerName))
.append(SOURCE_BANK_CODE)
.append(RESERVED).toString();
}
}
add a comment |
i have reduce the ciclomatyc complexity using factory method,
public class DetailRecord extends StringManager {
private final String RECORD_TYPE = "06";
private String userMainReference;
private String secondaryReferenceOfTheUser;
private static final String BILLER_PERIODS = "00";
private String cycle;
private String mainServiceValue;
private static final String BILLED_SERVICE_CODE_BY_ADDITIONAL_COMPANY = " ";
private static final String ADDITIONAL_SERVICE_VALUE = " ";
private String expirationDate;
private String collectingBankId;
private String targetAccountNumber;
private String billerAccountType;
private String noBillerId;
private String billerName;
private static final String SOURCE_BANK_CODE = " ";
private static final String RESERVED = " ";
private static final int lengthOfUserMainReference = 48;
private static final int lengthOfTheSecondaryReferenceOfTheUser = 30;
private static final int lengthOfTheCycle = 3;
private static final int lengthOfTheMainServiceValue = 14;
private static final int lengthOfTheCollectingBankId = 8;
private static final int lengthOfTargetAccountNumber = 17;
private static final int lengthOfNoBillerId = 10;
private static final int lengthOfBillerName = 22;
public DetailRecord(String userMainReference, String secondaryReferenceOfTheUser, String cycle, String mainServiceValue, String expirationDate, String collectingBankId, String targetAccountNumber, String billerAccountType, String noBillerId, String billerName) {
this.userMainReference = userMainReference;
this.secondaryReferenceOfTheUser = secondaryReferenceOfTheUser;
this.cycle = cycle;
this.mainServiceValue = mainServiceValue;
this.expirationDate = expirationDate;
this.collectingBankId = collectingBankId;
this.targetAccountNumber = targetAccountNumber;
this.billerAccountType = billerAccountType;
this.noBillerId = noBillerId;
this.billerName = billerName;
}
public static DetailRecord createWith(String userMainReference, String secondaryReferenceOfTheUser, String cycle, String mainServiceValue, String expirationDate, String collectingBankId, String targetAccountNumber, String billerAccountType, String noBillerId, String billerName) {
return new DetailRecord(userMainReference, secondaryReferenceOfTheUser, cycle, mainServiceValue, expirationDate, collectingBankId, targetAccountNumber, billerAccountType, noBillerId, billerName);
}
@Override
public String toString() {
return new StringBuilder()
.append(RECORD_TYPE)
.append(fillInWithZerosLeftPad(userMainReference, lengthOfUserMainReference))
.append(fillInWithBlanksLeftPad(secondaryReferenceOfTheUser, lengthOfTheSecondaryReferenceOfTheUser))
.append(BILLER_PERIODS)
.append(fillInWithBlanksLeftPad(cycle, lengthOfTheCycle))
.append(fillInWithZerosLeftPad(mainServiceValue, lengthOfTheMainServiceValue))
.append(BILLED_SERVICE_CODE_BY_ADDITIONAL_COMPANY)
.append(ADDITIONAL_SERVICE_VALUE)
.append(expirationDate)
.append(fillInWithZerosLeftPad(collectingBankId, lengthOfTheCollectingBankId))
.append(fillInWithBlanksLeftPad(targetAccountNumber, lengthOfTargetAccountNumber))
.append(billerAccountType)
.append(fillInWithBlanksLeftPad(noBillerId, lengthOfNoBillerId))
.append(fillInWithBlanksLeftPad(billerName, lengthOfBillerName))
.append(SOURCE_BANK_CODE)
.append(RESERVED).toString();
}
}
add a comment |
i have reduce the ciclomatyc complexity using factory method,
public class DetailRecord extends StringManager {
private final String RECORD_TYPE = "06";
private String userMainReference;
private String secondaryReferenceOfTheUser;
private static final String BILLER_PERIODS = "00";
private String cycle;
private String mainServiceValue;
private static final String BILLED_SERVICE_CODE_BY_ADDITIONAL_COMPANY = " ";
private static final String ADDITIONAL_SERVICE_VALUE = " ";
private String expirationDate;
private String collectingBankId;
private String targetAccountNumber;
private String billerAccountType;
private String noBillerId;
private String billerName;
private static final String SOURCE_BANK_CODE = " ";
private static final String RESERVED = " ";
private static final int lengthOfUserMainReference = 48;
private static final int lengthOfTheSecondaryReferenceOfTheUser = 30;
private static final int lengthOfTheCycle = 3;
private static final int lengthOfTheMainServiceValue = 14;
private static final int lengthOfTheCollectingBankId = 8;
private static final int lengthOfTargetAccountNumber = 17;
private static final int lengthOfNoBillerId = 10;
private static final int lengthOfBillerName = 22;
public DetailRecord(String userMainReference, String secondaryReferenceOfTheUser, String cycle, String mainServiceValue, String expirationDate, String collectingBankId, String targetAccountNumber, String billerAccountType, String noBillerId, String billerName) {
this.userMainReference = userMainReference;
this.secondaryReferenceOfTheUser = secondaryReferenceOfTheUser;
this.cycle = cycle;
this.mainServiceValue = mainServiceValue;
this.expirationDate = expirationDate;
this.collectingBankId = collectingBankId;
this.targetAccountNumber = targetAccountNumber;
this.billerAccountType = billerAccountType;
this.noBillerId = noBillerId;
this.billerName = billerName;
}
public static DetailRecord createWith(String userMainReference, String secondaryReferenceOfTheUser, String cycle, String mainServiceValue, String expirationDate, String collectingBankId, String targetAccountNumber, String billerAccountType, String noBillerId, String billerName) {
return new DetailRecord(userMainReference, secondaryReferenceOfTheUser, cycle, mainServiceValue, expirationDate, collectingBankId, targetAccountNumber, billerAccountType, noBillerId, billerName);
}
@Override
public String toString() {
return new StringBuilder()
.append(RECORD_TYPE)
.append(fillInWithZerosLeftPad(userMainReference, lengthOfUserMainReference))
.append(fillInWithBlanksLeftPad(secondaryReferenceOfTheUser, lengthOfTheSecondaryReferenceOfTheUser))
.append(BILLER_PERIODS)
.append(fillInWithBlanksLeftPad(cycle, lengthOfTheCycle))
.append(fillInWithZerosLeftPad(mainServiceValue, lengthOfTheMainServiceValue))
.append(BILLED_SERVICE_CODE_BY_ADDITIONAL_COMPANY)
.append(ADDITIONAL_SERVICE_VALUE)
.append(expirationDate)
.append(fillInWithZerosLeftPad(collectingBankId, lengthOfTheCollectingBankId))
.append(fillInWithBlanksLeftPad(targetAccountNumber, lengthOfTargetAccountNumber))
.append(billerAccountType)
.append(fillInWithBlanksLeftPad(noBillerId, lengthOfNoBillerId))
.append(fillInWithBlanksLeftPad(billerName, lengthOfBillerName))
.append(SOURCE_BANK_CODE)
.append(RESERVED).toString();
}
}
i have reduce the ciclomatyc complexity using factory method,
public class DetailRecord extends StringManager {
private final String RECORD_TYPE = "06";
private String userMainReference;
private String secondaryReferenceOfTheUser;
private static final String BILLER_PERIODS = "00";
private String cycle;
private String mainServiceValue;
private static final String BILLED_SERVICE_CODE_BY_ADDITIONAL_COMPANY = " ";
private static final String ADDITIONAL_SERVICE_VALUE = " ";
private String expirationDate;
private String collectingBankId;
private String targetAccountNumber;
private String billerAccountType;
private String noBillerId;
private String billerName;
private static final String SOURCE_BANK_CODE = " ";
private static final String RESERVED = " ";
private static final int lengthOfUserMainReference = 48;
private static final int lengthOfTheSecondaryReferenceOfTheUser = 30;
private static final int lengthOfTheCycle = 3;
private static final int lengthOfTheMainServiceValue = 14;
private static final int lengthOfTheCollectingBankId = 8;
private static final int lengthOfTargetAccountNumber = 17;
private static final int lengthOfNoBillerId = 10;
private static final int lengthOfBillerName = 22;
public DetailRecord(String userMainReference, String secondaryReferenceOfTheUser, String cycle, String mainServiceValue, String expirationDate, String collectingBankId, String targetAccountNumber, String billerAccountType, String noBillerId, String billerName) {
this.userMainReference = userMainReference;
this.secondaryReferenceOfTheUser = secondaryReferenceOfTheUser;
this.cycle = cycle;
this.mainServiceValue = mainServiceValue;
this.expirationDate = expirationDate;
this.collectingBankId = collectingBankId;
this.targetAccountNumber = targetAccountNumber;
this.billerAccountType = billerAccountType;
this.noBillerId = noBillerId;
this.billerName = billerName;
}
public static DetailRecord createWith(String userMainReference, String secondaryReferenceOfTheUser, String cycle, String mainServiceValue, String expirationDate, String collectingBankId, String targetAccountNumber, String billerAccountType, String noBillerId, String billerName) {
return new DetailRecord(userMainReference, secondaryReferenceOfTheUser, cycle, mainServiceValue, expirationDate, collectingBankId, targetAccountNumber, billerAccountType, noBillerId, billerName);
}
@Override
public String toString() {
return new StringBuilder()
.append(RECORD_TYPE)
.append(fillInWithZerosLeftPad(userMainReference, lengthOfUserMainReference))
.append(fillInWithBlanksLeftPad(secondaryReferenceOfTheUser, lengthOfTheSecondaryReferenceOfTheUser))
.append(BILLER_PERIODS)
.append(fillInWithBlanksLeftPad(cycle, lengthOfTheCycle))
.append(fillInWithZerosLeftPad(mainServiceValue, lengthOfTheMainServiceValue))
.append(BILLED_SERVICE_CODE_BY_ADDITIONAL_COMPANY)
.append(ADDITIONAL_SERVICE_VALUE)
.append(expirationDate)
.append(fillInWithZerosLeftPad(collectingBankId, lengthOfTheCollectingBankId))
.append(fillInWithBlanksLeftPad(targetAccountNumber, lengthOfTargetAccountNumber))
.append(billerAccountType)
.append(fillInWithBlanksLeftPad(noBillerId, lengthOfNoBillerId))
.append(fillInWithBlanksLeftPad(billerName, lengthOfBillerName))
.append(SOURCE_BANK_CODE)
.append(RESERVED).toString();
}
}
answered Jan 19 at 2:25
Santiago MolanoSantiago Molano
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53992987%2fhow-can-i-reduce-cyclomatic-complexity-from-a-model%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
How using getters/setters count towards cyclomatic complexity?
– user7
Jan 1 at 4:27
it counts each return
– Santiago Molano
Jan 1 at 5:19
1
As user7 said, Cyclomatic complexity mainly depends on branching conditions. I your case it is just a Bean, so I dont think this would count.
– Dush
Jan 1 at 7:57