Learner Learning Software Engineering
Posts with the tag Adapter:

Adapter Design Pattern

This design patterns guides to create a wrap around existing class to reuse existing class for a new requirement. Assume, I have two logging classes named WriteLogsToLocalFile and WriteLogsToServer. class WriteLogsToLocalFile { public void Log(string fileName, string message) { //write logs to file } } class WriteLogsToServer { public void Log(string urL, string message, string token) { //call rest API with oAuth // Note: here token is used for oAuth } } static void Main(string[] args) { WriteLogsToLocalFile fileLogs = new WriteLogsToLocalFile(); fileLogs.Log("hello.xml", "login success"); WriteLogsToServer serverLogs = new WriteLogsToServer(); serverLogs.Log("https://server.logs/upload", "login success", "oAuthToken"); } Here user is manually creating objects to write logs separately to local file and server.