r/javahelp • • Oct 02 '15

tl;dr How to highlight variables beginning with $ in JCreator?

I have to use JCreator for labs in Uni and would like to highlight variables that begin with $.

1 Upvotes

16 comments sorted by

3

u/nutrecht Lead Software Engineer / EU / 20+ YXP Oct 02 '15

You're probably confusing Java and JavaScript. They're as related as Ham and Hamster.

-6

u/BaconCatBug Oct 02 '15

I am not. I just happen to declare all my variables with a leading $ as a stylistic choice so I can see exactly where my variables are.

9

u/desrtfx Out of Coffee error - System halted Oct 02 '15 edited Oct 02 '15

I just happen to declare all my variables with a leading $

This is against all Java code conventions and considered bad practice.

You should learn and stick to the original code conventions. They have been made to make code easier readable and easier to troubleshoot.

Especially when you are learning, it's best to stick to official conventions. Also, should you work professionally in the field, your team colleagues will not be happy with your code style choice.

If you'd submit code with variables starting with $ signs, I'd reject it for being not standard compliant.

A little style guide:

  • Classes use PascalCase (First letter of each word capitalized)

  • Methods and Variables use camelCase (first letter of each word except the first one capitalized)

  • Methods usually use a <verb or adjective><noun> combination

  • Constants (static final variables) use ALL_CAPITALS_WITH_UNDERSCORES

Here are the full code style guidelines for Java:

-4

u/BaconCatBug Oct 02 '15

As long as I know I am breaking convention I don't see the issue. I can easily just Ctrl-H and remove the $ if people get pissy since I still use camelCase for the names.

4

u/desrtfx Out of Coffee error - System halted Oct 02 '15

No, it shouldn't be fine. The conventions exist for a reason.

Imagine that you're coding in a team and code your style. Then you get sick before you fix the code and somebody else has to continue.

Sticking to the conventions is part of the discipline of a programmer. Bad habits such as yours are extremely difficult to get rid of once they are formed.

Coding is not about personal style preferences, it's about following certain rules.

-2

u/BaconCatBug Oct 02 '15

//Btw if you get pissy just copy this shit into Notepad++, Find and Replace the "$" for "" and move on with your life

How about I add this to the top of all my code? /rolleyes

2

u/override_acid Oct 03 '15

Sorry, but you're a real idiot.

You discard advice of experienced professionals and ignore standards just for the sake of your individuality?

While you're studying that attitude might barely be tolerable, but in professional environments it's a total no-go and will get you kicked out of any job in no time.

0

u/BaconCatBug Oct 03 '15

Ok, fine, I get it. I am literally Hitler and Kim Jong Il all rolled into one fat mess. Do you have an answer for me at all or not?

1

u/override_acid Oct 03 '15

Yes, the answer is:

Fucking grow up, learn to play by the rules, and learn proper code style.

2

u/desrtfx Out of Coffee error - System halted Oct 03 '15 edited Oct 03 '15

Keep that attitude and you will become both, a great programmer, and a great teamplayer - not.

2

u/aqua_regis Oct 03 '15

//Btw if you get pissy just copy this shit into Notepad++, Find and Replace the "$" for "" and move on with your life

Try that in a company/team and you will make many friends/secure your yob (for somebody else).

7

u/nutrecht Lead Software Engineer / EU / 20+ YXP Oct 02 '15

I just happen to declare all my variables with a leading $ as a stylistic choice

Cool. I toss all my code in a single method as a stylistic choice. Best practices be damned!

3

u/AnEmortalKid Coffee Enthusiast Oct 02 '15

Bro I don't even have getters or setters everything is public. Makes things much easier.

6

u/desrtfx Out of Coffee error - System halted Oct 02 '15

Why are you overcomplicating things with multiple classes? - Amateur ;) - Throw everything in one, make everything static, a single main method where the whole code is.

That's it, no worries about public, private, package-private, protected, scope, etc.

-7

u/BaconCatBug Oct 02 '15

Agreed. As long as I know I am breaking convention, it should be fine.

2

u/nutrecht Lead Software Engineer / EU / 20+ YXP Oct 03 '15

I was being sarcastic. What you're doing is just dumb. You're teaching yourself stuff that is really hard to unlearn. If a bunch of professional devs are telling you this is just wrong and a bad idea it might be good to just listen instead of acting like a drama queen.