Skip to content

Data Clumps #8260

Description

@polipopi

Problema identificado

El método setup() duplica la lógica para inicializar arreglos en Flowable y Observable, utilizando siempre juntos los parámetros times y 777.

Esto representa un caso de Data Clumps, ya que dichos parámetros aparecen agrupados repetidamente sin estar encapsulados en una estructura propia.

Refactor aplicado

Se aplicó:

  • Introduce Parameter Object
  • Extract Method
public record InitSpec(int size, int fillValue) {}

private static Integer[] initArray(InitSpec spec) {
    Integer[] data = new Integer[spec.size()];
    Arrays.fill(data, spec.fillValue());
    return data;
}

public void setup() {
    InitSpec spec = new InitSpec(times, 777);
    Integer[] array = initArray(spec);

    flowable = Flowable.fromArray(array);
    observable = Observable.fromArray(array);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions