Last active
December 2, 2016 03:53
-
-
Save elderfo/c0664c3f75fa409ac16fac850f868ac7 to your computer and use it in GitHub Desktop.
Factory method addition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Project.Logic; | |
namespace Project.Controllers | |
{ | |
public class ExampleController : Controller | |
{ | |
private readonly User _userLogic = User.New(); | |
// public JsonResult GetUser(Guid userId) ... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Project.Data; // enternal dependency | |
namespace Project.Logic | |
{ | |
public class User | |
{ | |
public static User New() { | |
return new User(); | |
} | |
private User() { | |
// private constructor discourages other devs from | |
// explicitly creating instances of the class | |
} | |
// public UserModel Get(Guid userId) ... + other methods | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment