Should a repository delete/remove an entity by passing in an id or or the entity itself
domain-driven-design, repository
Solution
Option 3.
It doesn't matter that CarKey isn't a domain object (it can be a value object though), an id is all you need for that action to happen. That's because, if the Car is an AR, the repository should know how to GetIt and how to handle deletes.
Problem
I am currently creating a repository and was wondering what the "best practice" is for the delete operation of an entity. In the options below make and model make up the key for the Car entity. Option 1: ``` deleteCar(Car car) ``` Option 2: ``` deleteCar(String make, String model) ``` Option 3: ``` deleteCar(CarKey carKey) ``` At first I thought Option 1, but in practice Option 2 seems more appealing (I don't want to have to get an object when I only have the id just so that I can pass it into the delete method). I put option 3 because I have seen stuff like that but that doesn't seem right to me because CarKey isn't really a domain object. Thoughts?