❔ Refactoring a Tag class

I have a Tag class that has the ability to store information about tags. Each tag has several properties associated with it. For example:

  {
    "TagName": "Leveling",
    "ValType": 2,
    "isScanTag": true,
    "isTag": true,
    "TagType": 6,
    "DBField": "Leveling",
    "IsQualityTag": false
  }


I am trying to think of a more efficient way to handle this. At the moment, each tag is stored in a json file and then loaded on startup. Therefore, I am accessing each tag with a string, and getting each property based on this file.

public sealed class Tag
{
    public string TagName { get; set; }
    public ValEnum ValType { get; set; }
    public bool IsScanTag { get; set; }
    public bool IsTag { get; set; }
    public TagTypeEnum TagType { get; set; }
    public string DbField { get; set; }
    public bool IsQualityTag { get; set; }

    public Tag()
    {
        TagName = "";
        IsScanTag = false;
        IsTag = false;
        TagType = TagTypeEnum.Na;
        ValType = ValEnum.VInteger;
        DbField = "";
        IsQualityTag = false;
    }

    public enum ValEnum
    {
        VDouble,
        VInteger,
        VBoolean,
        VLong,
        VIntAsDouble,
        VByte,
        VUInteger
    }

    public enum TagTypeEnum
    {
        Na,
        First,
        Last,
        Avg,
        AvgBody,
        Bit,
        PercentageOn
    }
}


It works, but I think it could be better. I'm running into issues of bringing stuff back into memory with this setup. Any suggestions are welcome, thanks.
Was this page helpful?