@Service
public class FizzStringPrinter implements StringPrinter {
// ...
public void print() {
final StringStringReturner myFizzStringReturner = this._fizzStringReturnerFactory
.createStringStringReturner();
final FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter myOutputAdapter =
new FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter(
this._systemOutFizzBuzzOutputStrategyFactory.createOutputStrategy());
myOutputAdapter.output(myFizzStringReturner.getReturnString());
}
}
"So this week, we're introducing a general-purpose tool-building factory factory factory, so that all of your different tool factory factories can be produced by a single, unified factory. The factory factory factory will produce only the tool factory factories that you actually need, and each of those factory factories will produce a single factory based on your custom tool specifications. The final set of tools that emerge from this process will be the ideal tools for your particular project. You'll have exactly the hammer you need, and exactly the right tape measure for your task, all at the press of a button (though you may also have to deploy a few configuration files to make it all work according to your expectations)."
And with the colour encoding of IDEs it's honestly not that bad. I try to avoid it, but naturally variable and class names often try to describe the same thing.
I believe Visual Studio does that by default. I picked up a habit of writing private variables and functions in lower case from my courses and once I switched to C# in VS the default configuration instantly started flagging that as style violations.
In C# its also less of a problem because a line like OP's would often be 'var ColorPalette = new ColorPalette();'
But using var instead of explicit type will pillute your warnings list so often I just go with the IDE's suggestion and just try not to read that bit again.
I preferr not having either one active since both var and explicit types have their places for clarity. I use var in about 95% of the times, but occasionally writing out the type helps because it's not obvious enough from context.
Wait, isn't this how Java always looks? I distinctly remember giving up on that awful language the day I realized that starting a new thread involved something like thread myThread = threadFactory(new thread).getThread().
(The spelling definitely deserves an award though)
in general if you use a factory you dont need to use new; factory are meant to build the object for you (i guess moat of the time they will provide an object from a pool, instead of building a new one). to be fair this pattern abuse is fault of the programmers, not of the language
As someone who does Java development for a living I was like... Ugh another thread making fun of long Java variable names... Ohhh....AHHHH... MY EYES... THEY BURN
I know that this is a bad code but how do you generally fix that? Sometimes we have a class just for a single use (because Java need class) and what should we name it. I am open to recommendation.
I think the Problem isn’t necessarily that it has colorPallete three times, that happens a lot in Java and similar languages since that is, quite commonly, the best name you can give to the variable.
However, the type / class is also spelt colorPallete instead of ColorPallete - and classes should always be capitalized.
360
u/Sir_Applecheese Sep 27 '21
Why isn't it capitalized? What the fuck kinda nasty shit are you doing?
265
u/ThatHappenedOneTime Sep 27 '21
ColorPaletteFactoryProvider.Create().CreateInstance(PaletteOptionsProvider.GetOptions());
Smh
140
u/teapot_on_reddit Sep 27 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
27
u/bubbleztoo Sep 27 '21
I wondered what was wrong, then I saw it and it scared me.
106
u/wyndigo92 Sep 27 '21
I'm impressed this compiled at all
79
u/TCreopargh Sep 27 '21
what about
9
u/ekolis Sep 27 '21
I'll order a pallet of those.
7
u/abrams666 Sep 27 '21
Reminds me to an workmate that called a C# Filehanlde open. at the end he had to
open.close();
10
u/erinyesita shameless Sep 27 '21
Pronounced "Koh-lore pie-yet-tay", presumably?
10
u/lachlanhunt Sep 27 '21
They could have put a "u" in the colourPalette variable so that it at least would have been correct spelling.
7
u/K1ngjulien_ Sep 27 '21
Thats not how you write java! You forgot to use the FactorySingletonBuilderProvider Pattern! /s
3
u/[deleted] Sep 27 '21
color_pallete
11
u/malsomnus Sep 27 '21
Wait, isn't this how Java always looks? I distinctly remember giving up on that awful language the day I realized that starting a new thread involved something like
thread myThread = threadFactory(new thread).getThread().(The spelling definitely deserves an award though)
2
u/haltmich Sep 27 '21 edited Sep 27 '21
Well, that's definitely a color palette...
2
u/b1ack1323 Sep 27 '21
VS or a plug-in I use actually recommends this for c# .
ColorPallette ColorPallette;
2
u/elingeniero Sep 27 '21
🎶 ooh colorPalette colorPalette equals new colorPalette baby 🎶
(to the tune of Britney Spears' Womanizer)
2
u/ign1fy Sep 27 '21
Misspelling to disambiguate? Java is all clazz.
2
u/gutigutibah Sep 27 '21
Isn't it just Java?
2
u/[deleted] Sep 27 '21
This is why Java now has a
varkeyword.1
u/chariot_dota Sep 27 '21
I was wondering what's actually wrong then i see the first letter
1
u/TheDawgLives Sep 27 '21
Wait till you see the next line:
colorPallete.colorPallette = new colorPalette.colorPallette():1
u/yonatan8070 Sep 27 '21
The first letter of a class name should be capitalized
1
u/sosta Sep 27 '21
As someone who does Java development for a living I was like... Ugh another thread making fun of long Java variable names... Ohhh....AHHHH... MY EYES... THEY BURN
1
u/[deleted] Sep 27 '21
ouch ouch no no no
1
u/haggie13 Sep 27 '21
I like the typo to prevent naming conflicts. That’s the way!
1
u/AnotherRichard827379 Sep 27 '21
The 0th and 2nd c need to be capitalized. I then find it fully acceptable.
1
u/hullabaloonatic Sep 27 '21
Isn't a color palette just a set of colors? So couldn't
var colors = new HashSet<Color>();have worked as well?1
u/SaltyMini Sep 27 '21
What's wrong with it?
1
u/Wafflelisk Sep 27 '21
Thanks to this I'm gonna start a site called Code Buffalo and make stuff that's filled with code like this.
When I'm a billionaire I'll be sure to send some your way
1
u/[deleted] Sep 27 '21
imagine maintaining a business like this
1
u/[deleted] Sep 27 '21
When I learned Java the big joke was
Cat Cat = new Cat()1
u/[deleted] Jan 12 '23
Oh boy you’ve never seen my code then
1
u/Knuffya Sep 27 '21
someone doesn't deserve fingers
0
u/KYIUM Sep 27 '21
colourPalette :)
0
u/chrisza4 Sep 27 '21
I know that this is a bad code but how do you generally fix that? Sometimes we have a class just for a single use (because Java need class) and what should we name it. I am open to recommendation.