Functions that use references to base classes must be able to use objects of derived classes without knowing it.
Used when inheritance was a main form of reuse.
Design smell – Type checking in client code and changing the behavior for a specific type in client.
Due to forcing an unrelated object into an inheritance hierarchy
Prefer composition over inheritance whenever possible
LSP Violation Data Extractor CSV Format JSON Format Data Extractor Service Reporter (UI + Formatter) Database New Requirement - Adding Database as a data source for report data. Adding it to File Reader Service as it is conveniently there
Better design confirming to LSP File Reader CSV File JSON File File Data Extractor Service Reporter (UI + Formatter) Database Database Data Extractor Service Keep Database separate as it doesn't fit in File Data Extractor Service
DIP Violation Stuck with Text Format and Text Report Formatter implementations !!! Arrows are Dependency Text Report Formatter Reporting App Text Format JSON Format
Fixing for DIP Text Report Formatter Reporting App CSV Format JSON Format IFormatReport IExtractReportData
Design confirming to DIP IExtractReportData CSV Data Extractor JSON Data Extractor Data Extractor Service Reporter Writer Database Reader Service XML Data Extractor Reporting Application Report Data