Given the hypothetical situation where the old library of obsolete presentations was maintained over the years, and gradually it introduced more and more business logic into it through a process of hasty corrections and lack of proper architectural supervision. As an alternative, consider a business class or namespace that is not separated from the presentation by the assembly boundaries, and therefore could refer to something like System.Windows.Forms without having to add a link (a much more sobering action than a simple use sentence).
In such situations, it is unimaginable that the business code used by this user interface code will ultimately be called for reuse. What is a good way to rearrange two layers for this?
I am not familiar with design patterns - at least in principle. However, I do not have much practical experience, so I am not sure of my intuitions. I began the journey of using a strategy template for this. The idea is to identify where business logic invokes user interface components to ask the user a question and collect data, and then encapsulate them in a set of interfaces. Each method on this interface will contain UI-oriented code from the original workflow, and then the user interface will implement this interface.
The new code that wants to reuse the business logic in question will also implement this interface, but will replace either new windows, or perhaps preliminary or parameterized answers to questions that were originally answered by the user interface components. Thus, the biz logic can be considered as a real library, although with some inconvenient interface parameter passed to some of its methods.
Is this a decent approach? What is the best way for me to do this? I will give to your collective Internet wisdom.
Thanks!
source share