Why I ask
In my work to improve questions by editing I often stumble over people who ask questions with code snippets in them. This by itself isn't a problem, since code snippets are a valid formatting option.
But I feel like code snippets are well over- and misused.
My understanding of what code snippets are supposed to be for
Code snippets, in my understanding, are supposed to be independent blocks of code or scripts that could run by themselves.
What bothers me is that they are often used in a manner of, what I understand, code samples are for.
To format dependent classes or other samples that would require context in order to be productive.
The question(s)
Am I wrong with my assumption about the misuse of code snippets?
Where can I find a clarification about how to treat these cases and what is the encouraged standard of how I should personally use code snippets or edit them in related questions?
This seemed like a question that should have an answer, but I was unable to find one.
Demo: