Click here to Skip to main content
15,030,240 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

My requirement is to send diff actions to vendor through rest API (actions will be for ex: simple notes, some docs etc through xml payload). I will have to support unit testing (so logic should be decoupled from UI) for all the actions and more actions can be added in future also. So when i click on Action button, a list of actions will be displayed and on select of one particular action above sending to vendor logic is executed. I felt lot of code can be reused here and only different thing would be forming payload. Can any one please suggest a good design approach/pattern i can use to reuse the code and decouple logic from UI?

What I have tried:

I have have tried view model concept and it helps me to decouple the logic. But am not sure which pattern will help to reuse the code?
Updated 24-Feb-21 6:57am
PIEBALDconsult 24-Feb-21 9:45am
Always think in layers.
Gerry Schmitz 24-Feb-21 12:09pm
All Xml is a string.
BillWoodruff 24-Feb-21 13:39pm
Unless your exchanges need to transfer very large data, consider using JSON for communication,

1 solution

Take a look at the Factory Pattern, it is discussed here:
Design Pattern - Overview - Tutorialspoint[^]

And here is a C# example: C# Design Patterns - Factory Method - Code Maze[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900