Class Design in C++ program -


i'm working on little project in c++. i'm new c++/programming , wanted ask how classes should designed.

to specific: want write little program chatting. simple communication between 2 programs/computers. want use class design because, although small project (just sake of learning), want designed , extensible.

my program should have 5 classes (handlers etc, updater , app - main class program).

i'll give few examples of ideas have how design 1 part of program. first part should connection part (handled connection). task build connection between 2 programs. set local files, hold information print, , connect 'server' file. later in program there should access file_handler class can edit/read local file , read/request write 'server' file. (how it's gonna figured out, long not necessary i'd keep system ;) ). let's ideas have:

idea 1

app creates instance of connection set connection.

connection creates instance of file_handler set files (in case file_hanlder hold paths static variables) , destroy instance because no longer needed connection.

another class (instance held app) creats own instance of file_hanlder later , work files since variable path static.

idea 2

app creates instance of connection , file_handler (lets call them con , fil).

to set connection, fil passed per reference con set variable paths files , create files etc. .

for working files later, app pass around fil manage file handling other classes would, example, update chat etc.

that require lot of classes have constructor or (a) function(s) needs have file_handler parameter , same variable passed around lot of times.

idea 3

the last idea have connection, file_handler , other classes created general without or near 0 relation other classes.

app creates lot of functions (or 'subclasses') work these classes working frameworks developed independently , could, theoraticly, used in program without problems.


which solution think best? or there solution have me better?

please let me know, i'd appreciate help


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -