Re: The Mark of a Serious programmer.
From: Dan Bloomquist (EXTRApublic21_at_lakeweb.com)
Date: 10/11/04
- Next message: Dave Cook: "Re: Need Advise"
- Previous message: Grant Edwards: "Re: Are there any GUI CVS repository browsers?"
- In reply to: Jeff Relf: "The Mark of a Serious programmer."
- Next in thread: Gregory L. Hansen: "Re: The Mark of a Serious programmer."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 11 Oct 2004 00:12:50 GMT
Jeff Relf wrote:
>
> Macros make the code look a Thousand times better,
> it simplifies the source code and reduces complexity.
Macros may be ok for addressing portability issues. But, no, they do not
reduce complexity when used generally in the language.
>
> Use #define... You Idiot !
I like Mans' answer.
>
> As an example of how macros clarify source code,
> take a look at this code which
> extracts a server name from an article's Path line:
> ( taken from X.CPP http://www.Cotse.NET/users/jeffrelf/X.CPP )
>
> // XHd() sets P ( char * ) to the raw Path line
> // and B to a free buffer.
> // Path is one of the XHdr commands that I used:
> // enum { XOver, Path, User_Agent, X_Newsreader, H_Cnt };
Where is this documentation in the code you posted? I was going to point
out how to simplify _and_ make readable the following code using
objects. But after looking a little I realized just how hard it is to
make sense of your implementation. If you are going to handle strings,
USE THE TOOLS PROVIDED! There is never a good reason to memmove strings.
You want a set of troll objects?
class CTroll
{
std::string strName;
std::string strDomain;
std::string strWhatever;
};
Use names that human readable. LnP DN B E are meaningless!
USE THE TOOLS PROVIDED! I have no idea where your containers is. You
must because if you don't return the memory you've taken or you'll have
a memory leak. So, if you want a set of trolls:
typedef std::vector<CTrolls> TROLL_SET;
In a given scoop you can create a container full of trolls and never
have to concern yourself with memory management:
{
TROLL_SET theTrolls;
for( ; /*add trolls to container till done*/; )
{
CTroll aTroll;
aTroll.strName= whatever( ... );
...
theTrolls.push_back( aTroll );
}
//Do whatever with your set of trolls, theTrolls.
}
//Out of scope, the container and all the trolls
//will self destruct, you don't have to worry about it.
Best, Dan.
-- http://lakeweb.net http://ReserveAnalyst.com No EXTRA stuff for email.
- Next message: Dave Cook: "Re: Need Advise"
- Previous message: Grant Edwards: "Re: Are there any GUI CVS repository browsers?"
- In reply to: Jeff Relf: "The Mark of a Serious programmer."
- Next in thread: Gregory L. Hansen: "Re: The Mark of a Serious programmer."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|