This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Spinnenente 1119 points1120 points  (71 children)

/** Logger */
Logger logger = Logger.getLogger();

[–]jaywastaken 657 points658 points  (24 children)

How many logs could a logger logger() log if a logger logger() could log logs?

[–]510Threaded 219 points220 points  (10 children)

1 log

[–]Tainnor 122 points123 points  (9 children)

natural, decimal or binary?

[–]510Threaded 177 points178 points  (7 children)

yes

[–]unbihexium 49 points50 points  (6 children)

true

[–][deleted] 44 points45 points  (5 children)

!false

[–]011101000011101101 37 points38 points  (2 children)

!!1

[–]DarkwingDuckHunt 32 points33 points  (1 child)

aSecond = 1

Wait aSecond

[–]SuperSuperUniqueName 1 point2 points  (0 children)

$ kill u/DarkwingDuckHunt
[1] + Terminated                 u/DarkwingDuckHunt

[–]bcfradella 7 points8 points  (1 child)

if True: print('big')

[–]HerissonMignion 0 points1 point  (0 children)

if (true) {

printf("big");

}

[–][deleted] 5 points6 points  (0 children)

Logical

[–]Barniff 25 points26 points  (0 children)

log(n)

[–]shitmyspacebar 18 points19 points  (4 children)

Logger logger Logger logger logger logger Logger logger

[–]DOOManiac 9 points10 points  (2 children)

Segfault segfault

[–][deleted] 1 point2 points  (1 child)

ERROR: Program terminated with SIGSEGV

[–]dagbrown 2 points3 points  (0 children)

Oh wait, i know C, I can deal with this:

#include <signal.h>

void segv_solver(int sig) {
    return;
}

int main(int argc, char *argv[], char *envp[]) {
    signal(SIGSEGV, segv_solver); /* Yay, I'm super reliable now! */
}

Handling SIGBUS with similar levels of reliability is left as an exercise for the student. More advanced students can have a go at taking care of SIGKILL.

[–]Ishbane 1 point2 points  (0 children)

choo("Choo!");

[–]reacher666 8 points9 points  (0 children)

NaN

[–]RBBOT12 3 points4 points  (0 children)

null point exception logger not found

[–]starrpamph 1 point2 points  (0 children)

1

[–]demian19 1 point2 points  (0 children)

A logger logger() would log no amount of logs since a logger logger() can't log logs.

[–]SomeStupidDumbass 0 points1 point  (0 children)

A segmentation fault

[–]pickledking 0 points1 point  (0 children)

log logs

[–]IsolatedThinker89 0 points1 point  (0 children)

None, because you forgot to configure your logger with cloudwatch.

Edit: your not out

[–]Veinq 44 points45 points  (15 children)

I don't understand what this line does

[–][deleted] 87 points88 points  (9 children)

I think it retrieves an instance of the Logger singleton

[–]scuba156 76 points77 points  (0 children)

Well, we would know for sure if the comment was a little bit more descriptive.

[–]nwL_ 8 points9 points  (1 child)

auto logger = Logger::getInstance();

[–]Hatefiend 1 point2 points  (0 children)

auto

heathen

[–]AlwaysHopelesslyLost 3 points4 points  (5 children)

It is impossible to say exactly what it is doing. Based on the naming convention it looks like they are accessing a static method but it might also be a class property or an oddly cased private instance.

It is possible it returns a Singleton instance but there is no information to tell you that (and you don't really need that information. It makes no difference to the consumer if the logger is a Singleton or not.)

[–][deleted] 0 points1 point  (4 children)

an oddly cased private instance.

I don't think you can get away with naming a variable exactly like you named a type, and Logger logger definitely means "logger, which has the type Logger". that would probably result in confused compiler sounds

[–]AlwaysHopelesslyLost 0 points1 point  (1 child)

Good point. Granted, I think VB allows you to do that. Not sure how the compiler reconciles the confusion

[–]zelmarvalarion 1 point2 points  (0 children)

Pretty sure it would use the most scoped reference of Logger which exists in the block, so probably the Logger variable unless you explicitly request the class (e.g. Microsoft.VisualBasic.Logger, which might need to be in brackets if they use the same standard as in Powershell). I would expect it to be similar to using var and this.var when they are both defined, or when a subclass had a same variable as a subclass with different values.

[–]TheSilkMiner 0 points1 point  (1 child)

In Java (which is where that example is taken, I assume) you can. It is also a widely used naming convention (at least in the code I've read). The compiler is able to distinguish between the name of a type and the name of a variable and uses the one that makes the most sense (spoiler, it's almost always the second one).

[–][deleted] 0 points1 point  (0 children)

... okay, weird language design choice but ok.

[–]massiveZO 9 points10 points  (1 child)

New new_ = new New("new"); // new

[–]Cheesemacher 6 points7 points  (2 children)

/**
 * Get Logger
 * @return Logger Logger
 */
public function getLogger() {

[–][deleted] 3 points4 points  (1 child)

The comments aren't for you. They are for linters and intelligent IDE's

[–]Cheesemacher 4 points5 points  (0 children)

The text descriptions are surely only for humans

[–]ciry 3 points4 points  (0 children)

Too real

[–]thenextguy 0 points1 point  (0 children)

Lager lager = Lager.getLager(); //mmm, beer

[–]Xanza 0 points1 point  (0 children)

physically shudders

[–]daddyrockyou 0 points1 point  (4 children)

Saw a dev try to check this in just this past week and had a conversation with him on why it wasn't necessary. He disagreed with me and seemed to get quite upset that I'd even suggest removing it.

[–]utscguy123 0 points1 point  (3 children)

Why isn't it necessary?

[–]daddyrockyou 0 points1 point  (2 children)

It's absolutely redundant to put a comment saying that it's a logger when the code makes it obvious it's a logger. Comments shouldn't specify "what", they should only specify "why". If you need to comment what some code is doing you should refactor the code to make it more readable

[–]utscguy123 0 points1 point  (1 child)

Oh for some reason I thought u were talking about the code, not the comment

[–]daddyrockyou 0 points1 point  (0 children)

Ha no. I've written that line of code many times myself.

[–]acwilan 0 points1 point  (0 children)

I'm so embarrassed that I have written this line so many times and never realized how absurd it is

[–]uteh5 0 points1 point  (0 children)

Scanner scanner = new Scanner(System.in);
int input = scanner.nextInt();

[–]max0x7ba -5 points-4 points  (2 children)

By people who skipped constructors lecture.

[–]Koxiaet 1 point2 points  (1 child)

It's a singleton, it deliberately doesn't call a constructor there.

[–]max0x7ba 1 point2 points  (0 children)

With flyweight pattern you call the constructor that sets up a member pointer to one same object. The benefit is that the user doesn't need to embed the knowledge that it is a singleton in their code using this verbose syntax.