eo-cqrs / cmig

Apache Cassandra Schema Migration
MIT License
5 stars 2 forks source link

Master.java:33: Master is set of states inside XML document. #36

Open 0pdd opened 1 year ago

0pdd commented 1 year ago

The puzzle 32-ae85e224 from #32 has to be resolved:

https://github.com/eo-cqrs/cmig/blob/8d1946dee42e847762438f4f56608f81f3ab8d2e/src/main/java/io/github/eocqrs/cmig/Master.java#L33-L33

The puzzle was created by @rultor on 11-Aug-23.

Estimate: 45 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be \"done\" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

zoeself commented 1 year ago

@0pdd thank you for reporting this. I'll assign someone to take care of it soon.

0pdd commented 1 year ago

@0pdd thank you for reporting this. I'll assign someone to take care of it soon.

I see you're talking to me, but I can't reply since I'm not a chat bot.

zoeself commented 1 year ago

@l3r8yJ this is your task now, please go ahead. Deadline (when this ticket should be closed) is 2023-08-21T10:29:18.479270.

Estimation here is 60 minutes, that's how much you will be paid.

Remember, you don't have to solve everything in this ticket - you can solve it partially and leave todo markers in the code, which will become future tasks.

If you have any questions don't ask me, I'm not a technical person. Open new tickets instead.

If you don't have time or simply don't want to work on this, you can always resign.

0pdd commented 1 year ago

@0pdd 2 puzzles #47, #48 are still not solved.

zoeself commented 1 year ago

@l3r8yJ Don't forget to close this ticket before the deadline (2023-08-21T10:29:18). You are past the first half of the allowed period.

h1alexbel commented 1 year ago

@zoeself deregister

zoeself commented 1 year ago

@zoeself deregister

@h1alexbel ok, I've removed this task from scope. I'm not managing it anymore.

h1alexbel commented 1 year ago

@l3r8yJ WDYT?

new Master(
      new ListOf<>(
        new XmlState(
          new XMLDocument(
            new ResourceOf("cmig/master.xml").stream()
          ),
          "1",
          "cmig"
        )
      ),
      cassandra
);
l3r8yJ commented 1 year ago

@h1alexbel what is "1"?

h1alexbel commented 1 year ago

@l3r8yJ State ID

l3r8yJ commented 1 year ago

@h1alexbel Why do we need a state id at a time when we have an entire xml file? Or am I not understanding what it's for?

h1alexbel commented 1 year ago

@l3r8yJ Master is a set of States, while state is denoted by ID

l3r8yJ commented 1 year ago

@h1alexbel I think passing id as a parameter is not the best idea, it would make this design not flexible enough, wdyt?

h1alexbel commented 1 year ago

@l3r8yJ what you are suggesting then?

l3r8yJ commented 1 year ago

@h1alexbel smth like

new Master(
  new State(
    cmig,
    master
  ),
  cassandra
).migrate()

where

wdyt?

h1alexbel commented 1 year ago

@l3r8yJ looks interesting, but in this example, master consists of only one state, I think that master is a list of states on which it is built. Also, State is identified by ID

I suggest the following design:

new Master(new States(xml).value()), cassandra).migrate();

WDYT?

l3r8yJ commented 1 year ago

@h1alexbel master encapsulates a state that contains state changes - so it's not just one state. I don't think we need to bind us to ctor parameters with lists of states and such

Also id as a parameter looks bad to me - since we are not telling the object what xml we want to get the state for the database from, we are saying here's an id, here's something else, do the data conversion for me and give back the data

Also if you pass #value of any Scalar to ctor, you lose the sense. The call is instantaneous, not delayed

wdyt?

h1alexbel commented 1 year ago

@l3r8yJ agree with you, let's try to design Master.java in the following way:

@Override
  public String value() {
    final List<String> shas = new ListOf<>();
    new Ids(this.self)
      .value()
      .forEach(id -> {
        final String author = new Author(this.self, id)
          .asString();
        // persist author, id, and sha of change state to the cassandra table
        final String sha = new Sha(
          id, this.self.toString(), this.cmig
        ).asString();
        shas.add(sha);
        new Names(this.self, id)
          .value()
          .forEach(
            name -> new InFile(
              this.cassandra, name
            ).apply()
          );
      });
    return shas.get(shas.size() - 1);
  }

Master encapsulates only: XML named self, CMIG dir and Cassandra connection

WDYT?

l3r8yJ commented 1 year ago

@h1alexbel why we're passing shas.size() - 1 at return statement?

h1alexbel commented 1 year ago

@l3r8yJ to get last sha

l3r8yJ commented 1 year ago

@h1alexbel can we wait couple of week for [this](https://download.java.net/java/early_access/jdk21/docs//api/java.base/java/util/List.html#getLast())?

h1alexbel commented 1 year ago

@l3r8yJ we can refactor this later, but now Its OK to use shas.get(shas.size - 1)

l3r8yJ commented 1 year ago

@h1alexbel Also I think cmig is not the best name for a directory, I suggest using something like dir or cmigDir, or cdir, wdyt?

h1alexbel commented 1 year ago

@l3r8yJ maybe just remove this variable? and it will be cmig by default

l3r8yJ commented 1 year ago

@h1alexbel yeah, I was thinking the same thing

h1alexbel commented 1 year ago

@l3r8yJ created https://github.com/eo-cqrs/cmig/issues/60

0pdd commented 1 year ago

@0pdd 2 puzzles #64, #65 are still not solved; solved: #47, #48.

0pdd commented 8 months ago

@0pdd 2 puzzles #64, #98 are still not solved; solved: #47, #48, #65.