c# - How to refactor this? -


I am struggling with a small issue how I am recalculating it for a decent pattern.

  Public class DocumentLibrary {Private IFile System File System; Private IDocumentLibraryUser User; Public DocumentLibrary (IDocumentLibraryUser User): This (User, FileSystemFrom (user)) Public DocumentLibrary (IDocumentLibraryUser user, IFileSystem file system) {this.user = user; This.fileSystem = fileSystem; } Create Public Zero (IWorkerDocument Document) {document.SaveTo (fileSystem); } Public IWorkerDocument AttemptContractRetrieval () {new contract (file system, user) returned; } Public IWorkerDocument AttemptAssignmentRetrieval () {new assignments (file system, user); } Private Static IFileSystem FileSystemFrom (IDocumentLibraryUser User) {var userLibraryDirectory = New Directory Info ("/ DocLib /" + Environmental () + "/" + user.Id); Return the new file system (User Library Directory); } Private Static String Environment () ({var edmxContext = new entities ()) {return (from setting in edmxContext), Environment Settings, where setting.Name == Select "EnvironmentName" setting. value). first (); }}}  

I have two types of worker documents, but I have two methods from the top ( AttemptContractRetrieval and AttemptAssignmentRetrieval ) a decent in the form of.

Any help would be greatly appreciated.

Regards, Jim.

Personally, I think either by using a factory pattern, the factory methods or manufacturers Pattern

Good use of factory patterns can be seen in enterprise library solutions eg: Database.CreateDatabase ();
I will say that it will be the straight forward front integrated.

If you have chosen builder pattern, with the need to create more complex objects, you can separate complex objects into a series of construction commands such as: vehicleBuilder.BuildFrame (); VehicleBuilder.BuildEngine (); VehicleBuilder.BuildWheels ();

Then within these methods, in your chosen implementation, you can add your complexity but the method can make calls and construction quite straight forward.

If you do not come across it, there is a good place to go.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -