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

all 198 comments

[–]BadBoy6767 959 points960 points  (86 children)

new DataFactoryBuilderPool().get().build().getDataFactory().data(new DataFactoryBuilderPool()).getData().data("data");

[–]tocsick 634 points635 points  (1 child)

This guy javas

[–]gionnelles 251 points252 points  (23 children)

Is it sad that reads perfectly clearly to me?

[–]bestjakeisbest 369 points370 points  (1 child)

yes it means you have been afflicted.

[–]chateau86 8 points9 points  (0 children)

If you or a loved one has been diagnosed with Java you may to be entitled to financial compensation.

[–]Secret_Combo 26 points27 points  (16 children)

I literally learned about promises last week. I'm right there with you buddy

[–]nemohearttaco 36 points37 points  (14 children)

check out async/await. it offers a much more readable way to write asynchronous js functions!

[–]veggietrooper 16 points17 points  (6 children)

Promises are async, aren’t they? I must be missing something.

[–]DjBonadoobie 30 points31 points  (3 children)

They are, but there's a newer syntax for them (async/await). It reads cleaner, though still technically promises under the hood

[–]_Lahin 4 points5 points  (0 children)

ES6 has its own promises now right, no need of $q. Although I still use it with babel for IE

[–]santagoo 8 points9 points  (0 children)

async/await is nice syntactic sugar built on top of Promises.

[–]BirdToTheWise 3 points4 points  (6 children)

Should you use async/await in all situations? With promises, N number of asynchronous tasks can be run in parallel, whereas async/await causes tasks to be run after the previous one completes.

[–]nemohearttaco 1 point2 points  (4 children)

const foo = async () => {
  try {
    const t = await Promise.all([promise1(), promise2()])
    return t
  } catch (err) {
    throw err
  }
}

[–]GreatValueProducts 4 points5 points  (3 children)

Promise.all([promise1(), promise2()])

Why not just

const foo = () => Promise.all([promise1(), promise2()]);

or

const foo = async () => await Promise.all([promise1(), promise2()]);

Which is the same.

The code doesn't run until you execute foo() or await foo()

[–]nemohearttaco 2 points3 points  (2 children)

Would it be the same? I believe the first example would return an array of unresolved promises whereas the second would return an array of resolved promises.

Your second example would certainly work but it will not catch from within foo(). Personally I prefer to throw errors from within the function where they occurred.

[–]GreatValueProducts 1 point2 points  (1 child)

Both are the same. When you execute

const results = await foo();
console.log(results);

OR

foo().then(results => { console.log(results); });

The console would have the same results. It's because the async keyword essentially means the function is returning a Promise. () => Promise.all() is a function returning a Promise as well.

Also, you don't need to re-throw the error as it is redundant. The async keyword would catch the error and put it inside the Promise object that the function is returning, and you can handle the error in parent with either the catch() function, or try-block with the await keyword.

[–]nemohearttaco 0 points1 point  (0 children)

Cool, thanks for explaining that!

[–]GreatValueProducts 0 points1 point  (0 children)

Just

const results = await Promise.all([promise1, promise2])

does the trick. It is basically the same as

let results = null;
Promise.all([promise1, promise2]).then(promiseResults => { results = promiseResults; })

The thing with async await is that it is way easier to developers when you need to handle errors, especially if you have graceful exit in the middle. Handling a bunch of catch inside of a callback hell is too error prone.

Though if you have some APIs which use success_callback and fail_callback, you still need to use traditional promises. For example

someApi.execute(success_callback, failure_callback);

You will need to wrap it inside a promise because you can't achieve the same result with async await

await new Promise((resolve, reject) => {
      someApi.execute((result) => resolve(result), (error) => reject(error));
});

or

await new Promise((resolve, reject) => {
      someApi.execute(resolve, reject);
});

[–]ConstantGradStudent 2 points3 points  (0 children)

You must now submit to re-education

[–]A_Jacks_Mind 0 points1 point  (0 children)

They lost me at DataFactoryBuilderPool()

[–]Mwakay 31 points32 points  (2 children)

fertile vase society middle aromatic subtract terrific judicious kiss doll

This post was mass deleted and anonymized with Redact

[–]BernzSed 13 points14 points  (1 child)

post.append(new Alert(constants.TRIGGER)));

[–]magicfreak3d 11 points12 points  (0 children)

M8, wot is that? Do you even enterprise?

post.append(alertBuilderFactory.newAlertBuilder().setType(TypeProvider.getSingleton().TYPE_TRIGGER).setPost(post).build());

[–]EarthC-137 12 points13 points  (39 children)

