Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose I have created interface IFolderRepository with methods like that: IEnum

ID: 644314 • Letter: S

Question

Suppose I have created interface IFolderRepository with methods like that:

IEnumerable<Folder> GetAllFolders();
Folder GetFolderWithId(int id);
void AddFolder(Folder newFolder);
void ModifyFolder(Folder folderToModify, Folder folderAfterModification);
void RemoveFolder(Folder folderToRemove);
and I've implemented DatabaseFolderRepository and lets say CacheFolderRepositoryDecorator. Now 'hundreds of lines later' I'd like to add SkyDrive folders functionallity so I'm ready to add SkyDriveFolderRepository. Unfortunately while DatabaseFolderRepository implementation used synchronous methods to talk with database, skydrive one uses a lot of async and await. What to do in such case? In case of void methods marking it async is not a solution (need to exception handling). Should I change interface to return Task<T>? Sure it will work in above example but they're just 2 interface implementation classes. Or should most of my interfaces have Task return types (against you aren't gonna need it rule)?

Explanation / Answer

You will probably find this MSDN article about Asynchronous practices to be a good read.

You asked:

Unfortunately while DatabaseFolderRepository implementation used synchronous methods to talk with database, skydrive one uses a lot of async and await.

This is where the sub-section Async All the Way in the MSDN article I linked will be pertinent to your situation.

In particular, it

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote