[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

Application design

maverik

11/15/2008 11:13:00 AM

Hi all.

I'm writting some kind of text processing application (in C++). It has
about 20 classes. Of course, it also has some settings (such as text
color, text size, text family, etc). This settings is represented as
class with static members, like this:

Settings.h

class Settings {
...
static std::string TextFamily;
static int TextSize;
static std::string TextColor;
... // Many other options (about 100)
};

So, other classes use this class:

MyAnotherClass.cpp

voif foo() {
if(Settings.TextSize == 12) { ... }
...
};

My questions:
Is this bad design?
What advantages or disadvantages it has?
Can you suggest me how to organize settings in better way?

Thanks.
2 Answers

Pete Becker

11/15/2008 12:45:00 PM

0

On 2008-11-15 06:12:46 -0500, maverik <maverik.mail@gmail.com> said:

>
> My questions:
> Is this bad design?
> What advantages or disadvantages it has?
> Can you suggest me how to organize settings in better way?
>

Design is about specifying how your code will meet its requirements. So
desgin depends on knowing what the requirements are. Without a
statement of requirements it's not possible to evaluate a proposed
design.

"I'm going on vacation. Should I fly or drive?"

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

mail.dsp

11/17/2008 6:27:00 AM

0

On Nov 15, 4:12 pm, maverik <maverik.m...@gmail.com> wrote:
> Hi all.
>
> I'm writting some kind of text processing application (in C++). It has
> about 20 classes. Of course, it also has some settings (such as text
> color, text size, text family, etc). This settings is represented as
> class with static members, like this:
>
> Settings.h
>
> class Settings {
> ...
> static std::string TextFamily;
> static int TextSize;
> static std::string TextColor;
> ... // Many other options (about 100)
>
> };
>
> So, other classes use this class:
>
> MyAnotherClass.cpp
>
> voif foo() {
> if(Settings.TextSize == 12) { ... }
> ...
>
> };
>
> My questions:
> Is this bad design?
> What advantages or disadvantages it has?
> Can you suggest me how to organize settings in better way?
>
> Thanks.

Go and study some OO design pattern books and use some design patterns
like Flyweight etc. It will give you a wide thought.

--
Daya