Separating Business Logic
When designing an application, separate UI code from the code that makes your application “do things”—what is traditionally called “business logic”. Make sure an airtight interface separates your business logic from your UI.
Taken to its logical end, business logic code should exist in its own library or framework, and your UI app links against it.
Separating your business logic this way allows you to repurpose it in other apps, create command-line versions of your app (useful for scripting), refactor it without changing your UI, or overhaul your UI without introducing errors into your app’s core logic.
Even if you never refactor or repurpose your code, this separation acts as an organizational tool while you design your app. Follow this pattern and your app will likely be more maintainable.