Reputation: 6813
So I've been around android for about two years now, and around 6 with java, something that I liked from the very start that i discover them where the Java Convetion, this guide that help me wrote more understandable code you know the typical CalmelCase Upper for class lower for method, or the getter and setter of JavaBean, etc. But what i've also seen it's that Android itself sometimes does not follow some of them,
I would like to know Why?
Does not declared private attribute and follow the getter and setter pattern. Is it as evil as some say it is? or they just leave it like that for example purposes.
They start the member with 'm' preffix? for me it's sometimes annoying but is there any hidden true about it? or it just to specify members?
They seem to love static class while before I used to avoid them?
Do you know any other that you'd like to share?
Upvotes: 4
Views: 263
Reputation: 122
When I was working with Android sources I found that design of Android is not in a "good object oriented" style. For example I found some classes with 2 thousands of code lines. And yes a lot of hardcode too. Usual Java programmers will become angry at you if you do it. Link in one of the previous posts shows that we can increase performance using large objects, static variables and direct access to the fields. Also the Android code is well divided to services which perform different tasks and have different responsibilities.
It seems like Google engineers were balancing between "good" design and performance.
Upvotes: 1
Reputation: 5151
A code/style/language convention is just that: a convention, it's an agreement. You don't have to follow the Java Convention as if it were the only correct way to write Java code. The important thing is to follow some convention, especially across a team, but which one you're following doesn't matter.
Android just has some differences from the proposed Java one which probably relate somewhat to the mobile technology itself and somewhat to whatever preferences the Google engineers had when they were writing it all up :) .
Upvotes: 1
Reputation: 5643
I found a few answers for your questions when I ever have questions like you have. Here is the link:
Android: Designing For Performance
Upvotes: 3