Should I use Adaptor, Facade, Abstract Factory or Factory pattern to refactor God controllers

by and   Last Updated August 10, 2018 12:05 PM - source

Our system were initially created around the client's ordering logic which is received by an API. This was allowed by the previous I.T. dept.

However over time many different clients with differing systems send their order's to our API which have to be cleaned and changed into our working version, examples are filenames without file types for images which have ',jpg' added to the filename, or statuses that are strings ie 'finished' that are converted into our new status of int 2 etc.

There are huge sections of if statements and switch statements that change things based on who the client is which has created God controllers which have all this logic whilst the models are anaemic, and I need to service the code whilst refactor as I go, but there are little in the way of tests etc.

I want to use SOLID principles and learn better programming and move the logic to the models for reuse, create viewModels, move javascript out of html pages and into javascript files and remove duplicated code which seems to be everywhere.

So my question is what is the best design pattern(s) to have a core logic and have other logic to convert clients orders to our working orders, so that the clients can update their systems to be more like ours over time with as little or no ill effects. (I realise I'm asking a lot in a generic way)

Tags :

Related Questions