Re: Request for comment on my tiny learning project: dfighterdb (mytree)
- From: s0suk3@xxxxxxxxx
- Date: Mon, 20 Apr 2009 20:31:44 -0700 (PDT)
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 simpleIf it's tiny, you may as well post the source code to the group.
console based "database" application I'm writing as a learning
project.
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
.
- References:
- Request for comment on my tiny learning project: dfighterdb (mytree)
- From: dfighter
- Re: Request for comment on my tiny learning project: dfighterdb (mytree)
- From: dfighter
- Re: Request for comment on my tiny learning project: dfighterdb (mytree)
- From: Richard Heathfield
- [LONG] Re: Request for comment on my tiny learning project: dfighterdb (mytree)
- From: dfighter
- Request for comment on my tiny learning project: dfighterdb (mytree)
- Prev by Date: Re: adapting getline
- Next by Date: Re: similar Perl data structure?
- Previous by thread: Re: Request for comment on my tiny learning project: dfighterdb(mytree)
- Next by thread: Re: [LONG] Re: Request for comment on my tiny learning project: dfighterdb (mytree)
- Index(es):
Relevant Pages
|