What are your thoughts on declaring constant variables in an interface? I thought the idea was brilliant...

What are your thoughts on declaring constant variables in an interface? I thought the idea was brilliant, but then I noticed in my book that they claimed that this was very controversial. I do not understand the problems with this.

By the way people who write{
like this
}

Instead of
{
like this
}

should kill themselves. It is a dumb practice picked up by people who saw it in their "how to program" textbook, not realizing that the book only does this for the technical reason of saving space on the paper.

pleb tier

BLASPHEMY!
K&R STYLE IS THE ONE TRUE STYLE!

...

There is literally nothing wrong wtih Java.

...

Bullshit.
Read the Kernel style guidelines before you spew more ignorance.

The VM is so slow interpreted languages are faster.
The language is so verbose it's basically IDE assembly.
The average dev is so incompetent you might just emigrate to India.

Yeah, pretty much nothing.

Interfaces really shouldn't be used to house a function. An interface is a little like a socket. A power socket can be used for many things, but you should never take off the outlet and wire a device directly into the home power supply with a few exceptions, mostly for monetary reasons (lightbulbs go in light sockets).

For this same reason, interfaces should only be used to house a reference to a function.

If you must use a function inside of an interface, you really should not be using global variables within it. Since in this case const variables are accessable throughout the program.

You've basically taken the wires out of the wall and added wires to them. It's just bad policy.

The best option would be to create an enum somewhere else in the program and access that with the interface, if you must use a global option at all.

my knowledge of java is limited, try to excuse errors here

Bullshit. All benchmarks show the JVM is faster than interpreted languages, and that is without even letting the JVM warm up.
What the fuck do you mean with this.
:^)

...

(Checked)

It is not bad per se, but it doesn't make much sense... unless we're talking about Java 8. Java 8 incorporates default methods which make interfaces much more than a "contract", so to speak; they can be used as a quick way to add components to other classes, and can also be used like mixins. If you think of interfaces as mixins, then it is perfectly valid.

My Java book uses Allman style, your argument is invalid. Fuck, the OFFICIAL Java code conventions state that K&R is preferred, and they are digital so they have no paper restriction.

CM pls

void reply() { System.out.println("Not writing like this");}

TBH it makes perfect sense for interfaces to declare enums or constants, e.g. for use in function arguments.

...

...

This is how I was thinking since they're just constants. Although they are public, you won't be modifying them at all, so what harm could be done?


Don't give a fuck. Your retard way makes it so confusing identifying when something begins or ends when a bunch of shit is nested in it


Class FuckYou{
public static void main(String [] args){
while(true){
for(int i = 0; i < 3; i++){
if(i % 2 == 0){
System.out.println("fuck you");
}
}
}
}
}


What an eyesore.

And what would you prefer? Magic numbers? Regular variables of which someone could modify by mistake, not knowing that they were not supposed to?

Enums is something different altogether since they are a type and thus make sense to be used in function prototypes (ie. you want to send a service code to a parameter). You can't use a constant in a function prototype.

What do you exactly want to do with these constants, OP? I am sure there must be a more logical way to structure it.

What if a constant could be used in all classes, such as the maximum size of an array? You can make an interface declaring only constant variables, and make the classes just implement that methodless interface rather than going through all classes, and typing out the constants to all of them who need it.

#define

You can figure this one out on your own, you just have to think for a moment.

Even suggesting OOP for anything is wrong, let alone enforcing OOP for everything.

I have never seen #define in Java.


A variable that will always stay at a fixed, constant value that cannot be changed. A variable that will stay constant. Hmmm...

Ideally, you should be using a static method from a class to get the "constant" array size. This way, if at any given moment you want to modify the value without recompiling or whatever, you could easily implement reading from a config file. This should be specially true if you want to hold several constants; at least use an enum because "implements Constants", while valid, sounds dirty as fuck. Interfaces were never made for that abomination.


There are no preprocessors in Java.


Why is OOP so triggering for /g/furs Holla Forumstards?

Class fuckYou{ public static void main(String[] args) { while (true) { for (int i = 0; i < 3; i++) { if (i % 2 == 0) System.out.println("fuck you"); } } }}

Man, proportional font made the indentation look a lot smaller than it came out.

Never go full pleb Holla Forums

In the previous Holla Forums challenge we had, Java-user's code took longer just to start than most solutions in interpreted languages took to complete. bash-user's shellscript garbage was even much faster.

It's too hard for them to comprehend. So they get mad at it.

Please user, "controversial" was the big buzzword of the day about 10 years ago before it got replaced with various types of (((virtue signaling))).


This is nigger-tier logic.


Pick one, furfag.

there is a reason why "hello world" isn't used as a benchmark

java right? this is no longer controversial. They blew up any ideological purity interfaces once had when they introduced default implementations and the diamond problem in java 8.

Discussing a relic meme language from the 90's

Not a java programmer, but I think the real question is. Can i use a goto in java?

Because goto's and global variables are where its at.

Also how do I get ring level 0 execution. (any chance of a negative ring execution?)

The real question is why you need to attach an interface to what is very clearly a global varia-


nevermind, this thread is dead.

No one could have made faster code, it literally took 100 times longer _to start_ than the others did _to run_.

That's literally the worst thing ever.

fuck off india nigger

I don't see the issue with it, if it makes sense to do so.
inb4 semantics

oh god! yuck!

java doesn't have constants a la c. you can make primitive variables effectively constant with final static, but they are still variables and are constant

>add < 70mb of memory overhead


fuuuuuug

public static void main

Anything wrong with putting the constants in a utility class?

A public method of the main application class
The method is static. Aka can be accessed without instantiating the class
Method doesn't return a value

Not so much verbose as it is descriptive.
Personally I prefer it over mucking about in .h files trying to figure out what methods are public/private/protected.

Are you fucking retarded, Pajeet?
class Poo{ private: int usedLoos; std::vector loos; public: Poo(int nLoos); bool pooInTheLoo();};
Is that really too hard to understand for you?

Java still looks better with the visibility being put in front of the method declaration in my opinion.

...

I see nothing wrong with default implementations on interfaces. It lets you make changes to an interface without crashing the entire program with no survivors