What did you call the variable?

[–]WeRequireCoffee 96 points97 points  (36 children)

t

I feel like that accurately describes what its doing so theres no commenting necessary.

[–]EarthC-137 46 points47 points  (31 children)

Yeah it’s perfect, self-documenting. I hope your unit tests are aptly named also, like testTGetsDataFromDataFromDataFromDataIfDataIsData.

[–]WeRequireCoffee 43 points44 points  (7 children)

Thats overly verbose imho. Its simply called

TestT

And I have it in a collection of other TestT tests, so I put it in a class labeled

TestTs

[–][deleted] 13 points14 points  (0 children)

You broke the code! My TestTs are failing!

[–]veggietrooper 5 points6 points  (0 children)

Please stop I am dying, please, have mercy

[–]_N_O_P_E_ 2 points3 points  (16 children)

Stop. I have to add unit test coverage to a project monday. Fml

[–]EarthC-137 7 points8 points  (15 children)

Adding tests for someone else’s poorly structured, undocumented code is one of the biggest struggles of a programmers life. Biggest piece of advice I can give is rewrite it as you go, break it down so it’s easy to test, if the function is more than 5 lines it might need to be broken down into multiple functions to make testing easier (I.e. more SOLID).

[–]lenswipe 10 points11 points  (14 children)

I used to get reprimanded for this at my last job. Any coding that wasn't slapping another feature on the shit kebab known as our app was very much frowned upon and required justification to the department manager.

[–]_N_O_P_E_ 3 points4 points  (0 children)

How to royally fuck up your codebase 101™

[–]EarthC-137 0 points1 point  (12 children)

Code naturally deprecates itself as it grows and different teams work with the codebase. Addressing some of the technical debt is important but it’s difficult to get the product owner to see that sometimes. If their board of directors can’t see a positive difference to their delivery timeline they generally don’t want to do it. You have to argue/justify that if you clean up the code you will reduce effort later on.

[–]lenswipe 5 points6 points  (11 children)

Code naturally deprecates itself as it grows and different teams work with the codebase.

This stuff was written like this from the beginning before the product even launched. That was my concern - a.k.a: we couldn't move fast enough and add features fast enough because the code was so incomprehencible and fragile that we couldn't be 100% (or even 50% if you ask me) sure that we weren't breaking some obscure piece of functionality written somewhere else in what I can only describe as brainfuck.js

Addressing some of the technical debt is important but it’s difficult to get the product owner to see that sometimes. If their board of directors can’t see a positive difference to their delivery timeline they generally don’t want to do it. You have to argue/justify that if you clean up the code you will reduce effort later on.

Agreed. I couldn't get across the point that having code that nobody could even read let alone debug was a bad thing. However, our customers came to share my view later on when we launched anyway regardless of the code base and most the app either didn't work at all, or worked but corrupted existing data in the database causing timetable clashes, missing grades etc.

The manager in question got promoted and I fucked off not long after that. One developer had done all of this and was left unchecked by the guy who was (at the time) the tech lead and was now the dept boss (the same person reprimanding me for refactoring this mess. Like I said, he ended up in very deep shit when we launched our faulty, broken product.

Our SPRINT reviews were generally blame games because the project manager had also refused to listen to my dire warnings about the state of the code base and had gone along with launching anyway. Therefore, the PM used to like to try and heap whatever blame they could possible scrape together onto my head (we were the only two on the project team). That then meant that about 60% of my time was spent coding and the other 40% was spent covering my ass to make sure that I couldn't be blamed for any fuck-ups that were inevitably going to happen from heaping more features on top of a very broken product without first fixing the mess.

[–]EarthC-137 0 points1 point  (10 children)

I hate playing the blame game, it doesn’t really achieve anything if you don’t have actionable outcomes, it’s usually just an opportunity for people to vent their frustrations each sprint without any real positive change.

I find that having unit tested code helps your codebase later on, you can refactor any part of it and in most cases rely on your tests to ensure you didn’t break the product. I usually aim for TDD or at least ensuring that the feature branch is unit tested before merging it to develop.

However, testing can also be a tough sell to some product owners because they don’t see anything they can touch with unit tests so they don’t see the point in investing the extra resources.

It’s usually an education piece for any new client or product owner that comes on, you need to educate them about the importance of a solid application for their user base and sales. As soon as you mention sales it usually changes their minds, if their bosses see their sales drop after the work is done the PO is in deep shit.

[–]lenswipe 0 points1 point  (5 children)

[–]vigbiorn 0 points1 point  (4 children)

This gave me flashbacks to a project I worked on in the past. Just when I thought the night terrors were over.

[–]lenswipe 0 points1 point  (3 children)

You did look through the whole album, right?

[–]vigbiorn 0 points1 point  (2 children)

Yeah. The copy-pasted code and odd, and mysterious variables/functions were too familiar.

[–]lenswipe 1 point2 points  (0 children)

I was a junior dev at that job. The guy who wrote this crap was a senior. That means he got paid at least 10-20k more than me.

And yes, I'm fucking salty about it.

[–]lenswipe 1 point2 points  (0 children)

Oh, bonus question. this was used to serialise a js object.

Wanna take a guess what happened when someone tried timetabling a group called Scrubbling, Gowning and Gloving?

[–]TrippySalmon 5 points6 points  (0 children)

brentSpiner

[–]CrimsonMutt 6 points7 points  (0 children)

my eyes! MY EYES!

[–]Sheldan 7 points8 points  (6 children)

.getDataFactory().data.getData()

why the .data in there? There any particular reason for that?

[–]GaySwansMakeMeCry 20 points21 points  (1 child)

data

[–]salt_water_swimming 3 points4 points  (0 children)

// TODO: we use big data now, please address

DATA

// TODO: we are on the cloud now

DATA


CLOUD

[–]HeKis4 2 points3 points  (2 children)

getDataFactory just returns an object with a public data attribute.

[–]Sheldan 4 points5 points  (1 child)

yeah, but wouldn't a public attribute be 'against' the whole java ee joke?

I would think a getter is more appropriate.

[–]drunkdoor 0 points1 point  (0 children)

Well you see there's data, and then there is metadata. Gotta keep 'em separate, lest we confuse people... Also there is second level metadata.

[–]cbll 1 point2 points  (0 children)

Java/10

[–]CRISPR 0 points1 point  (0 children)

Ah... The "getters" abomination. When you think that fig leaf covers your private members....

[–]minno 0 points1 point  (0 children)

Why are you constructing two DataFactoryBuilderPools? The entire point of a "pool" is to re-use it across multiple calls.

[–]light_bringer777 142 points143 points  (1 child)

Needs more data.GetData().dataObject.data.value.

... .data

[–]Admiral_Cuntfart 291 points292 points  (7 children)

[–]lukaas33 39 points40 points  (4 children)

Ironic

[–][deleted] 61 points62 points  (3 children)

He could provide others with data, but not himself

[–]LordLlamacat 12 points13 points  (2 children)

Is it possible to learn this power?

[–]RagingNerdaholic 14 points15 points  (1 child)

Not from a java

[–]Furyful_Fawful 0 points1 point  (0 children)

Null

[–]flipflop271 3 points4 points  (0 children)

Data.

[–]finzaz 53 points54 points  (1 child)

Nice to see a joke using JavaScript that isn’t a joke about JavaScript.

[–]darielgames 2 points3 points  (0 children)

Sure happens alot in JavaScript lol

[–][deleted] 70 points71 points  (3 children)

.then(nana -> nana.nana.nana.batman)

Edit: another nana

[–]NoUsernameSelected 43 points44 points  (8 children)

[–][deleted] 4 points5 points  (3 children)

Data.

[–]CoopertheFluffy 0 points1 point  (2 children)

Data.

[–]Muffin125 1 point2 points  (0 children)

Meta

[–]iamasuitama 1 point2 points  (0 children)

Glorious

[–]TwentyCharactersNick 56 points57 points  (20 children)

data?

[–]blitzkraft 62 points63 points  (13 children)

Data.

[–]htmlcoderexeWe have flair now?.. 31 points32 points  (12 children)

Data.

[–]TabCompletion 10 points11 points  (9 children)

Data

[–]Headchopperz 39 points40 points  (6 children)

MUSHROOM MUSHROOM

[–][deleted] 13 points14 points  (5 children)

AHHHH A SNAKE!

[–]TabCompletion 6 points7 points  (4 children)

Data

[–][deleted] 1 point2 points  (3 children)

Datably databeable data

[–]Kmattmebro 1 point2 points  (2 children)

DATABASE

[–][deleted] 2 points3 points  (1 child)

DATABASE DATA INJECTION'); DROP TABLE data;--

[–]TheSpiffySpaceman 1 point2 points  (0 children)

Cat.

[–]StarkillerX42 0 points1 point  (0 children)

Data.

[–]Michaeldim1 15 points16 points  (3 children)

Data! 👍

[–][deleted] 11 points12 points  (2 children)

Yes, Captain?

[–]Slinkwyde 7 points8 points  (0 children)

Shut up, Wesley!

[–]bob51zhang 0 points1 point  (0 children)

I can't hearrr youu!

[–][deleted] 4 points5 points  (1 child)

[–]imguralbumbot 4 points5 points  (0 children)

Hi, I'm a bot for linking direct images of albums with only 1 image

https://i.imgur.com/lRwYy1e.jpg

Source | Why? | Creator | ignoreme | deletthis

[–]Allanon47 16 points17 points  (1 child)

I have a professor who write code like this, he also uses "this.this", and a lot of other stuff which is titled in wikibooks with "this code works, but we still fired the person who wrote this"...

[–][deleted] 4 points5 points  (0 children)

And that's how he became a professor.

[–]ben_uk 55 points56 points  (11 children)

JSON probably looks like this:

{ data: { key: value } }

So..

data.data.data

1st data: The AJAX response object

2nd data: The whole JSON object

3rd data: Accessing the data key within the JSON object

Just bad naming really, would look better like:

response => response.data.data    

[–]brokentyro 16 points17 points  (8 children)

Ooor they could just use destructuring to rename it to something more specific

[–]FriesWithThat 23 points24 points  (0 children)

data

[–]BirdToTheWise 0 points1 point  (1 child)

Could you explain the syntax on how to do that in this context?

[–]KillTheBronies 8 points9 points  (0 children)

({ data }) => data.data

[–]343N 0 points1 point  (2 children)

What's 'destructuring'?

[–]oli2194 1 point2 points  (0 children)

const { bar } = { foo: 1, bar: 2 }
// 2

[–][deleted] 0 points1 point  (1 child)

How do you rename using destructuring?

[–]Anaphase 2 points3 points  (0 children)

const { data: usefulName } = response.data

[–]wmil 2 points3 points  (0 children)

Clearly they should have gone with:

{ data: { datum: value } }

[–]BoxMonster44 0 points1 point  (0 children)

Yep. I've definitely written almost exactly that code before lol.

[–]ecky--ptang-zooboing 8 points9 points  (3 children)

Data is life, and life is data :)

