Crash-oriented iterative development
An introductive look at a common pattern in iterative software development processes, particularly when building systems.
Here’s an excerpt from a recent codebase of mine that showcases what I call crash-oriented iterative development:
#include <event.h>
#include <evhttp.h>
#include <uni/log.h>
#define CHECKORDIE(_expr) do{if(_expr){}else{uni_perror( \
"Expression failed: " #_expr);uni_die( );}}while(0)
struct event_base * main_event( void );
struct evbuffer * main_evbuffer( void );
struct evhttp * main_evhttp( struct event_base * );
void route_root( struct evhttp_request *, void * );
int main( int ac, char * av[] )
{
struct event_base * const evbase = main_event( );
struct evbuffer * const evbuf = main_evbuffer( );
struct evhttp * const server = main_evhttp( evbase );
int r;
evhttp_set_cb( server, "/", route_root, (void *)evbuf );
r = evhttp_bind_socket( server, addr, port );
CHECKORDIE( r == 0 );
uni_print( "Done with setup. Listening..." );
/* this is the mainloop */
event_base_dispatch( evbase );
/* do cleanup */
evhttp_free( server );
event_base_free( evbase );
return 0;
}
Can you spot where the crashes might happen? Well, I guess uni_die()
might give it away – users of Hinterlib know that on common operating systems, it resolves to calling the POSIX abort()
function. If the post-conditions don’t hold as needed (this is known through relevant API documents), the program crashes.
So why do we do this? Well for one thing, this program is far from complete. We still have a lot more code to write, and in order to maintain the motivation needed to do so we need to use iterative development. This is a classic tried-and-true approach to software development – you might have seen it meted out before in the form of milestones or projects in all kinds of software companies. Some take it a step further using ‘agile’ methodologies and make these into sprints, but we don’t do that here.
Keep reading with a 7-day free trial
Subscribe to Nichstack to keep reading this post and get 7 days of free access to the full post archives.