Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor finding leafs #45

Open
larshp opened this issue Feb 13, 2018 · 1 comment
Open

refactor finding leafs #45

larshp opened this issue Feb 13, 2018 · 1 comment

Comments

@larshp
Copy link
Owner

larshp commented Feb 13, 2018

much of the code in the following 2 methods are identical

  public getDefinitions(): string {
    let g = new Graph<Class>();

    this.classes.forEach((c) => {
      g.addNode(c.getName(), c);
      c.getDependencies().forEach((d) => { g.addEdge(c.getName(), d); } );
    });

    let result = "";
    while (g.countNodes() > 0) {
      let leaf = g.popLeaf();
      result = result + leaf.getDefinition() + "\n";
    }

    return result;
  }

  public getExceptions(): string {
    let g = new Graph<Class>();

    this.exceptions.forEach((c) => {
      g.addNode(c.getName(), c);
      c.getDependencies().forEach((d) => { g.addEdge(c.getName(), d); } );
    });

    let result = "";
    while (g.countNodes() > 0) {
      let leaf = g.popLeaf();
      result = result + leaf.getDefinition() + "\n" + leaf.getImplementation() + "\n";
    }

    return result;
  }
@larshp
Copy link
Owner Author

larshp commented Jun 11, 2018

plus interfaces (in a bit)

larshp added a commit that referenced this issue Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant