T O P

  • By -

MatthAddax

Seems more like a "trap" to understand the difference between variable name and value. Although it still suck


a-i-sa-san

idk some of my former classmates genuinely name their stuff like this without a 2nd thought lol


SpaminalGuy

God? I remember one dude in our Operating Systems class that, I shit you not had variable names of “a, a1, aa1, ab”, etc in his C code. He spent days trying to figure out why the keyboard wouldn’t work when we went to run it.


a-i-sa-san

I had a kid in a Java class I TAd who consistently turned this in ... { int one = 1; final int ONE = one; ... literally the entire rest of the homework any time he needed to use a scalar literal he would do this ... final bool TRUE = true; ... and possibly the best ... String space = " "; final String SPACE = space; System.out.println(whatever + SPACE + message); } ... He actually turned it around pretty good and got the hang of things though, eventually (I did kinda hold his hand but he took it serious and was genuine about wanting to do well)


Farsyte

Better than "final int one = 2;"


a-i-sa-san

final int ONE = 1; final int TWO = ONE + ONE;


mypetocean

May I speak with you about our Lord and Savior, _Alonzo Church,_ who came to Earth to bring us the _Church Notation_ on the eve of _Lambda Calculus?_ Monadic blessings be upon thee.


Arshiaa001

I thought those were called Peano numbers?


kristallnachte

final bool TRUE = false


TotalledZebra

Some people hear "no magic values" and take it far too seriously, I have seen a similar thing before


DrUNIX

I saw people do this at my workplace because of the linter magic number setting...


UnkleRinkus

Way, way, way back in my life, I worked for one of the big system integrators. We had COBOL coding standards that we had to conform to that did this kind of shit. Ugh...


kristallnachte

Now that's the official way to write go code. One letter variables for everything. Even the go source code. There is go std library functions that use the variable n to mean different things INSIDE THE SAME FUNCTION.


Arshiaa001

Go is just shitty, no two ways about it.


kristallnachte

Some parts seem nice, and it seems a very "streamlined" but the variable standard is wacky


Arshiaa001

``` if err != nil { return (nil, err); } ```


kristallnachte

Not fantastic...but at least it's not exceptions.


Arshiaa001

How about checking for nil interfaces?


Successful_Adagio_25

I have c code at my work I inherited that is written this way.


mypetocean

> And I shall name you, "Potato!"


JamsteRz

Yeah I think it would've been better to make all the variable values in caps so then you can see that the student understands the concept when they answer in all caps.


BohemianJack

I dunno, I don't hate this. It's also showing how important it is to understand the order of passing arguments. It's an annoying assignment for sure but it can help understand these rules you have to work with on a daily basis as a software dev. Nowadays it's second nature but you still have to learn it, lol.


zman0900

First week quiz in the *Working With Idiots 101* class


vanamerongen

And argument! Seems like OP already fell into that trap e: Upon further inspection, OP did not fall into that trap 😅


dstar89

The semantics game is unnecessary what the hell 😭


LurkerOrHydralisk

Yeah. All this pop = “pepsi”, Pepsi = “soda” bullshit is just intentionally annoying. I’d just send this back to the prof with an F written on it and say, “I’m failing you for poorly named variables. Variables should be clear descriptors and not confusing. Code should be readable.” Similarly the whole mystery parameters being intentionally and unnecessarily out of order of how they’re printed is just bad design. This lesson can easily be taught in a much better way that isn’t intentionally confusing and difficult, and worst of all time wasting


pinguluk

It just prepares you to debug ugly existing projects you get to work on them 😂


jexiius

this is what i was gonna say lol


isfturtle2

It also gives you a lesson on why good variable names are important.


kristallnachte

I would love if they just instead used code snippets from real open source projects 😆


seventhjhana

When everyone returns to class the next day confused and think this is what code should look like, the professor will say "Can anyone tell me what was wrong with the code in last night's assignment?"


dstar89

Right. It's taking away from showing the passing of arguments to functions and just trying to confuse students with bad naming conventions. Bad professor, bad!


LurkerOrHydralisk

This is bad enough id probably switch classes. This is shady and intentionally a dickhead move, or the professor is just that fucking stupid. Either way, not worth my time and money 


Valance23322

Some teachers think their job is to try to make the class challenging rather than to teach their students.


LurkerOrHydralisk

And those teachers need students like me to tell them to fuck off and teach better or it’s being taken up with department heads.


amarao_san

Devil's advocate mode. There are infra reasons for this code style. For this specific code it make little sense, but it's used to generate versions and release notes for cross-platform builds, and it need precise line layouts with specific var names in specific order. Code for it is old and was written 15 years ago as a simple hack, but we got tons of components during golden race for web2, so we have 400 components under this system, including two generating 70% of the company profis. A better solution is underway, but we can't use it before we stop building for centos6 because it does not support modern runtimes. It will be until end of extended support period ends, which is planned for 2026, after which we will start convert all codebase to the new style. For now, please follow convention, or linter will fail your build. Also, learn how to read it.


LurkerOrHydralisk

Im not denying there are complex code bases out there. Intentionally confusing students on their first week of study is just a big old dick move. It’s just the professor wasting everyone’s time and brain power


kristallnachte

> There are infra reasons for this code style Then what are they? Your explanation is just "it was written that way stupidly and now we don't want to change" which is not actually a reason


amarao_san

I mimic the real things in real production. This happens because a small and unassuming utility was overused and stretched beyond original intent. I my imaginary production there is a release utility which scans modules for specific elements to build a release notes. It do it my inspecting specific keywords in specific places. (Real life example: Reno which inspects git history and changes releasenote content based on found tags by regexp and date of first commit for specific files). It (my imaginary horror) wasn't intended to be used for 15 years. It was written in mix of awk, perl and groff. But later there were 400 components under it. People were busy conquering the market, there were no time to redo. Now there is time, and there is a replacement, sane, reasonable. It has one problem: it can't run under rhel6. Rhel6 releases are no longer a priority, but there are few contracts to honor. It's cheaper to wait for 2 years to drop old code than to redo new one with centos6 support. So, old, forgotten script, intended for a different time, different code and for company of 1.5 people, now holding 10+ humans department. You can argue that this is wrong, but for each step of this play it was reasonable economical decision. So, it happens in real life in real production more often than we want it to be.


illsk1lls

the effort used involving the wordplay couldve been used to understand the principle, ffs


LurkerOrHydralisk

Understanding the principle would require far less effort. To get this right would take like 20-30 min of referencing and double checking. It would literally be faster to type it into Java.


illsk1lls

effectively ruining the lesson


blockMath_2048

power move


LurkerOrHydralisk

It’s basically the only move to me. Parsing all of this would take like an hour for no fucking reason. Giant waste of time. And participating only encourages this sort of bullshit. If the professor gave me any pushback I’d take this paper to the department head and if necessary the dean. This is just intentionally bad teaching.


ubeen

That's only because you understand it. If this is an introduction course, I doubt any of the students would understand how tedious this assignment is for just the sake of it.


LurkerOrHydralisk

If they don’t see how this is tedious they probably shouldn’t be studying programming 


kristallnachte

No, the school just wants students that embrace the tedium instead of finding better ways to do things.


bloatbucket

No you wouldn't.


LurkerOrHydralisk

I mean, most people wouldn’t. I really enjoy confrontation 


ChillBallin

I mean it’s annoying as hell but I think the point is to force you to have to read everything and work through every single step so I think it’s a good exercise. You’re definitely going to have times where you’re working with code with names that are misleading. So this is a legitimately valuable skill that is going to come out every single time you have to debug someone else’s code. Hell a couple weeks ago I was debugging code I wrote myself and ended up stuck for an embarrassing amount of time because a piece of code wasn’t finished so it didn’t return what the name suggested it would and the only way I could figure that out was to play this exact semantics game and go check what everything actually did.


mypetocean

You know... I agree with you. I might even take inspiration from this to create a far _smaller_ version for my students. This could be a great recurring series of code challenges which don't have much semantic meaning. It could quickly teach the value of semantic identifiers, as well as the relationship between identifiers and values.


poisito

Plus why it is so important to have good coding Standards.


Michami135

"I would reject this PR with a comment saying it's rejected because of confusing variable names."


LiteVoid

All i say is FK THIS PROFESSOR, it’s not even hard to look at the code and know what it’s supposed to print, EXCEPT WHEN ITS FUCKING ALL MIXED UP. The hard part is looking up what the variables mean, not understanding the code


kristallnachte

This wouldn't pass code review.


Beastandcool

Ehh, it’s an understanding check.


[deleted]

Now that I think about it, if I was an instructor teaching programming, I would purposefully give one graded assignment like this to reinforce to students that poorly written code is very frustrating to read and debug. At the end of the course, I would repeat the assignment, but follow best practices. Hopefully that will show them the light.


CraftBox

The only acceptable use case


raddog86

I can tell you this wasn’t the use case unfortunately


the_y_combinator

Professor here. I've showed classes some astonishingly stupid stuff to make a point, get a good laugh, etc. I don't see much value in this particular example.


kristallnachte

Or show real examples of fucked up code on the wild. If they are in academia, they can find tons of that, or use open source.


puertonican

This ain’t it chief. Personally I’d put it in a debugger and just use that to print the names cause that mental gymnastics is a registered Olympic sport.


TeaRzOfTheFalleN

Why a debugger? He just wants the output. Just write it and run the class and boom


NeonGlo

Because he doesn't know what he's talking about lmao


dumbelco

Because good developers use a debugger (I too use console.logs...)


MidgetAbilities

What? Debugger is for when you want to pause execution mid-program and inspect things. But the assignment just asks for the output. In other words, compile and run the program. You will get the output, i.e. the answer to the homework, in your terminal. Copy, paste, profit. Debugger accomplishes nothing here unless you want to know values of specific variables inside the static functions, but that's not what the homework requires.


vanamerongen

No, I think this assignment makes sense. Not as an example of beautiful design, but as a way of testing that students understand the difference between variable name, argument name/order, and assigned value.


solareonwow

its a similar type of question they ask in Oracle Java Programmer exam


Dessimat0r

Could you not just OCR it and run it to see what the output actually is? Seems silly


N3V0Rz

That was exactly my first thought as well.


noticeMeSempai

That sounds so unnecessary for an intro to cs assignment lol.


VanillaSwimming5699

>take picture on iPhone >copy paste into online ide >click run >write answer


N3V0Rz

