vendredi 22 juillet 2016

c# Updating a Collection Across Multiple Classes

I have list of objects with around 500k items in it. Object class has around 100 (total) properties in it(nested or otherwise), beliveve me that this model really need so many properties and all are interlinked.

I am enriching/assigning values to these classes in various class called Enricher since each value assignment has it's own big logic.

Is is a good way to update a list item across multiple classes? Please note I have to store the intermediate values inside the enrichers.

I have class design like below

 class MyItem
    {
        public bool IsXyz { get; set; }
        public decimal Value { get; set; }
        public Tuple<string, string> MyTuple { get; set; }
        public double Rate { get; set; }
        //Like these around 100 properties
    }

    class Enricher1
    {
        public void Enrich(MyItem myItem)
        {
            myItem.IsXyz = true;
        }
    }

    class Enricher2
    {
        public void Enrich(MyItem myItem)
        {
            myItem.Value = 3M;
        }
    }

    class Enricher3
    {
        public void Enrich(MyItem myItem)
        {
            myItem.MyTuple = Tuple.Create("Test", "Test");
        }
    }

    class Enricher4
    {
        public void Enrich(MyItem myItem)
        {
            myItem.Rate = 300;
        }
    }

Thanks!

Aucun commentaire:

Enregistrer un commentaire