Factory methods vs constructors

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Minor - P4
    • 0.11
    • Affects Version/s: 1.0
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, many classes in the C# driver have both public constructors and factory (Create) methods, with different functionality (i.e. factory method usually caches thread-safe objects like MongoServer and MongoDatabase). I wonder if constructors should not be public to promote use of factory methods (since subclassing such types isn't practical, the constructors should become private and said types should be sealed)?

            Assignee:
            Robert Stam
            Reporter:
            Aristarkh Zagorodnikov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: