Skip to main content
added 45 characters in body
Source Link
Ixrec
  • 27.7k
  • 15
  • 84
  • 87

Pass a reference to the ConnectionString (or better yet, the actual Connection) to the Table's constructor.

Since the Table is already inside the Database (and doesn't really belong anywhere else), the Database can simply give it the magic string during construction, and then the Table always has what it needs to execute the row count logic. Since your ConnectionStringConnection(String) is mutable, you can't get away with a copy, but giving the Table a reference to that one stringconnection is much better than giving it a reference to the whole Database object or forcing the Database to contain all the real code.

Pass a reference to the ConnectionString to the Table's constructor.

Since the Table is already inside the Database (and doesn't really belong anywhere else), the Database can simply give it the magic string during construction, and then the Table always has what it needs to execute the row count logic. Since your ConnectionString is mutable, you can't get away with a copy, but giving the Table a reference to that one string is much better than giving it a reference to the whole Database object or forcing the Database to contain all the real code.

Pass a reference to the ConnectionString (or better yet, the actual Connection) to the Table's constructor.

Since the Table is already inside the Database (and doesn't really belong anywhere else), the Database can simply give it the magic string during construction, and then the Table always has what it needs to execute the row count logic. Since your Connection(String) is mutable, you can't get away with a copy, but giving the Table a reference to that one connection is much better than giving it a reference to the whole Database object or forcing the Database to contain all the real code.

Source Link
Ixrec
  • 27.7k
  • 15
  • 84
  • 87

Pass a reference to the ConnectionString to the Table's constructor.

Since the Table is already inside the Database (and doesn't really belong anywhere else), the Database can simply give it the magic string during construction, and then the Table always has what it needs to execute the row count logic. Since your ConnectionString is mutable, you can't get away with a copy, but giving the Table a reference to that one string is much better than giving it a reference to the whole Database object or forcing the Database to contain all the real code.