paladin3895 / google-search

0 stars 0 forks source link

[Chore] SearchEngine improvement #6

Open olivierobert opened 1 year ago

olivierobert commented 1 year ago

Issue

Using an interface and using a builder pattern are good ideas. There are still some ideas to improve the current implementation:

https://github.com/paladin3895/google-search/blob/9e652a7fab9f1073318c4bbb09de4fafba9de5cc/app/Jobs/KeywordSearch.php#L46-L48

to:

$searchEngine = new SearchEngine('google')
$searchResult = $searchEngine->search($keyword->key);

https://github.com/paladin3895/google-search/blob/9e652a7fab9f1073318c4bbb09de4fafba9de5cc/app/Utils/Search/GoogleSearch.php#L28

You could check to move other hard-coded values to constants too.

Let me know your thoughts on the proposed improvements 🙇

paladin3895 commented 1 year ago

Hi, your suggestion for the SearchEngine is very reasonable. I thought about it initially but I decided to include search engine name in the search function to make it flexible. Since you only need to create one instance of SearchEngine and can search across multiple search platforms (Google, Bing, etc). I'll have a think about it and make improvement tomorrow if need be.

Aside from that, I completely agree to refactor hardcoded value into a config and rename the directory to Services to suit its purpose better.

paladin3895 commented 1 year ago

Please refer to this pull request #9