Code Monkey home page Code Monkey logo

Comments (8)

robefernandez avatar robefernandez commented on July 17, 2024

Am I the only one with this case? 😅

from dotnet.

simonbrowndotje avatar simonbrowndotje commented on July 17, 2024

Declaring components as interfaces shouldn't be a problem ... but what do you mean by "Component Class -- serves -> Interface Component"?

from dotnet.

robefernandez avatar robefernandez commented on July 17, 2024

Hi Simon, thanks for your response.
There's no problem declaring components as interfaces. The issue that I have is for the components that extends from the interfaces and they are used dynamically.
For example I declare a variable as an interface and it could be different components depending on each implementation of the interface.
I don't know how to show in the diagram that the mentioned variable could have different implementations.
Regards.

from dotnet.

simonbrowndotje avatar simonbrowndotje commented on July 17, 2024

So you have multiple implementations of a component interface?

from dotnet.

robefernandez avatar robefernandez commented on July 17, 2024

Yes, I do.
If I use any hardware device for example, I have an interface to define the methods that I will use in my software but each device have their own SDK so I extend the interface to adapt each SDK to my software. And then I load each device using reflection.

from dotnet.

simonbrowndotje avatar simonbrowndotje commented on July 17, 2024

You may need to write your own component finder strategy implementation in that case, as there's no easy/general way to model that situation I'm afraid. If we forget Structurizr for a minute, how would you draw the component diagram manually on a whiteboard? Would you draw one component per implementation, or a single component that represents all possible implementations? Once you understand this, you can then figure out how to represent this using the client library. One option might be to exclude those components from the component scan, and manually specify them instead. Does that help?

from dotnet.

robefernandez avatar robefernandez commented on July 17, 2024

I would like to show that my variable declared as an interface could have several implementations.
Maybe a new annotation could be created to declare what implemented classes could be that variable.
Something like that:

[UsesComponent("Different behaviour based on the consumed workflow")]
[PossibleComponents(WorkflowOne, WorkflowTwo)]
public IWorkflow CurrentWorkflow { get; private set; }

Where IWorkflow is the interface and WorkflowOne and WorkflowTwo are the classes that extend the interface and could be loaded dynamically.
What do you think?

from dotnet.

simonbrowndotje avatar simonbrowndotje commented on July 17, 2024

Creating your own annotations and a custom component finder strategy is certainly possible, and relatively straightforward. I'm still interested in your thoughts on how you would draw a component diagram (on a whiteboard) to represent this. Also, what tooling are you using to create the diagrams? This might be one of those situations where using a UML class diagram is the best way to show the multiple implementations, rather than the C4 model.

from dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.