lundi 1 février 2021

Determining design pattern from scenario

I am trying to refactor my code by imposing a design pattern in my code. The scenario is as follows:

For a desktop application(c#), I have to generate YAML for different type of UML diagrams.

A specific YAML pattern has been given. I am using a .dll file of a third party to traverse the diagrams and get the data related to the diagram. I am assigning those data to the diagram objects property, and later converting those object directly to YAML by another library.

Below is my class diagram for UML state diagram:

public class StateDiagram
    {
        public string refDiagramName { get; set; }
        public string refDiagramId { get; set; }
        public List<State> states { get; set; }
        public HashSet<Transition> transitions { get; set; }
        public string initialState { get; set; }
        public string finalState { get; set; }
    }

public class State
    {
        public string name { get; set; }
        public string entryActions { get; set; }
        public string exitActions { get; set; }
        public string doActions { get; set; }
    }

public class Transition
    {
        public string from { get; set; }
        public string to { get; set; }
        public string trigger { get; set; }
        public string effects { get; set; }
}

I have a Main Class where I am creating the object which is later converted to YAML.

In future I need to integrate for example UML Sequence Diagram, UML Activity diagram and so on and all of them have different properties and generation strategies.

For the above mentioned scenario, which design pattern I should use? I was thinking of strategy or template pattern but confused.

Aucun commentaire:

Enregistrer un commentaire