The way Stack Exchange works is that volunteers get reputation, and when a user gets 3000 reputation they can vote to close questions. These moderators are different to elected moderators, who have diamonds next to their names.
Your question was deemed to violate the following rule by 3-5 users.
Authorship of code: Since Code Review is a community where programmers improve their skills through peer review, we require that the code be posted by an author or maintainer of the code, that the code be embedded directly, and that the poster know why the code is written the way it is.
This one rule actually has three independent but linked rules within it:
-
we require that the code be posted by an author or maintainer of the code
In this case it is debatable who the author is. However you are a maintainer.
In this situation the closers may have assumed you were neither; instead you just took the code from the book.
-
that the code be embedded directly
You have included the code. It is not this reason.
-
the poster know why the code is written the way it is
Some closers may have thought you were asking how the code works. A segment of your question can read as a if you're trying to circumvent the rules.
Does the code below program correctly to interfaces, encapsulate changeable behavior, and employ composition in a reasonable manner?
If the code does work as intended, the interfaces, etc, are correct then we would answer the question with "yes". But it doesn't stop there; since we're just random people on the internet we should provide proof that we are correct. And so we would be explaining how or why the code is correctly applying interfaces, etc.
So from my perspective I can see potentially two reasons to close your question for this reason. But lets look at another close reason too, as some may have voted to close for this too.
Missing Review Context: Code Review requires concrete code from a project, with enough code and / or context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site.
Linking to:
If your code was deemed to be example code, too hypothetical to be meaningfully reviewed, then we need you to provide concrete details.
Your code doesn't really do much. It creates two objects which in some convoluted way add "I'm flying" and "not flying" to the page. I can see people voting to close your question for this reason.
-
generic best practices are outside the scope of this site.
Your question could also be thought of a generic best practice. As all you've implemented is a design pattern.
So to summarize, you post has as far as I can see three potential problems:
- It's not clear on if you're an author or maintainer.
- It may look like you're trying to circumvent our rules.
- Your post looks like example code / generic best practice.
In my opinion, your post was:
At the least, closed for the wrong reason.
I've read the first chapter, and whilst I can see similarities, the code is your own. I also think it's rude of us to assume that you're trying to circumvent the rules.
I don't think your question is off-topic for MRC either.
I'm used to a higher code density, and your code gives off a hint that it's example code. But I do think the question is answerable, there's enough context to answer this.