This is a simple example of code (template) snippets to work with Beans, including the creation, preprocessors, and theming.
For this example I will be creating the Bean through the GUI and locking it in a Feature. This is good for high-paced development, and at least for what I have used Beans for, I haven't had the need to create one programmatically, yet.
Beans turns blocks into an entity, Block Types; which then you can create instances of each block type, have fields, view modes, etc. Just like you would with a content type.