The ratio of positive to negative emotions that predicts flourishing is about 3 to 1. Above that ratio, people tend to flourish; below it, they tend to languish.
The best way to write a program is to write it.