Design Patterns Series 4 - Factory Pattern
Previous post explored decorator pattern that take care of flows in standard OOP especially when it comes to inheritance, also this post will explore another pattern that serve the same concept. Factory Pattern : the factory design pattern lets you improve the new operator by giving you a lot more flexibility when you create new object. When you use this pattern, you use your own code to create new objects, you don't use just the new operator. To know how we can improve the new operator consider you want to create a connection to MSSQL database, you will create it using the following line Connection conn = new SQLConnection(); and when we want to connect to Oracle database we will use the following connection Connection conn = new OracleConnection(); but we want to make the default datebase is MySql so we need the next connection Connection conn = new MySqlConnection(); of course we will use one connection so we will choose the right connect...