可能有些人已经遇到过这个问题。当程序员过于关注面向对象,忘记了性能和数据库时,这种情况就会发生。
例如,假设我们有一个电子邮件表格,需要通过该程序发送。在启动时,它会按以下方式查找需要发送的任何内容:
Emails = find_every_damn_email_in_the_database();
FOR Email in Emails
IF !Email.IsSent() THEN Email.Send()
从不重复自己的角度来看,这是一个好的方法,但有时候无法避免,因此应该采用以下方法:
Emails = find_unsent_emails();
FOR Email in Emails
Email.Send()
这个有名称吗?