I want to use EF Code First. I’m working with a repository pattern. And I want to implement an n-tier architecture. What I really want is to use TDD but I’m getting a problem with aggregate routes. My problem is this…
I have a blog object. From this blog object associated files can be added. Great. So I in essence have 1 aggregate root which I create my repository for and then I need add some methods that allow me to ‘Add’ Associated Files to the blog. But where do I put this? Its a data access layer thing so I really want it there. But to be honest its also a business logic challenge. Part of the product is to be able to add assoc files. So should I put the logic to add Assoc Files in the DAL or the BLL?
Hope someone can give me some guidelines.
I think you mean DDD instead of TDD, because what you said have little meaning in context of TDD.
You need to sit and think what does a file mean to you system, are there any rules that connects files and posts. For example if we delete a post what should have with files? Do we delete them too? Can we “add” same file to multiple posts. You sit, think, and gather knowledge about you file, then you decide if it deserve a place to be introduced in you Domain.
Some sample domain I can imagine:
Update: Let’s continue…
After a 5 mins of thinking on you domain I descovered that my initial design misses important concepts (as always with DDD you scrape knowledge bit by bit).
Who is responsible for uploading Files? Can user associate file he already uploaded to Post, can he add new File (unuploded) file to post? Can he mix this things? Those are important question, again you need to think about it and design you system.