Why is ORM considered good but “select *” considered bad?

后端 未结 12 1696
误落风尘
误落风尘 2021-01-29 23:25

Doesn\'t an ORM usually involve doing something like a select *?

If I have a table, MyThing, with column A, B, C, D, etc, then there typically would be an object, MyThin

12条回答
  •  感情败类
    2021-01-30 00:28

    SELECT * is a strong indication you don't have design control over the scope of your application and its modules. One of the major difficulties in cleaning up someone else's work is when there is stuff in there that is for no purpose, but no indication what is needed and used, and what isn't.

    Every piece of data and code in your application should be there for a purpose, and the purpose should be specified, or easily detected.

    We all know, and despise, programmers who don't worry too much about why things work, they just like to try stuff until the expected things happen and close it up for the next guy. SELECT * is a really good way to do that.

提交回复
热议问题