android-client icon indicating copy to clipboard operation
android-client copied to clipboard

Some variable names cause misleading, not suitable for clean code

Open karsai1993 opened this issue 7 years ago • 1 comments

Summary: Some variable names cause misleading as their types require different naming conversions. See examples in "What did you see instead? Describe your issue in detail here." section.

Steps to reproduce: 1, Have a look at the code

Expected status: All the variable names should be defined to be able to identify its role in context. They should also be suitable for clean code.

Observed status: Roles of some variables cannot be identified from its name. Some variable names are not suitable for clean code.

What did you see instead? Describe your issue in detail here. There are four kinds of naming conversion problem: 1, Templete as pattern for examples and their possible correction: wrong definition -> good definition Examples: public void showProgressbar(boolean b) -> public void showProgressbar(boolean isNeededToShow) boolean show -> boolean isNeededToShow boolean loadmore -> boolean isNeededToLoadMore boolean paged -> boolean isPaged public LoanAccount getItem(int i) -> public LoanAccount getItem(int position) public long getItemId(int i) -> public long getItemId(int id) void showError(int message) -> void showError(int errormessageId) void showError(int errorMessage) -> void showError(int errorMessageId) void showError(int s) -> showError(int errormessageId) onError(Throwable e) -> onError(Throwable throwableError) public void loadGroups(int groupid) -> public void loadGroups(int groupId) void passScoreCardData(Scorecard scorecard, int surveyid) -> void passScoreCardData(Scorecard scoreCard, int surveyId) showFetchingError(String s) -> showFetchingError(String fetchingErrorMessage); private String fullname -> private String fullName private String firstname -> private String firstName private String middlename -> private String middleName private String lastname -> private String lastName private boolean selected -> private boolean isSelected private boolean repeating -> private boolean isRepeating private boolean active -> private boolean isActive transient Boolean sync -> transient Boolean isSynced public Boolean getSync() {return sync;} -> public Boolean getIsSynced() {return isSynced;} public void setSync(Boolean sync) {this.sync = sync;} -> public void setIsSynced(Boolean isSynced) {this.isSynced = isSynced;} Boolean active -> Boolean isActive public Boolean getActive() {return this.active;} -> public Boolean getIsActive() {return this.isActive;} public Boolean isActive() {return isActive;} public void setActive(Boolean active) {this.active = active;} -> public void setIsActive(Boolean isActive) {this.isActive = isActive;} private Boolean exactMatch = false; -> private Boolean isExactMatch = false;

2, There are a lot of variables (listed below) like Boolean mandantory which should be handled accordingly. Original: @SerializedName("mandatory") Boolean mandatory; public Boolean getMandatory() {return mandatory;} public void setMandatory(Boolean mandatory) {this.mandatory = mandatory;} Improved definition: @SerializedName("isMandatory") Boolean isMandatory; public Boolean getIsMandatory() {return isMandatory;} public void setIsMandatory(Boolean isMandatory) {this.isMandatory = isMandatory;} The following ones should also be handled: @SerializedName("amortizationType") Boolean amortizationType; @SerializedName("interestType") Boolean interestType; @SerializedName("transactionProcessingStrategyId") Boolean transactionProcessingStrategyId; @SerializedName("interestCalculationPeriodType") Boolean interestCalculationPeriodType; @SerializedName("inArrearsTolerance") Boolean inArrearsTolerance; @SerializedName("repaymentEvery") Boolean repaymentEvery; @SerializedName("graceOnPrincipalAndInterestPayment") Boolean graceOnPrincipalAndInterestPayment; @SerializedName("graceOnArrearsAgeing") Boolean graceOnArrearsAgeing; @SerializedName("includeInBorrowerCycle") Boolean includeInBorrowerCycle; @SerializedName("useBorrowerCycle") Boolean useBorrowerCycle; @SerializedName("allowPartialPeriodInterestCalcualtion") Boolean allowPartialPeriodInterestCalcualtion; @SerializedName("canDefineInstallmentAmount") Boolean canDefineInstallmentAmount; @SerializedName("multiDisburseLoan") Boolean multiDisburseLoan; @SerializedName("holdGuaranteeFunds") Boolean holdGuaranteeFunds; @SerializedName("accountMovesOutOfNPAOnlyOnArrearsCompletion") Boolean accountMovesOutOfNPAOnlyOnArrearsCompletion; @SerializedName("penalty") Boolean penalty; @SerializedName("isActive") @Column boolean activeStatus; @Column boolean withdrawalFeeForTransfers; @Column boolean allowOverdraft; @SerializedName("paid") Boolean paid; @SerializedName("waived") Boolean waived; @SerializedName("chargePayable") Boolean chargePayable; @SerializedName("multiDisburseLoan") Boolean multiDisburseLoan; @SerializedName("canDefineInstallmentAmount") Boolean canDefineInstallmentAmount; @SerializedName("canDisburse") Boolean canDisburse; @SerializedName("canUseForTopup") Boolean canUseForTopup; @SerializedName("manuallyReversed") Boolean manuallyReversed; @SerializedName("includeInBorrowerCycle") Boolean includeInBorrowerCycle; @SerializedName("useBorrowerCycle") Boolean useBorrowerCycle; @SerializedName("allowVariableInstallments") Boolean allowVariableInstallments; @SerializedName("canDefineInstallmentAmount") Boolean canDefineInstallmentAmount; @SerializedName("holdGuaranteeFunds") Boolean holdGuaranteeFunds; @SerializedName("accountMovesOutOfNPAOnlyOnArrearsCompletion") Boolean accountMovesOutOfNPAOnlyOnArrearsCompletion; @Expose private Boolean disbursement; @Expose private Boolean repaymentAtDisbursement; @Expose private Boolean repayment; @Expose private Boolean contra; @Expose private Boolean waiveInterest; @Expose private Boolean waiveCharges; @Expose private Boolean accrual; @Expose private Boolean writeOff; @Expose private Boolean recoveryRepayment; @Expose private Boolean initiateTransfer; @Expose private Boolean approveTransfer; @Expose private Boolean withdrawTransfer; @Expose private Boolean rejectTransfer; @Expose private Boolean chargePayment; @Expose private Boolean refund; @SerializedName("reversed") @Column Boolean reversed;

private Boolean allowOverdraft; private Boolean enforceMinRequiredBalance;

3, Following ones should be changed according to the context as in case of them, the type and the name are against each other: private int isSynced; public int getIsSynced() {return isSynced;} public void setIsSynced(int isSynced) {this.isSynced = isSynced;}

private String isPaymentChanged; public String getIsPaymentChanged() {return isPaymentChanged;} public void setIsPaymentChanged(String isPaymentChanged) {this.isPaymentChanged = isPaymentChanged;}

4, Wrong classes definition as plural would be made to be plural QuestionDatas -> QuestionData ResponseDatas -> ResponseData ComponentDatas -> ComponentData

karsai1993 avatar Mar 14 '17 18:03 karsai1993

@ishan1604 What you think.

therajanmaurya avatar Mar 18 '17 11:03 therajanmaurya