When should you and shouldn't break away from OOP for speed / performance?

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

I was wondering - to what extent should efficiency be sacrificed in order to adhere to the OOP paradigm? And in what other cases does optimization mean breaking away from “good” coding methods?

+3
source share
13 answers

Build it for maintenance, and then hack it faster.

, , .

+15

, .

.

+7

, , .

: - . get, , , public OO. , , , .

+6

, , , , , , "". , , , , "". , , , -, " ". , , .

+6

, - . .

- , .

" : . ( !): ". - .

, , . , /, , - ? , , , " ".

+5

, , .

, .

Google , , , API . , / , . , , , - , .

, . , , Java, Fortran.

/ , . , , ressource, , . , Android.. Android, .

+3

? ( MIPS, ).

  • [body]
  • ( )

/ , CPU reset ( , , , , ). / , . , , / , .

( +).

+2

, Google , .

, , , , , .

, , , , 80% , 20% , . , , , , , Android ).

, Android , . - , , , . , , .

, Google ad absurdum, :

1 XML: 22 000

: 15

, onLayout(), Adapter.getView() inflate(). .

+2

, , . , . Android . , .

, get-get-getter/setter , " ", . , Java, " ", , - .

, ++, , .

+1

, , , .

0

"" , , . , , . , - , .

; , . , , . , , , , .

0

Android . - , Android , ( ). . , .

Java , , .

Google , getters/seters Android. / . http://developer.android.com/guide/practices/design/performance.html:

" Getters/Setters

, ++, (, = getCount()) (i = mCount). ++, , , .

Android . , , . - , .

0

Millions of man hours have been wasted on these stupid little getters and setters. In most cases, they are not needed. Start with open fields, and you can always change their use to get / set methods later if necessary.

-1
source

Source: https://habr.com/ru/post/1723929/


All Articles