开发者

Representing main() in a class diagram

I'm constructing a simple class diagram for a class assignment and I was wondering how I 开发者_JAVA百科should go about incorporating functions defined and declared in main() (it's for a C++ project) into it. These functions don't fit into any of the classes that I have, and since there aren't any variables that accompany them, it seems pointless to create a control class containing only a few functions with no data. Aside from keeping things neat, I'm concerned about it from a code generation point of view - if I simply create a class called main(), I'll get only called just that, rather than the functions being declared within the main() function.

FWIW, I'm using Enterprise Architect to model the code.


class diagram doesn't need to depict every detail. C++ is a multiparadigm language, so not everything is an object. you need to show only those details that can be well represented on class diagram and that will help to understand the system better. your functions can be represented on control flow diagram or even not represented at all if they aren't so important.


It's not as pointless as you may think -- that's why languages such as Java mandate that everything goes into a class. If you're following a strict OOP design, put everything into classes and just have your main function instantiate your main application class. For the kind of functions that you describe, you could make them static methods of one or more "helper" or "utility" classes.


The aim of modeling is "understanding" complex problems and share this undestanding with others to solve difficult problems.

In that situation, UML does not seem to help you... So be pragmatic. Use other notations( may be flow chart...)... Who will use your model? If there is no specific answer, do not model anyting. If you has concrete answer, ask yourself how can i help model users? What they expect from me...

If uml does not fit your problem do not use it...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