Sequence Diagram with lifeline of type not modeled in class diagram
I'm currently architecting a design for an application that communicates with an inventory system. I don't need to design a class in my class diagram for this inventory system, but a class has to communicate with that inventory system in a sequence diagram. Can I simply model a开发者_Python百科 lifeline for that inventory system without having modeled it in my class diagram?
My short answer is yes, you can include something in a sequence diagram which doesn't appear in any class diagrams.
My long answer is: making UML diagrams is not modeling, it's a way of illustrating how you plan to model; it's a tool for communicating ideas. A comprehensive, complete set of UML diagrams probably won't translate into a working system which meets your customer's needs, because while the system is being built your customer is very likely to change their mind about what they want, and you're very likely to discover things you didn't know up front which force some of your carefully-diagrammed plans to change.
With this in mind, I use UML only as a tool to get an idea across to a particular audience at a particular time. As such, I consider everything which isn't vital to illuminating a particular concept or part of the system I'm looking at at the time as irrelevant. This includes whether my UML diagram covers every part of the system, whether every entity in a sequence diagram has a corresponding symbol in a class diagram, etc. I'd say the only measure of whether a UML diagram is 'correct' is if it helps illustrate the part of the model you intend - if it does don't spend any time worrying about the details.
精彩评论