You CAN code them if you want to, but as we're talking about a component of the UI system which is inherently visual in nature, it is FAR simpler to use the editor which allows you to see the changes you are making.
Also IN GENERAL, styles do not require updating at runtime in this fashion. You could instead quickly create your styleboxes in advance in the editor, save them as resources and switch to them as required. I would go so far as to say that 'that is the point' of this resource, to mitigate the need to type it all out in code....
Even the answer you've quoted states "In fact, I don't know why are you trying to do this from code."
What I think is more useful for the OP is the YouTube link in this link that shows how StyleBoxTextures are used in the editor: