I'm refactoring a huge WPF application whose complexity stems from the way it deals with flow control. It has a lot of "tiny business rules" that make it really difficult to make a modification without breaking something. These rules are things like
If the window mode is foo but this is the first time they've pressed this button and the user has a certain role, show this, else validate another thing and show that, else show another thing.
I've thought about creating a lot of different classes for validation and keeping the global state but I'm not sure if there's a design pattern or something focused on dealing with this kind of situation.
-
Possible duplicate of Style for control flow with validation checksgnat– gnat2016年07月19日 17:08:06 +00:00Commented Jul 19, 2016 at 17:08
-
4If you're not already doing so, a Model-View-ViewModel (MVVM) approach eases this problem considerably. See markwithall.com/programming/2013/03/01/…Robert Harvey– Robert Harvey2016年07月19日 17:27:26 +00:00Commented Jul 19, 2016 at 17:27
1 Answer 1
One approach that might fit is a finite state machine. There are tools that help you build and visualize them but you can also model it with standard OOP practices.
Explore related questions
See similar questions with these tags.