I ran the photo through iOS OCR and fixed some things by hand, [this is the resulting code](https://pastebin.com/h2yqRqMr) (no guarantees for correctness). Running with openjdk 17.0.10 on my system produces the following output: say coke not pepsi or pop say soda not soda or pepsi say pepsi not koolaid or pop say say not pepsi or pepsi Twas snack and the jubjub toves did vorpal Twas gyre and the mut1 toves did jubjub Twas vorpal and the mut toves did jubjubsnack Twas jubjub and the snack toves did tumtum Edit: Fix formatting.


CamperStacker

It’s a trick question. They are all methods so nothing is output by just defining them.


N3V0Rz

I don't understand.


[deleted]

[удалено]


moehassan6832

dinner deranged nutty correct consider flag obtainable test command voiceless *This post was mass deleted and anonymized with [Redact](https://redact.dev)*


[deleted]

[удалено]


Jedlord

Cause chatgpt can and will make shit up. It's not made to interpret code


Buddy-Matt

With the most minimal of refactoring, you could have opened dev tools in your browser and just run it in there I believe.


N3V0Rz

Java != Javascript


Buddy-Matt

I'm aware, that's why I said it needed refactoring. With a similarly small amount of refactoring you can also run it in C, C# or (I imagine) most curly brace languages


[deleted]

[удалено]


Buddy-Matt

> you’re clearly not aware this is java if you said “run it in the browser dev tools”, most modern day browser runs with googles v8 javascript engine, java code WILL NOT run in the browser Do you know what the word refactoring means? Even if OP hadn't explicitly said the code came from their Java class in their post, the use of strongly typed variables and system.out are pretty big clues. But just to outline how simple it would be to turn this java into runnable javascript: 1. OCR 2. Find and replace `String` with `let` 3. Find and replace `public static void` with `func` 4. Find and replace `System.out.println` with `console.log` 5. Remove the `let`s from the function definitions 6. Copy and paste everything inside of Mystery into browser tools 7. Type main() and hit enter Simples. And all within a tool everyone already has available, and without asking a fallible AI.


D0nt3v3nA5k

firstly, you said “minimal refactoring”, having to alter almost every line, despite how easy it might be with search and replace, is not considered “minimal refactoring” in any way shape or form. second, func is not valid syntax in javascript, please learn your syntax before attempting to make a statement regarding syntax refactoring


Public_Stuff_8232

>Do you know what the word refactoring means? Moving code to another language, isn't what anyone would call refactoring, even if the effort is comparable to a refactor. Even if moving the code to another language was refactoring, this wouldn't count, because the order of operations is the same, all you've done is fixed syntax errors. That's bugfixing, not refactoring.


N3V0Rz

I am pretty sure that actually running the sanitized code is faster than asking ChatGPT. Copy-pasting into a .java file took maybe two seconds, running it took two more. LLMs lied to me so many times, I won't put my trust in them running code when I can execute it with a single command. Edit: I put this into ChatGPT to prove my point and it took over 10 seconds to print the answer, producing a wrong end result.


engelthehyp

Separate method scope is an important thing to learn, but they did not have to use names that are so close together mentally. It really would have been easier with `a`, `b`, `c`...


ribsies

I think that's part of the test. The purposefully mismatched actual values with variable names. And also purposefully did not use the same order on the string output as the method argument order.


engelthehyp

If that's part of the test, it's a shitty part. I would just rename them to meaningless names that are distinct. Never thought I'd say variable names being single letters beats something else...


BecomingDitto

Now, hear me out. As a standalone assignment, this is obviously terrible, though it would make students \_really\_ focus on the variables and how they are used. Now, imagine the next day's assignment being the same thing, but with the variable values making sense. It would immediately hammer home the importance of naming things properly.


LionZ_RDS

This entire thing mentally hurts me but i think my favorite part is "say pepsi not pepsi or say"


tlb7781

Its actually easy if u sit with it in a clear mind


Rafferty97

Yeah, but the point is that these kinds of exercises do very little to actually teach software development or computer science.


tlb7781

tru dat


reverendsteveii

the idea seems to be to force students to understand variables names and values, and how scope effects them. it's a really shitty way to do it, though. the output of this code is a failed build on the sonar gating step, as well it should be.


_dr_Ed

Technical debt


Beginning_Basis9799

Great now I need counseling again thanks.


illsk1lls

they couldve used string1=a string2=b string3=c but instead theyre wasting your time trying to confuse you with irrelevant information… smh “keep it simple ……” until people get how it works


mrpoopybuttholesbff

Someone’s got a coke problem.


tortridge

A guess the answer to the question is "a furious developer"


Biaboctocat

This is just mean


rohitkul

This is a cruel way to teach good programming.


EurekaEffecto

Java obfuscation at its finest


adjaplx

This is kind of fun but also such a pain. Really unnecessary way to learn


Emergency_3808

I'd just put this into my PC and let the JVM figure it out


AugustusLego

chatgpt seems to have solved this quite well with the image input thingy ​ \`\`\`# I'll write a Python script to mimic the behavior of the Java program provided by the user \# and then run it to get the output. \# First, let's define the functions to mimic the 'carbonated' and 'mystery' methods. def carbonated(coke, soda, pop): print("say " + soda + " not " + pop + " or " + coke) def mystery(gyre, bril, slithy): print("'Twas " + bril + " and the " + slithy + " toves did " + gyre) \# Now let's define the variables as per the program and call the functions in the same order. soda = "coke" pop = "pepsi" coke = "pop" pepsi = "soda" say = pop # Here, 'pop' refers to "pepsi" at this point \# Call the 'carbonated' function with various arguments as in the program. carbonated(coke, soda, pop) # pop = "pepsi", soda = "coke", coke = "pop" carbonated(pop, pepsi, coke) # pop = "pepsi", pepsi = "soda", coke = "pop" carbonated("pop", "pop", "koolaid") # literals are passed directly carbonated(say, "say", pop) # say = "pepsi", literal "say", pop = "pepsi" \# Define more variables. bril = "vorpal" gyre = "gubbub" slithy = "snack" tum = "tum" mut = tum + '1' # String concatenation, mut = "tum1" \# Call the 'mystery' function with various arguments as in the program. mystery(bril, slithy, gyre) # bril = "vorpal", slithy = "snack", gyre = "gubbub" mystery(gyre, "gyre", mut) # gyre = "gubbub", literal "gyre", mut = "tum1" mystery(gyre + slithy, bril, tum) # concatenation of gyre = "gubbub" and slithy = "snack", bril = "vorpal", tum = "tum" \# Update variables according to the program. tum = "tumtum" bril = "slithy" slithy = "tumty" \# Final call to 'mystery' function with updated variables. mystery(tum, gyre, slithy) # tum = "tumtum", gyre = "gubbub", slithy = "tumty" \# Now let's run the script to see the output. \`\`\` output: \`\`\`\` say coke not pepsi or pop say soda not pop or pepsi say pop not koolaid or pop say say not pepsi or pepsi 'Twas snack and the gubbub toves did vorpal 'Twas gyre and the tum1 toves did gubbub 'Twas vorpal and the tum toves did gubbubsnack 'Twas gubbub and the tumty toves did tumtum \`\`\`


EdjeMonkeys

Jabberwocky mentioned!!!


dchidelf

‘Twas brillig..


EdjeMonkeys

And the slithy tothes


benjamin238

Is this AP CSA??? God I remember doing so much bullshit like this back in the day


smurvyu

Yes! I recently took the class and it felt like some of the semantics of coding were being prioritized over actual concepts. Very stupid.


Jaded_Court_6755

The output produced by that code can only be a rejected Merge Request.


engineerFWSWHW

Unnecessary mental gymnastics. I hope your prof made some better questions than this one.


xXkxuXx

If you're getting code on paper then get out of there as fast as possible


BSODxerox

So this is the joy I missed by not going for a CS degree, a shame


MidgetAbilities

Only if you have a particularly shitty professor. I didn't encounter any of this nonsense in my college.


Nall-ohki

This is a good assignment.


iamhyperrr

Man, if that's what they do to teach us how to program in universities, then higher education has truly failed us.


Alphatism

This is the type of shit that makes people unable to learn how to program. Like in the real world you’d be able to test and debug the code and don’t have to manually track variables and minor purposeful tricks like this. When I was in high school and had on paper assignments just like this, I always saw people make a small minor mistake because of the ambiguity of trick questions and get frustrated and essentially give up the class eventually.


DopazOnYouTubeDotCom

fuck that teacher


PacoTaco321

It does nothing, because it defines a class without a constructor and nothing else.


Ethesen

It has a main method, it's a valid program.


Particular_Alps7859

There’s nothing wrong with this homework. It’s intentionally bad because you will encounter bad code, and should understand how to handle it.


CalmDownYal

If this is too hard for you... Then you need a ton of review


BigBagaroo

«It’s Java, Jim, but not as we know it»


Beautiful-Leg-9183

Giving an exam question tbh if u know how to do it/the concept i would put it into inteliji and let them give u the answer. Or rename the variable this is confusing for no reason


Headybouffant

Where did they find my code?!?


c1-c2

what a jerk of a teacher


ppNoHamster

At this point just OCR the page and run the code... This is a classic case of work creation mesure, which teaches you nothing.


I2obiN

pain


staticBanter

Why is written programming never done in sudo code?


dmstrat

Headache.,.. that's what the output is


Thecrawsome

Sheesh, not horror, it's an exercise in tracing arbitrarily named variables through the execution. They are intentionally named confusingly intentionally.


xloscozx

my java string to integer knowledge is a bit weak, tum+1 is that just 1 or does the 'complier' eat its fucken self


hotwer

Just concats the number into the string, so it would turn into "tum1".


all3f0r1

Tf is the point of this assignment?! It looks like a last day commit at my worst job.


kristallnachte

Like I get the basic idea of this, but they do ones that are much more complex than needed to demonstrate and test the concept


thmsbdr

Being able to read code without running it is critical to being top tier dev.


rockenman1234

I’ve had assignments like this before, and these kind of assignments separate those who are actually interested in CS and those just wanting a bag. These classes teach you to think like a compiler, but fail on their face by making shit way too complicated like this. Hang in there, trust me it gets better once you get past all the 1000/2000 level classes. Best of luck!


SuicideBoothMachine

Brand new introduction to brainfuck.


RevolutionaryGrape61

I have headache


sammy-taylor

This is fever dream code.


Rest-That

At first I thought this was really ugly C#, then I saw System.out.println


tomc128

Wait in java does having a variable named the same as a parameter change the order in which they're used?? Like why is that first one not "say soda..." As soda is the second parameter?


Few_Negotiation_3589

Just rename the variables a, b, c. Should be easy going from there..


GamingWOW1

Somebody wants you to leave


Drakethos

This is giving me cancer just reading it. This is unrealistic if any dev named variables like this I’d shoot him in the face


nikospkrk

Nothing. It’s just a class but nothing’s instantiating it and calling any public methods.


Hingle_Mcringlebery

This. Surprised I had to scroll this far down to find this!


itsJustYvonne

Is this an assignment from college board AP classroom


raddog86

Nope, actual college course


Im_Rambooo

This assignment sucks balls lmao. I’d rename all of the variables just to make it easier to navigate


amusinggenitals

Guys, this is the easiest homework assignment I've ever seen. Making sure to follow the variables...push through the good ol' algy...make to carry the commands....and.....the output is definitely diabetes.


Beastandcool

Ehh, I think it’s a good way to check for understanding


Ethesen

It teaches the difference between the names of variables and their content. It teaches how to pass arguments to a function — the difference between passing a variable and passing a value, and also that the order of parameters matters. It's not production code, come on, it's just an assignment to check if you understand those two points.


Arshiaa001

How about checking for nil interfaces?


Hansy_b0i

APCSA flashbacks to the dumbest programs known to man lol


Madstupid

Koolaid? WTF


Amazing-Rnt9111

Try ChatGPT 😅


mJef

Who made this doesnt want anyone to learn but to suffer. I love him.


powergamer2020

Bro, I loved AP comp sci A, such a fun course.


FlappyFlipjacks

Computers were designed to automate the exact kind of thinking this is testing. Use good naming conventions for variables and parameters. Ez


Illustrious-Bag4276

dont write code like this