A general model for pattern formation in electrode reactions