


Do I declare instance variables at the bottom or the top? Which is the right way to eat bread: butter side up or butter side down? I started googling to see what the ‘best practice’ was for Apex when the buzzing in my subconscious reached some kind of protesting critical mass and morphed into a loud, clear message: “this is completely stupid.”

But with Apex, I have no idea what the natives ‘sound’ like, not having seen it in use before. I attempt to ‘speak’ it without an accent. When programming in any of the various programming languages I know, I have this mental cache of what’s preferred in what language. Declaring them at the top makes sense since the first thing you want to see in the class is what its state will consist of, but declaring the public stuff at the top makes sense since that’s what consumers will interact with and it’s like the above-water part of your code iceberg. I’ve seen arguments of all sorts as to which approach is better and why. (I still don’t.) In C++, the convention (last time I was using it much, anyway) is to first define public members in class headers and then the private members at the bottom. I was doing a bit of work in Apex, the object-oriented language specific to, and it occurred to me that I had no idea what idiomatic Apex looked like. Please pardon the loaded phrasing in the title, but that’s how the message came to me from my subconscious brain: bluntly and without ceremony.
#LIGHTTABLE JUMP TO END OF LINE SOFTWARE#
Category: Language Agnostic, Reasoning About Code Tags: OOP, Software Engineering Order Doesn’t Matter
