Rolf B: Logging in class Diagram Uml Architectur

Beitrag lesen

Hello edy,

if you speak english better than german, then stick to english. This is a german forum, but we always try to help.

Although - your question is likely to polarize, so I wonder if you are sincere or if you try to troll us.

Whatever. Novice class modelers tend to move things that are used "everywhere" into a common "Object" superclass, but in most cases, this is wrong. A superclass describes a relationship "A is a B" - so a Cat Is A Mammal or an Employee Is A Person.

Of course, everything you model Is A Object, but that's purely technical and doesn't create a valid inheritance relation. It's better to use a Logger-Object and pass it to the objects you create.

You can also create a singleton "context" Object that provides access to a Logger-Interface. The important point is: make it replaceable. When you run unit tests, you don't want to write to your regular logging sink.

In most cases, it's NOT right to create a static resource to provide the logger, because then you can't easily provide a dummy logger when you run unit tests

Rolf

--
sumpsi - posui - obstruxi