Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

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

Open
0pdd opened this issue Aug 11, 2023 · 28 comments
Open

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

0pdd opened this issue Aug 11, 2023 · 28 comments
Labels
bug Something isn't working pdd

Comments

@0pdd
Copy link
Collaborator

0pdd commented Aug 11, 2023

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

* @todo #32:45m/DEV Master is set of states inside XML document.

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.

@0pdd 0pdd added bug Something isn't working pdd labels Aug 11, 2023
@zoeself
Copy link
Collaborator

zoeself commented Aug 11, 2023

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

@0pdd
Copy link
Collaborator Author

0pdd commented Aug 11, 2023

@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
Copy link
Collaborator

zoeself commented Aug 11, 2023

@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
Copy link
Collaborator Author

0pdd commented Aug 15, 2023

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

@zoeself
Copy link
Collaborator

zoeself commented Aug 16, 2023

@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
Copy link
Member

@zoeself deregister

@zoeself
Copy link
Collaborator

zoeself commented Aug 16, 2023

@zoeself deregister

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

@h1alexbel
Copy link
Member

h1alexbel commented Aug 17, 2023

@l3r8yJ WDYT?

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

@l3r8yJ
Copy link
Member

l3r8yJ commented Aug 17, 2023

@h1alexbel what is "1"?

@h1alexbel
Copy link
Member

@l3r8yJ State ID

@l3r8yJ
Copy link
Member

l3r8yJ commented Aug 17, 2023

@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
Copy link
Member

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

@l3r8yJ
Copy link
Member

l3r8yJ commented Aug 17, 2023

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

@h1alexbel
Copy link
Member

@l3r8yJ what you are suggesting then?

@l3r8yJ
Copy link
Member

l3r8yJ commented Aug 17, 2023

@h1alexbel smth like

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

where

  • cmig – directory with migration
  • master – xml file
  • cassandra – cassandra connection (or whatever is this)
  • #migrate – start of migration

wdyt?

@h1alexbel
Copy link
Member

@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
Copy link
Member

l3r8yJ commented Aug 18, 2023

@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
Copy link
Member

h1alexbel commented Aug 18, 2023

@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
Copy link
Member

l3r8yJ commented Aug 18, 2023

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

@h1alexbel
Copy link
Member

@l3r8yJ to get last sha

@l3r8yJ
Copy link
Member

l3r8yJ commented Aug 18, 2023

@h1alexbel can we wait couple of week for this?

@h1alexbel
Copy link
Member

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

@l3r8yJ
Copy link
Member

l3r8yJ commented Aug 18, 2023

@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
Copy link
Member

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

@l3r8yJ
Copy link
Member

l3r8yJ commented Aug 18, 2023

@h1alexbel yeah, I was thinking the same thing

@h1alexbel
Copy link
Member

h1alexbel commented Aug 18, 2023

@l3r8yJ created #60

@0pdd
Copy link
Collaborator Author

0pdd commented Aug 22, 2023

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

@0pdd
Copy link
Collaborator Author

0pdd commented Jan 26, 2024

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working pdd
Projects
None yet
Development

No branches or pull requests

4 participants