如何用UML类图描述这个工厂?

时间:2017-12-31 12:22:22

标签: factory-pattern

在我的工作中,我对这个样本工厂的UMLing类图有很多不同意见:

class Program
{
    private static TrainComponentsData _trainComponentsData;

    static void Main(string[] args)
    {
        InitTrainComponentsData();
        string str = _trainComponentsData.ToString();
    }

    private static void InitTrainComponentsData()
    {
        ITrainComponentsReader reader = TrainComponentsReaderFactory.Create("XML");
        _trainComponentsData = reader.Read();
    }
}

public class TrainComponentsReaderFactory
{
    internal static ITrainComponentsReader Create(string readerType)
    {
       //....
    }
}

internal class XMLTrainComponentsReader : ITrainComponentsReader
{
   //....
}

public class TrainComponentsData
{
   //....
}

internal interface ITrainComponentsReader
{
    TrainComponentsData Read();
}

我对各种不同的图表有点困惑:

UML class diagram 1 from internet UML class diagram 2 from internet UML class diagram 3 from internet

等...

谢谢!

0 个答案:

没有答案