Skip to content

Instantly share code, notes, and snippets.

@elderfo
Last active December 2, 2016 03:53
Show Gist options
  • Save elderfo/c0664c3f75fa409ac16fac850f868ac7 to your computer and use it in GitHub Desktop.
Save elderfo/c0664c3f75fa409ac16fac850f868ac7 to your computer and use it in GitHub Desktop.
Factory method addition
using Project.Logic;
namespace Project.Controllers
{
public class ExampleController : Controller
{
private readonly User _userLogic = User.New();
// public JsonResult GetUser(Guid userId) ...
}
}
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