I am about to upload a fairly large project of mine, a very flexible component-entity-system. More precisely it's a framework for a CES. It consists of 22 files, ~1000 lines of code and 20000 characters.

My problem is that in order to demonstrate what the framework does, I have 2 base component types (input, graphics) and 2 types of entities included in the framework. This is basically example code, unlike the framework itself. The base components have empty implementation too. However if I omitted these "examples" the usage and usefulness of the framework would be rather inconvenient to figure out. So I have empty implementation of base components and components specific to the particular entities (deriving from base components), because these classes' pure existence gives meaning to the framework's capabilities. Although having this kind of empty implementation is pretty much like having pseudo-code (even if everything compiles) and these tiny segments of code are not open to being reviewed therefore.

As an example here is an example component of an entity, where InputComp<> is the abstract base class for all InputComp< 'entity name' > classes.

class Comp<CompBase::INPUT, void> : public CompBase
    // Abstract Input component implementation.
template<typename Ent_t = void>
using InputComp = Comp<CompBase::INPUT, Ent_t>;

// in another part of the code
class InputComp<Monkey> : public InputComp<>
    // Monkey specific Input component implementation.

So is it okay to have a small amount of example-like code breathing life into a framework, included in the framework, given proper labeling of these segments.

  • \$\begingroup\$ We don't often say something is too big to review, but uploading your entire framework as a whole will not work in your favour. Why don't you select specific parts of your framework instead? \$\endgroup\$
    – Mast Mod
    Nov 30, 2015 at 10:21
  • \$\begingroup\$ It only makes sense to interpret it holistically, I think. It is written rather cleanly and it is indeed really flexible so I'm sure you will like it :P \$\endgroup\$ Nov 30, 2015 at 10:29
  • \$\begingroup\$ Prefer readability over brevity. InputComp -> InputComponent, CompBase -> ComponentBase, Comp -> Component (possible name collision..) You see, you can even get feed-back here :) \$\endgroup\$
    – Oguz Ozgul
    Dec 14, 2015 at 7:34

1 Answer 1


Yes, example code as a small part of a question, clearly labeled as example not for review, is perfectly fine, and even helpful.

That is assuming the rest of the question is real, fully working code, as per our on-topic rules in the help center.

And as @Mast pointed out, keep in mind that it's difficult to get good answers when you post a lot of code. You might want to split to multiple questions, highlighting different parts. That's not a rule, just a tip, for your consideration, to make the most out of your post.

  • 2
    \$\begingroup\$ The code should be real, the implementation may be an example. It's similar to including usage instructions. \$\endgroup\$
    – Mast Mod
    Nov 30, 2015 at 10:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .