I'm not a "die hard" coder and I need some advice.
I'm developing a website where users may search for a store or a brand.
I've created a class called Search and Store.
There are two ways search is executed: "jQuery Live Search" and "normal search".
Live search is triggered for each character entered above 2 characters. So if you enter 5 characters, a search is performed 3 times. If the store you are looking for is in the dropdown list, you can click the store and the store page will be loaded.
The other search is when you click the search button after entering 3 or more characters.
Every time a search is performed, the following code is executed
$search = new Search();
$result = $search->search($_GET);
Each time a store page is loaded a $store = new Store()
is executed.
My question is this:
Let's assume I get a very successful website and I have aroun 100 users per hour. Each user searches at least 3 times and looks at least 5 stores.
That means between 300 and 900 search objects are created every hour and 500 store objects.
Is it bad or good to create so many new objects?
I've read a bit about Singleton
, but many advices against this.
How should I do this to achieve best performance? Any specific design pattern I should use?