Domain driven design and file storage
<p>I'm developing an application which allows users to copy movies from one location to their user account. For this, the movie will need to be copied to the user's personal folder.</p>

<p>The problem I'm facing is, is <em>when</em> to actually copy the file over. At the moment, I have a MovieFactory that after creation, immediately puts it into the MovieRepository after the factory method has done the copying. This seems to work fine.</p>

<p>The repository and factory, however, should not have to know of each other. Ideally I would do this:</p>

<pre><code>var movie = this.MovieFactory.CreateFromFile(new FileInfo("MyPhoto.mp4"));
this.MovieRepository.Add(movie);
</code></pre>

<p>Now my idea was to do the copying inside the <code>Add</code> method, given you're basically copying into the repository itself. However, by doing so, the movie's file location will change as well. As a result, the <code>Add</code> method either has to modify <code>movie</code> or return a new, but different movie instance. This sounds like code smell to me, and I'm completely stuck on this scenario.</p>

<p>At the moment of speaking, the file location does not get stored. Instead, the location gets deduced from multiple other movie properties using a MovieFileLocator service.</p>