当应该和不应该从OOP割舍速度/性能? [英] When should and shouldn't you break away from OOP for speed/performance?

查看:93
本文介绍了当应该和不应该从OOP割舍速度/性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为Android开发者的文章,谷歌指出,通常应声明公共变量,而不是getter和setter私立学校加强对嵌入式设备(我猜想函数调用不仅仅是写一个地址更贵)的性能。

In their developer articles for Android, Google states that you should usually declare public variables rather than private ones with getters and setters to enhance performance on embedded devices (I suppose function calls are more expensive than just writing to an address).

我想知道 - 到什么程度应该表现可以牺牲坚持面向对象的范式?在什么其他情况下不优化的意思是好的编码实践一个突破了?

I was wondering - to what extent should performance be sacrificed to stick to the OOP paradigm? And in what other cases does optimisation mean a break-away from 'good' coding practices?

推荐答案

构建它是维护,然后攻击它的速度更快。

Build it to be maintainable, and then hack it to be faster.

如果你开始与黑客 - 你可能没有必要 - 保养通常是一场噩梦

If you start with the hack - which you might not have needed - maintenance is usually a nightmare.

这篇关于当应该和不应该从OOP割舍速度/性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