Open source software (OSS), and open innovation in general, has received increasing attention from both researchers and practitioners. Based on recent literature on social preference from behavior economics, we propose a finite-horizon dynamic model to study the interactions between OSS developers who are either purely self-interested or conditional cooperators. We find that selfinterested developers who are predicted to free ride under conventional analysis may contribute to a public good, and the existence of purely these developers may, under certain conditions, even benefit the provision of a public good. We further analyze how code architecture affects OSS development outcome and propose that a higher level of code modularity leads to more code contributions overall, due to the strategic behavior of self-interested developers. However, a right mix of the two types of developers plays a critical role for modular design to make an impact. The findings bear important theoretical as well as practical implications and provide guidelines for OSS development and the collective innovation in general.