Skip to content

Filter from/to class #89

Closed
Closed

Description

@jose-ba

Hi, I have an idea and I would like to know if it could be something interesting for the project. In very large applications, although php-class-diagram works correctly, you get diagrams that are difficult to navigate (too many arrows and classes). My idea is to add 2 more options: "--from-class" and "--to-class", which would filter only the classes referenced from/to a specific class, up to "--depth" levels. For example:

php-class-diagram --from="InvoiceGenerator" --depth=2 app

I have a working code draft but before refactoring it and writing tests I would like to know if it is worth it.

Thank you very much

Activity

  1. smeghead commented on Nov 30, 2024

    @smeghead
    Owner

    The idea of filtering classes and outputting class diagrams by specifying the class to be investigated is very interesting.
    Do the two options from and to change which classes are filtered depending on the direction of dependency?
    It would be great if you could provide a PR.

  2. jose-ba commented on Nov 30, 2024

    @jose-ba
    ContributorAuthor

    Yes, that's the idea. For example, if I'm going to refactor a service class, I want to see a diagram of all the classes that depend on it (and the ones that depend on those up to --depth levels). This way, I can see all the classes that should be considered during a refactor (tests are a better way, but in some legacy projects tests are not available). That would be an use case for the --to-class filter.

    Or maybe, I have a class that has many dependencies and I want to split it for better maintainability. Then, you could use the --from-class filter to see a "tree" of dependencies and detect potential points for splitting, or redundancies, cyclic dependencies and so on.

    I think that it can be useful for @pmaasz, who opened this PR: #76 It's similar to what he wants I think.

    I will create a PR when I have time to refactor and test the code I have a little bit, because now it's just a draft (although it works, but options are hardcoded for example). I think that I can have it ready next week, or at least a draft that doesn't embarrass me 😂

    Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions