iluwatar / java-design-patterns

Design patterns implemented in Java
https://java-design-patterns.com
Other
89.37k stars 26.43k forks source link

Hexagonal architecture pattern is wrong implemented #790

Closed earroyoron closed 4 years ago

earroyoron commented 6 years ago

Not sure, really

can the model have dependencies of repository classes?

com.iluwatar.hexagonal.domain.LotteryService has a dependency on LotteryTicketRepository

iluwatar commented 6 years ago

Yes, it can. LotteryTicketRepository is one of the driven ports. See for example the slides 10-11 on this presentation https://www.slideshare.net/fabricioepa/hexagonal-architecture-for-java-applications

andrievsky commented 6 years ago
public String getNumbersAsString() {
    List<Integer> list = new ArrayList<>();
    list.addAll(numbers);
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < NUM_NUMBERS; i++) {
      builder.append(list.get(i));
      if (i < NUM_NUMBERS - 1) {
        builder.append(",");
      }
    }
    return builder.toString();
  }

Why are you instantiating a list if you could iterate over the numbers HashSet?

iluwatar commented 6 years ago

@andrievsky please help us improve and create a pull request

andrievsky commented 6 years ago

@iluwatar https://github.com/iluwatar/java-design-patterns/pull/793