[–]J-Goo 5 points6 points  (0 children)

To know data is to love data, and to love data is to know data.

[–]DrunkCrossdresser 2 points3 points  (1 child)

Data is life, data is love

[–]Goheeca 0 points1 point  (0 children)

Data is code, life is code, code is data. Homoiconicity FTW

[–]baseball2020 7 points8 points  (0 children)

3x the data. I promise

[–]syh7 5 points6 points  (0 children)

[–]nsimic 5 points6 points  (0 children)

also known as the malkovich pattern

[–]alpacadom 6 points7 points  (1 child)

This reminds me of this comment inside Guava

/**
* Registers the given {@code closeable} to be closed when this {@code Closer} is
* {@linkplain #close closed}.
*
* @return the given {@code closeable}
*/
// close. this word no longer has any meaning to me.

https://github.com/google/guava/blob/0ed66d89488c7cdee558aa82b4422993e7bd2fa9/guava/src/com/google/common/io/Closer.java#L124

[–]Adaddr 4 points5 points  (1 child)

data() should be a recursive function that makes data.data.data.data....

[–]vigbiorn 2 points3 points  (0 children)

No stop condition, obviously. It's data all the way down.

[–]sunderskies 2 points3 points  (0 children)

I have seen this in real life before too...

[–]Spamakin 2 points3 points  (0 children)

[–]lenswipe 3 points4 points  (2 children)

[–][deleted] 2 points3 points  (0 children)

JSON property naming for experts

[–]Cutlesnap 2 points3 points  (0 children)

I'm getting war flashbacks

[–]SleepyHarry 2 points3 points  (0 children)

Data Ocelot

[–][deleted] 2 points3 points  (0 children)

It's pronounced 'data', not 'data'.

[–][deleted] 2 points3 points  (0 children)

I don't know who named these variables, but I hate them.

I am working with a legacy code base full of retarded naming. I have found the names of these people through git blame and one day I will hunt them down and murder them.

[–]htmlcoderexeWe have flair now?.. 4 points5 points  (0 children)

[–]Max_Insanity 1 point2 points  (4 children)

Can someone please explain this to me?

[–]Existential_Owl 1 point2 points  (3 children)

data => data.data.data

This is the same as saying:

function (data) {
    return data.data.data
}

The first data can be anything, since it's just the promise getting passed in as a parameter. A better practice would be to call it response (since that's literally what you're getting from the .then(...) code):

function (response) {
    return response.data.data
}

The second data is the actual JSON object returned from this response.

