Given these 2 approaches:
Approach 1
module DomainCRUD =
let getWhere collection cond = ...
module DomainService =
let getByCustomerId f customerId =
f(fun z -> z.CustomerId = customerId)
// USAGE:
let customerDomains = DomainCRUD.getWhere collection
|> DomainService.getByCustomerId customerId
Approach 2
type DomainCRUD(collection) =
member x.GetWhere cond = ...
type DomainService(CRUD) =
member x.GetByCustomerId customerId =
CRUD.GetWhere(fun z -> z.CustomerId = customerId)
// USAGE:
let domainService = new DomainService(new DomainCRUD(collection))
let customerDomains = _domainService.GetByCustomerId(customerId)
Which would fit functional programming the most? I assume approach 1
would, but also it feels a bit superfluous to call DomainCRUD.GetWhere collection
each time.
Which would be the most flexible, and "readable"?