On Tuesday, 4 July 2017 00:04:22 UTC+3, peter koch wrote:
>
> Currently, I have chosen to use three files to represent the class:
> complex.hpp, (the struct) complex_tio.hpp (std::stream functions
> including parsing) and complex_gui.hpp (includes gui-code). This is not
> a bad solution, I think, but I would like to also hear YOUR opinion. ;-)
Your "complex" sounds like something whose nature is entirely undisclosed
so you seem to hope that there is silver bullet that covers everything?
There are no silver bullet solutions so do how you please, but I can sure
tell how I organize those.
When I need to stream objects "Whatever" to/from somewhere then I typically
make those constructible from and convertible to streamable format/document
class that I use in project, for example JSON. That capability means 2
functions to declare so I would likely declare those in "Whatever.h".
Same we can say about streaming it directly (have operator<< for ostream
and operator>> for istream). Your situation may be different ... or why
to have separate header for 2 function declarations?
About GUI however I consider every view or widget as separate class and
see those quite non-tightly related to each other and to data class
they represent.
For example if there is "list item", "table cell", "tool tip"
and "edit dialog" that represent "Whatever" in one or other part of GUI
then I would most likely have separate header ("WhateverListItem.h",
"WhateverTableCell.h", "WhateverToolTip.h" and "WhateverEditDialog.h") for
each of those and possibly in separate directories (and even modules)
from "Whatever.h" and each other. Again your situation may be different
and even GUI concept may be different, how can I know.