Re: Request for comment on my tiny learning project: dfighterdb (mytree)



On Apr 20, 11:28 am, dfighter <dfigh...@xxxxxxxxxxxx> wrote:
Richard Heathfield wrote:
dfighter said:

Han from China wrote:
dfighter wrote:
dfighterdb (I started it as mytree), is a tiny and simple
console based "database" application I'm writing as a learning
project.
If it's tiny, you may as well post the source code to the group.

Well, well, well. Even a stopped clock is right twice a day.

This has at least two advantages:

(1) Some people are unable or unwilling to check external links
or to unzip archives, so you've already lost their help.

(2) WWW links die all the time, but your posts will have a
relatively permanent existence in various Usenet archives.
There's a chance someone who's writing a similar application
could happen upon this thread years from now and want to know
what everyone in the thread is referring to.

Unfortunately it's not that tiny. It's only relatively tiny (~900
lines).

That's pretty tiny - okay, quite a large tiny, but nevertheless well
within Usenet limits (put LONG in the subject line as a warning to
the modem users amongst us, and you're covered). This isn't IRC.

(1) That's very unfortunate.
(2) You have a point, however I can always choose not to delete it
from the website ;)

Sometimes that isn't within our control. When I moved ISP, I left a
number of pages behind that I can no longer maintain. Worse still,
they're still there, so few people realise that the pages are no
longer maintained.

I hope this won't happen again (not because I won't move ISPs again,
but because I now do my own hosting, with Web forwarding).

ANYWAY - I did actually look through your code. I didn't have time
for a full review, I'm afraid, but before I realised this I did
spot a few minor conformance issues (the one I remember being
leading underscores on identifiers) and a design consideration (as
a matter of robustness you might want to take T** in your
destructors, rather than T*, so that you can set *p to NULL when
you're done).

Thank you Richard for you observations. Since you told me it's ok to
post larger codebases too, I'm posting it now.

------------------------------SOURCECODE--------------------------------------

ui.h:

#ifndef __DBUI__
#define __DBUI__

#define TABLE_OK 0
#define TABLE_ALREADY_EXISTS 1
#define TABLE_ERROR -1

void ui_mainmenu(void);
#endif

tree.h:

#ifndef __MYTREE_H__
#define __MYTREE_H__

#define MAXFIELDNAMELENGTH 100
#define SIGLENGTH 6
#define SIG "DBTBL"

#define FILECORRUPT -1

typedef struct __mytreeinfo__ {
        unsigned char numfields;
        unsigned long numrecords;
        unsigned char *afieldtypes;
        char **afieldnames;

}treeinfo_t;

typedef struct __mytreenode__ {
        struct __mytreenode__ *parent;
        struct __mytreenode__ *left;
        struct __mytreenode__ *right;
        void **field;

}treenode_t;

My suggestion is to put your struct definitions in source files, not
in header files, so as to make them opaque. Any member access and
operations should be provided by functions of the module.

Sebastian

.



Relevant Pages

  • Re: Request for comment on my tiny learning project: dfighterdb (mytree)
    ... you may as well post the source code to the group. ... There's a chance someone who's writing a similar application ... the modem users amongst us, ... When I moved ISP, I left a ...
    (comp.lang.c)
  • [Un] Unangband 0.6.0 final released
    ... is now available for download. ... The source files are available at ... time to the beta release as well as Andrew Sidwell for assisting with debugging ... source code available to help me finish the adoption of the 4GAI code. ...
    (rec.games.roguelike.angband)
  • Re: Debugging
    ... > I do a listing of available source code from within DDD none of these ... all that shows up is the top level source files containing the ... I manually added it with the directory command in gdb. ...
    (comp.lang.fortran)
  • Re: where is reports.vb class
    ... They should be in your client's source code. ... Search for files with those names in the source files you were supplied with. ... > whaka, whaka. ... >> Microsoft MVP ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Still not clear about global functions
    ... > I suppose they can't be done from source files? ... but it's not good to publish source code. ... > I can't see how you can get around having a global function here, ... > say that they are really against the idea of OOP. ...
    (microsoft.public.dotnet.framework.aspnet)