Another common design pattern is factory pattern. The main goal of this pattern is delivering an object by hiding all the complexities behind it. This may sound cryptic, so let's look at it using a real life scenario.
You are doing a project that works on a very complex system. For this example, you are creating an online document repository, which saves documents in temporary storage. For this you need support for PostgreSQL, MySQL, Oracle, and SQLite because users may deploy your application using any of these. So you create an object, which connects to MySQL and perform the necessary tasks. Your MySQL object is:
<? class MySQLManager { public function setHost($host) { //set db host } public function setDB($db) { //set db name } public function setUserName($user) { //set user name } public function setPassword($pwd) { //set password } public function connect() { //now connect } } s ?>
Well, now you use this class...