Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-148

Factory methods vs constructors

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 0.11
    • Affects Version/s: 1.0
    • Component/s: None
    • Labels:
      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@mongodb.com Robert Stam
            Reporter:
            onyxmaster Aristarkh Zagorodnikov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: