5

Android devs, what are your thoughts about the naming conventions google tries to enforce on us, especially with the xmls?

I opened a new project after months of leaving android dev, and thought of trying the basic activity template with name 'myActivity'

On clicking it, a ton of files got created : myActivity, myActivityFragment ,... And in xml the reverse naming notation : activity_my, fragment_my, content_my,...

This naming is uncomfortable .in a large project, activities usually acts as complete modules in which different tasks are handled : logins getting checked, data being cached, database being accessed and much more...
So if my activity 'abc' has a content fragment and a toolbar whose design is in another xml, shouldnt the 3 of them be named like:
abc_activity.xml
abc_activity_fragment.xml
abc_activity_toolbar.xml

And not
activity_abc.xml
fragment_abc.xml
toolbar_abc.xml

??
At the very least , it would look nice since the components that are displayed together will have their files together. And i don't know much about testing, but i believe it would be helpful there too

Comments
  • 2
    Highly subjective. I find no issue with either naming convention but do not find preferred over the other.
  • 0
    As a person who struggles to name variables things that are not insanely long I welcome any name that isnt two letters, at least it's readable, though don't really mind either way
  • 2
    I like the activity_abc naming convention, since you can actually group all the activities layouts on the project layout and search fadter for the file you want.
  • 0
    It bothers me too. Not because I prefer one ordering over another, but because it is different in classes and xmls.
  • 0
    Doesn't bother me, I am actually OK with both naming conventions as @Viewholder said it is much easier to search when all your activities and fragments are grouped together
Add Comment