Entitas-csharp: "Context" class name is unintuitive

Created on 5 Apr 2017  路  12Comments  路  Source: sschmid/Entitas-CSharp

I know, that should not be a big issue, and you should name the way you see fit, and you have been working on Entitas for years, and probably used to think in these terms, even though it was called Pool for the longest time. But here is why Context might be not the best name for this class.

Entity and Component are something that exists in real life in tangible form, even though entity is a more general term, it is still literally a thing, an object. Systems do exist in real life too, no need to explain what a system is.

Pool - "Contains entities. Got it." Factory - "Produces and manages entities. Right" Entity manager - "Say no more" Context - "..Umm. Wel... Here is an example (insert a long drawn out explanation with multiple analogies to give some idea of what context means in programming [http://stackoverflow.com/questions/6145091/the-term-context-in-programming])"

And even after that long explanation, it is very questionable that this is a good description of what Context in Entitas is.

  1. So context is not a real tangible thing, it is an abstract concept never represented by real objects.
  2. Even after learning the meaning of Context in programming this seems to be not the best use of it, and context seems to be understood as more of a contextual information, a dataset. While in Entitas this class is seen more like a Factory or a Manager.

I'm not sure what the best name would be, they all have their issues, and everyone has their own preferences. Pool was okay to me. Manager would be even better.

Pool could be confusing because it could refer to the concept of pooling objects for reuse, yes. But Manager is clearly a generic term with very clear purpose. EntityManager in this case.

I would like to know what other people think about the "Context" and any alternative naming.

Most helpful comment

If you call SomethingManager, or SomethingController, that you don't understand what that thing is exactly.

Context is really great name with very clear understanding to my opinion. Maybe you need to work with entitas more to understand that.

All 12 comments

I would just call it EntityManager. Very clear purpose. The fact that it's two words is not an issue at all because autocompletion, and the name of the class is not used a lot actually. You would have:
GameEntityManager _manager;
_manager = EntityManagers.game;

Yeah, @JuDelCo, thanks, I probably should have responded there, but I figured it was a closed issue specifically about Pool vs Context.

I just wanted to show that Context was called Pool before 馃槃

The name is not about the class only. It also refers to the concept of the set of components that can build an entity. In one context, an entity can have a position, in another context it can't. Each component is relevant in one or more contexts.

@JuDelCo Yes, thanks, I mentioned it.

@paraboxx Aren't we talking about different entities though, if you have your GameEntity and InputEntity? I JUST started learning Entitas so I don't even know if you can take the same entity in different contexts and see different components on it depending on the context. Is that the case? If so, then yes, that makes things clearer to me.

No that's not possible. GameEntity and InputEntity are different entity types. Each type can only exist in it's own context. But these types can share common components. The context defines the set of components that its own entities can be composed of. And this is why EntityManager doesn't show the whole picture. Sure it does _manage_ entities, but it also _represents_ the concept of a context whose entities follow certain rules and which are separate by definition from entities from other contexts.

I see, but on the other hand, components are just available to different entity managers or to different types of entities. So when you put [Game] in the component definition, you are saying that this component is a part of GameEntity.

A "Factory" kinda works perfectly in this particular example. Factory has components to build entities from. Some components are available for certain factories and some are not.

I'm a little OCD about my namings. Ironically that's one of the reasons why I'm switching to Entitas :) That is always an issue in OOP.

So in a case of EntityManagers, you are not generating contexts, you are generating entity types, and each entity type has its own manager. Components are declared available to different entity types. If you want to destroy or create a GameEntity, you go to GameEntityManager. EntityManager manages entity pools and entity lifecycle, and also Groups. A lot of stuff to manage if you ask me :D

Mm.. I actually don't see disadvantages or incoherences with EntityManager naming now.

If you call SomethingManager, or SomethingController, that you don't understand what that thing is exactly.

Context is really great name with very clear understanding to my opinion. Maybe you need to work with entitas more to understand that.

If you call SomethingManager, or SomethingController, that you don't understand what that thing is
exactly.

Absolutely true. Besides that, we already had the long discussion about this topic (you should read it) and current name expresses exactly what it is.

@VladislavKostin While I love talking about details like naming (which I think is really important) I must tell you that this topic has been discussed already in the past (#99) and I'm afraid that there will be no renaming of the Context anytime soon.
We were thinking about the name a lot and we agreed that Context is actually a good name that it is both short and descriptive. Personally, I try to avoid using *Manager whenever I can.

But thanks for the input!

Well, that wasn't a long discussion, @VirtualMaestro, and I have read it... Unless you mean not the #99 And not a lot of people were enthusiastic about Context, so I thought I'd ask.

It's not like it's "ManagerControllerSystemThingy" but I'll take the point about Manager in general. But I don't agree that it is always a bad thing.

I just wish there would be a better option for everybody. I'm sure I would get used to any name.

If Context is not an intuitive name by default (I think I made the case) even if it is a good name at the end of the day (and I can kinda see why it would be), then ideally there should be a definition of Entitas' Context/Pool class from which its current name becomes self-explanatory. Because right now, it's funny, it's like the Dao that can't be named. When I will become zen enough I'm sure I will know the True Dao and the true meaning of Context 馃槃

The simple and intuitive definition in the Wiki doesn't have very much to do with the name of the class: "The Context is the factory where you create and destroy entities."

So just logically the intuitive name is Factory or a synonym. I'm just exploring the subject of intuitive naming at this point..

Was this page helpful?
0 / 5 - 0 ratings