Object-Oriented PHP Best Practices: A Small Handbook of Conventions for Writing Readable, Sustainable OOPHP Code by Ikram Hawramani

Object-Oriented PHP Best Practices: A Small Handbook of Conventions for Writing Readable, Sustainable OOPHP Code by Ikram Hawramani

Author:Ikram Hawramani [Hawramani, Ikram]
Language: eng
Format: azw3
Publisher: Hawramani.com
Published: 2017-03-24T04:00:00+00:00


$school_name = $school->getName();

// and so on

}

?>

Now, the School object is being instantiated only once per school, and then reused for each student that belongs to that particular school. This means that a maximum of only 10 school objects will be created throughout the loop’s lifetime (since there are only 10 schools in the district as described earlier).

The problem with this method is that my team decided it was too much of an annoyance to implement a separate cache for each class. There had to be a better way.

After months of thinking, during a caffeine and phenylpiracetam fueled 15-minutes of clarity, I wrote the following class:

<?php

class Repository {

private static $repository = [];



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.