Why would I use static methods for database access

前端 未结 4 1447
滥情空心
滥情空心 2020-12-16 20:16

So I came across this issues today and I couldn\'t find some meaningful explanation is there some non-subjective reason to use static methods when it comes to database inter

4条回答
  •  不知归路
    2020-12-16 21:20

    I think your last statement is correct; its just the previous developers approach.

    I will say, though, that having those methods static is going to make your life a nightmare to create a testable product; if you have the power to change them to be instance based and create a set of unit tests that can test the app via mocks without needing a database it'll make your life easier in the long run.

提交回复
热议问题