Active Records vs. Repository - pros and cons?
问题 Using ActiveRecord you might define a class like this: class Contact { private String _name; public String Name { get { return _name; } set { if (value == String.IsNullOrWhiteSpace()) throw new ArgumentException(...); else _name = value; } } public Boolean Validate() { ... /* check Name is unique in DB */ } public Boolean Save() { ... } public static List<Contact> Load() { ... } } Whilst this is nice and simple, I've found my classes become very bloated with a big mix of logic going on! Using