How can I design this better? (Avoiding a switch statement with Object Oriented design)

前端 未结 6 826
不思量自难忘°
不思量自难忘° 2020-12-30 11:23

I know a little bit about Object Oriented design, but I\'m not sure how to go about using those principles in my code. Here\'s what I\'m working on:

    pub         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 12:00

    ADO.NET has a set of generic classes: DbCommand, DbConnection, etc... that also implement another set of generic interfaces: IDbCommand, IDbConnection, etc...

    So you could use them, but it may become quite complicated in the end. The advantage of your solution is it's very readable. Plus maybe the pick database does not have any ADO.NET provider...

    PS: I would replace the Type property type though, and use an enum instead.

提交回复
热议问题