Anti-Pattern: The "God Method" (Importer Edition)
🔴 The Problem
A single method that handles File I/O, Parsing, Data Validation, Business Logic and Database Persistence all in one continuous flow, often spanning hundreds of lines.
Signals
- Methods with > 200 LOC.
- High Cyclomatic Complexity (many
if/else,switch,try/catchnested). - Uses
ExecuteSqlCommandmixed with classic Entity Framework usage. - Variable names like
isOk,tempList,obj2.
Why it's Bad
- Untestable: You cannot write unit units for the "Parsing" logic without setting up a full DB context.
- Fragile: A change in the File Format requires editing the same code that handles Database Transactions.
- Timeouts: Since it runs as a huge transaction script, it often exceeds SQL or HTTP timeout limits.
💡 The Solution
Pipeline Pattern:
- Reader: Reads the file -> returns raw DTOs. (Pure Logic, Testable).
- Validator: Checks DTOs -> returns "Clean" vs "Invalid" lists.
- Persister: Saves "Clean" list to DB in batches.
🔍 WEP NG Context
FinancialTransactionImporter.ImportPaymentToProvideris a classic example.