Skip to content

Instantly share code, notes, and snippets.

@andrewmclagan
Last active May 1, 2018 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewmclagan/2578f887a3486e6b241b832631c007e2 to your computer and use it in GitHub Desktop.
Save andrewmclagan/2578f887a3486e6b241b832631c007e2 to your computer and use it in GitHub Desktop.
Style of naming and namespacing
/*
|--------------------------------------------------------------------------
| Class has function only
|--------------------------------------------------------------------------
*/
use App\Criteria;
$jobs = $repository
->addCriteria(Criteria\Jobs\Approved::class)
->addCriteria(Criteria\Jobs\Recent::class)
->where('deleted_at', '!=', null)
->find();
/*
|--------------------------------------------------------------------------
| Class has function and domain
|--------------------------------------------------------------------------
*/
use App\Criteria;
$jobs = $repository
->addCriteria(Criteria\ApprovedJobs::class)
->addCriteria(Criteria\RecentJobs::class)
->where('deleted_at', '!=', null)
->find();
/*
|--------------------------------------------------------------------------
| Class has function, domain and namespace
|--------------------------------------------------------------------------
*/
use App\Criteria\ApprovedJobsCriteria;
use App\Criteria\RecentJobsCriteria;
$jobs = $repository
->addCriteria(ApprovedJobsCriteria::class)
->addCriteria(RecentJobsCriteria::class)
->where('deleted_at', '!=', null)
->find();
#######################
# Which one do you think is more fluent?
#######################
@sebastiansibelle
Copy link

I think option A

@sebastiansibelle
Copy link

I don't like the duplication in the last option

@andrewmclagan
Copy link
Author

yeah i was option A as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment