forked from danieldantasdev/DesignPatternsInUse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
14 lines (11 loc) · 663 Bytes
/
Program.cs
File metadata and controls
14 lines (11 loc) · 663 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* In this example, IDatabaseConnectionFactory serves as a contract
* for creating database connections, and concrete factories implement
* this interface to provide specific connection types.
* This pattern effectively decouples the instantiation logic from the
* client code, making the system easier to extend and maintain. */
IDatabaseConnectionFactory factory;
// The choice of factory can be dynamically decided based on configuration or environment settings
factory = new SqlDatabaseConnectionFactory();
// For Oracle: factory = new OracleDatabaseConnectionFactory();
DatabaseClient client = new DatabaseClient(factory);
client.UseDatabase();