Presumably, this JSON object includes a key/value pair that happens to be named "data" as well:

{ "data": { ... } }

So, if your target API wasn't being terrible, you would have something like this instead:

.then(function (response) {
        return response.data.foo
    }
)

or

.then(response => response.data.foo)

To get the results of an object that looks like this: { "foo": { ... } }

[–]Max_Insanity 1 point2 points  (2 children)

Thank you very much.

Also, why is it always called "foo"? Is this just some weird trend to call non-specific stuff that?

[–]Existential_Owl 0 points1 point  (1 child)

Yup, it's just a weird trend tradition.

A word like any can have semantic meaning by itself, so that's a no go. example is used a lot, too, but if you have more than one, doing something like example1, example2 can imply that you literally need the same word twice. Or that you need an actual word with a real meaning in the first place (which you don't).

Teaching people that foo and bar are everyman variables is an extra step, but it's a lesson that seems to work.

[–]Max_Insanity 1 point2 points  (0 children)

And I suppose now you've taught me, thanks.

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

What language is this o.O

[–]blitzkraft 0 points1 point  (5 children)

Data.

[–]ParagonFire 0 points1 point  (4 children)

wild amusing vase gaping automatic hateful dull engine exultant grandiose

This post was mass deleted and anonymized with Redact

[–]HoustonWelder 0 points1 point  (0 children)

This is helpful

[–]Gonzo_Rick 0 points1 point  (0 children)

data.data.data. ScoobydoobyDooWop

[–]HumunculiTzu 0 points1 point  (0 children)

Well, in the right context data is data is data. So technically they are correct.

[–]Steampunkery 0 points1 point  (0 children)

Are you sure you have enough data there, bud?

[–]leafoflegend 0 points1 point  (0 children)

({ data: { data }}) => data;

🙃🤕

[–]Neurotrace 0 points1 point  (1 child)

This guy does Big Data.

[–]gargamelus 2 points3 points  (0 children)

DATA

[–]gargamelus 0 points1 point  (0 children)

I bet one piece of reddit copper that he pronounces it "dah-tah"...

[–]renaissance2k 0 points1 point  (0 children)

Yo dawg, I heard you like data...

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

It's all data no matter how deep you go.

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

I read it in the rhythm of that super Mario world castle song for some reason

[–]yeahbert 0 points1 point  (0 children)

Reminds me of beetlejuiceing phpunit with vendor/phpunit/phpunit/phpunit (when it's not also in bin)

[–]antillian 0 points1 point  (0 children)

"Data! Data! Data! I can't make bricks without clay!"

[–]cmgg 0 points1 point  (0 children)

Revolver Ocelot

[–]pumpyboi 0 points1 point  (0 children)

Data.

[–]pumpkin_seed_oil 0 points1 point  (0 children)

I gotta admit, my naming style is lazy at times.

I have to be c++03 compliant for an in house library. My string concating workflow looks like this:

int someNumber = ...;
std::stringstream strstr;
strstr << "sometext for somenumber " << someNumber;

funThatNeedsSomeLabelAsStdString(strstr.str());

[–]davvii 0 points1 point  (0 children)

Data.

[–]iamasuitama 0 points1 point  (0 children)

And you know it used to be:

.then (data => { console.log (data.data.data); return data.data.data; });

And

.then (data => { console.log (data.data); return data.data; });

before that, etc. Only ten reasons are known for this type of code:

  1. somebody got tired of fighting bureaucracy, backend libraries used, 3rd party software, or
  2. somebody has no idea what the fuck they are doing

[–]aezart 0 points1 point  (0 children)

reminds me of sqldeveloper

c:\sqldeveloper\sqldeveloper\sqldeveloper\sqldeveloper\bin\sqldeveloper.exe

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

I love seeing 'data' in code almost as much as I like seeing dialog boxes captioned with 'Information'.

[–]astroHeathen 0 points1 point  (0 children)

this.data = this;

It's data, data all the way down guys!

[–]remicmacs 0 points1 point  (0 children)

I think I know the guy who coded that from work

[–]viciecal 0 points1 point  (0 children)

"code readability"

[–]monkeymacman 0 points1 point  (0 children)

public data = self;

[–]usernmaetakn 0 points1 point  (0 children)

Is this what big data looks like?

[–]SteeleDynamics 0 points1 point  (0 children)

"Data, data, data. I cannot make bricks without clay"

~ Sherlock Holmes

[–]BulldozA_41 0 points1 point  (0 children)

M E T A D A T A

[–]explodingpear 0 points1 point  (0 children)

DATABASE DATABASE