[ale] [semi-OT] Recommended C programming book?

Christopher Fowler cfowler at outpostsentinel.com
Fri Aug 8 08:39:04 EDT 2003


I was not stating that mod programming + OOP was the same thing.  I was
just giving an example of a possible modular technique.

Here is one exmaple of the windows
handle crap that I've used in Linux.

typedef struct __userdata {
	char *name;
	char *address;
	/* More stuff */
} _USERDATA;

typedef int USERHANDLE;


/* inside the API */
int ptr2handle(_USERDATA *ptr) {
	return (int)_USERDATA;
}

int handle2ptr(USERHANDLE) {
	return (_USERDATA *)USERHANDLE);
}


This is just a layer of abstration to the application programmer.
You can then have many functions for this data.

setUserName(USERHANDLE u, const char *name) {
}

This is one possible method.  I've found myself creating much
code doing that since everything has to be treated like object.


In another example I've replaced libc's getpwnam() with my version
of getpwnam() in that case I've consolidated all remote authentication
protocls into getpwnam().  SSH automatically supports radius when using
the new version.  If I see my function start to get big I look at the
possibilites of breaking code up into smaller functions.  I guess the 
whole purpose is to keep it simple and manageable.
On Fri, Aug 08, 2003 at 08:19:36AM -0400, Geoffrey wrote:
> Christopher Fowler wrote:
> >I'm not sure what to tell you about a book that teaches modular
> >programming.  Normally that is reserved for OOP programmers in 
> >C++.
> 
> What?  I was writing modular code long before OOP was the buzz word. 
> Although you can write modular code while using OOP techniques, it's not 
> entirely necessary.  Further, C lends itself to modular programming, 
> without the weight of C++.
> 
> Modular programming is little more than breaking the code down into 
> routines based on the purpose of the code.
> 
> -- 
> Until later: Geoffrey		esoteric at 3times25.net
> 
> The latest, most widespread virus?  Microsoft end user agreement.
> Think about it...
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list