Amethyst: [FEATURE MODIFICATION] The engine struct naming are not clear enough

Created on 31 May 2019  路  3Comments  路  Source: amethyst/amethyst

The standard components in the engine have names that doesn't immediately tells the type of the struct that you are dealing with.
By doing so you don't know if a struct is a component or another thing until you open the relative implementation file.

A solution to this problem could be add "Component" as suffix to all components in the engine in order to have something like: SpriteRenderComponent (or SpriteRenderComp)

In this way the names are way more consistent, and when you read the code is immediately clear what you are dealing with.

Another way to view this is, If you read this code:

    let sprite_render = SpriteRender {
        sprite_sheet: sprite_sheet.clone(),
        sprite_number: 0
    };

SpriteRender what it is? A System, a component, a state or what?

    let sprite_render = SpriteRenderComp {
        sprite_sheet: sprite_sheet.clone(),
        sprite_number: 0
    };

Instead in this second case is clear that you are dealing with a component.

What I propose is to add the suffix comp to all default components of the engine and thus make it the code way more clear.

Also @piedoom in the discord chat said that currently we use this naming strategy with the Systems structures, and he said that he usually use the namespace to differentiate the components in its code.

easy low discussing engine improvement

Most helpful comment

I would probably bite the bullet and not abbreviate it - SpriteRenderComponent. Otherwise, I know that I will at some point forget whether it was abbreviated as C, Com, Comp, or something else. I wouldn't think that reducing verbosity in the type name should be too critical here. If someone wants to reduce the verbosity, they can always type alias on their end.

Only other thing I would say is that all or at least most of the original struct names should be type aliased to the component version with some comment indicating that it is a deprecated type name and the Component suffix version should be used.

All 3 comments

I would probably bite the bullet and not abbreviate it - SpriteRenderComponent. Otherwise, I know that I will at some point forget whether it was abbreviated as C, Com, Comp, or something else. I wouldn't think that reducing verbosity in the type name should be too critical here. If someone wants to reduce the verbosity, they can always type alias on their end.

Only other thing I would say is that all or at least most of the original struct names should be type aliased to the component version with some comment indicating that it is a deprecated type name and the Component suffix version should be used.

This is a good point, instead do you know if is it possible to make the compiler stop when you use the old struct name and tell exactly which type you have to use from now on?

I'll do a PR later today

Considering the answers I'm seeing in this forum thread https://community.amethyst.rs/t/rename-all-components-to-have-component-suffix/878/27
I'm closing this issue. Please re-open if it is still valid.

Was this page helpful?
0 / 5 - 0 ratings