Skip to content

Enhance Code Maintainability: Replace Hardcoded Value #41

Open
@arkaprovob

Description

@arkaprovob

It's a generic issue please ally it wherever it is applicable, a few examples are given below

Description:
In the existing code, we have a hardcoded value "10" used for retry attempts. To improve code maintainability, we should replace this value read it from a property.
Similarly for the second example use a constant class (do-not create a new if it exists) and read the value from it

Example Code details

class name:

src/main/java/io/spaship/operator/service/k8s/Operator.java

existing code 1

.onFailure()
                .retry()
                .withBackOff(Duration.ofSeconds(1), Duration.ofSeconds(2))
                .atMost(10)

existing code 2

public ConfigMap updateConfigMap(Environment environment, Object syncConfig) {

        var configMapName = "sidecar-config-"

Benefits:

  • Enhanced code maintainability.
  • Improved flexibility in handling retry attempts.

Implementation:

  1. Replace the hardcoded value "10" with property reading .
  2. Replace the hardcoded value "sidecar-config-" with a constant .

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions