I am working on an old software system, and I was tasked with porting some of the old COM components to .NET 3.5. COM components were originally hosted at MTS, and then at Component Services. In the .NET port, we process transactions with ADO.NET transactions, so the method signatures change somewhat.
The dilemma I came across is the order of the parameters. Each method requires that you pass it either SqlConnection or SqlTransaction (depending on whether it updates or not updates the database). Naturally, some methods can be called by different arguments. For instance:
Keyword.Load(string description, SqlTransaction transaction)
- OR -
Keyword.Load(string description, string tag, SqlTransaction transaction)
Now most framework methods that provide multiple overloads do the following:
A(int arg1)
A(int arg1, string arg2)
A(int arg1, string arg2, DateTime arg3)
, , . , . , . , 0:
A(SqlTransaction transaction)
A(SqlTransaction transaction, int arg1)
, , , :
// These overloads create a connection, open it, and start a new transaction.
A()
A(int arg1)
A(int arg1, string arg2)
A(int arg1, string arg2)
A(int arg1, string arg2, DateTime arg3)
// These overloads require that the transaction be passed in, so that the method
// can take part in it.
A(SqlTransaction transaction)
A(SqlTransaction transaction, int arg1)
A(SqlTransaction transaction, int arg1, string arg2)
A(SqlTransaction transaction, int arg1, string arg2, DateTime arg3)
, , .
, ? , , ? ?