Hi,
It doesn't have much to do with programming, its a database parameter.
Before tuning the database make sure your programs use proper indexes, most performance problems are caused by programs and not by improper database tuning.
The -B parameter is (still) a static parameter which you can only set before startup of your database.
There are lots of articles about tuning -B. Good starting point is to make -B as big as ~10% of your database size (YMMV). The units of -B are expressed in dbblocks (So -B of 1024 with an 8K blocksize database acounts for a buffer pool size of 8MB. The goal is to get a high enough buffer hit percentage. (Should be 95% and up and can be monitored with tools like promon or protop
http://www.greenfieldtech.com/downloads/downloads.shtml).
There is lots more to tell about database tuning, look around here and at the peg for more threads on this.
A good starting point aswell are the top 10 performance tuning tips from Gus to tune the database, this is in the progress KB --> P19806.
HTH,
Casper.