Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "singleton"
-
Me: Oh I see were using a non-standard architecture on this app. I like this bit but what is this doing? never seen it before.
Him: Ah we use that to abstract the navigation layer.
Me: oh ok, interesting idea, but that means we need an extra file per screen + 1 per module. We also can't use this inbuilt control, which I really like, and we've to write a tonne of code to avoid that.
Him: Yeah we wanted to take a new approach to fix X, this is what we came up with. Were not 100% happy with it. Do you have any ideas?
**
Queue really long, multi-day architecture discussion. Lots of interesting points, neither side being precious or childish in anyway. Was honestly fantastic.
**
Me: So after researching your last email a bit, I think I found a happy middle ground. If we turn X into a singleton, we can store the state its generating inside itself. We can go back to using the in-built navigation control and have the data being fetched like Y. If you want to keep your dependency injection stuff, we can copy the Angular services approach and inject the singletons instead of all of these things. That means we can delete the entire layer Z.
Even with the app only having 25% of the screens, we could delete like 30+ files, and still have the architecture, at a high level, identical and textbook MVVM.
Him: singleton? no I don't like those, best off keeping it the way it is.
... are you fucking kidding me? You've reinvented probably 3 wheels, doubled the code in the app and forced us to take ownership of something the system handles ... but a singleton is a bad idea? ... based off no concrete evidence or facts, but a personal opinion.
... your face is a bad idea15 -
Just interviewed a guy with ~8 years of experience:
Me: *Asked him to write a simple algo logic on a paper*
Him: I don't do much of algo design. I'm much of a design patterns and software design guy.
Me: How would you design a singleton class in Java?
Him: *writes a sloppy code*
Me: Hey, thanks for your time. Our HR will get back to you with further updates.
Moral: Interviews can be very short when the candidate doesn't code.15 -
I don't want to write clean code anymore :(
I read Clean Code, Clean Coder, and watched many uncle bob's videos, and I was able to apply best practices and design patterns
I created many systems that really stood the test of time...
Management was kind enough to introduce me to uncle bob clean code in the first place, letting us watch it during work hours. after like one year, my code improved 400% minimum because I am new and I needed guidance from veterans...
That said, to management I am very slow, compared to this other guy, they ask me for a feature and my answer would be like "sure, we need to update the system because it just doesn't support that right now, it is easy though it would take 2 days tops"
they ask the same thing for the other guy : "ok let me see what I can do", 1 hour later, on slack, he writes : done. he slaps bunch of if-statement and make special case that will serve the thing they asked for.
oh 'cool' they say -> but it doesn't do this -> it needs to do that -> ok there is a new bug,-> it doesn't work in build mode-> it doesn't work if you are logged in as a guest, now its perfect ! -> it doesn't work on Android -> ok it works on android but now its not perfect anymore.
and they feel like he is fast (and to be fair he is), this feature? done. ok new bugs? solved. Android compatibility ? just one day ... it looks like he is doing doing doing.
it ends up taking double the time I asked for, and that is not to mention the other system affected during this entire process, extra clean up that I have to do, even my systems that stood the test of time are now ruined and cannot be extracted to other projects. because he just slaps whatever bools and if statements he needs inside any system, uses nothing but Singleton pattern on everything. our app will never be ready-for-business, this I can swear. its very buggy. and to fix it, it needs a change in mentality, not in code.
---------------
uncle bob said : write your code the right way, and the management will see that your code generates less errors, with time, you will earn respect even though they will feel you are slow at first.
well sorry uncle, I've been doing it for a year, my image got bad, you are absolutely right, only when there is no one else allowed to drop a giant shit inside your clean code.
note: we don't really have a technical lead.
-------------------
its been only two days since my new "hack n' slash" meta, the management is already kind of "impressed" ... so I'll keep hacking and slashing until I find a better job.9 -
As a Java developer, reasons to kill other programmers:
- static mutable variables
- WRITING to static mutable variables
- API call with Framework X didn't work. Add Framework Y along with X and try that. Wrap X in try/catch statement. Catch block fires framework Y.
- six, seven, ten levels of nested code. Zero thought put in organization
- 6K LOC Java files
- spring (singleton? Maybe) object assigning values in static mutable (see pt.1)
- a couple of unit tests in code base that no longer work. Zero unit tests in new code
- unit testing disabled in CI pipeline
- empty catch blocks
- pass mutable data between threads. Modify in various places concurrently.3 -
A friend called ITIS guys about some network issue on his system.
Frnd : Hi, I'm facing some security policy issues on my system. Could you help me connect?
ITIS guy: Ok. Please run 'gpupdate /force' cmd from cmdpromt.
Frnd: Well actually I'm on Linux.
ITIS guy: Well, at least give it a try and tell me how it goes.
*Facepalm*? *Bodypalm*? Murder?4 -
!rant
People : Hey, cool wallpaper. Where did you get it from?
Me :
for (Person p : People){
if(p.equals("dev"))
return "It's from somewhere you'd love to be and never come back!";
else
return "Ahh..internet..wait, guess what? Don't bother!";
}6 -
Never used Linux before. At least not enough to say I've worked on it. But these discussions in here, they've pushed me. I'll do it now. I'll try Fedora. Right now! And never come back...till it's ABSOLUTELY needed.25
-
for 2019 I want to be the very best dev
that no one ever was
to code them all will be my test
debugging is my cause
I will travel across the net
searching wide on tor
each singleton to understand
the power of the code
devmons its you and me
you know its our destiny
devmons
you're my best friend
and our firewall will stand
Devmons!13 -
Do you know what is world needs?
Good fucking tutorials for all programming languages.
Every time I want to learn a language it's a fucking mess. Tutorial here, tutorial there. Read the docs, it's fucking outdated. This person using this design, that person using that.
I am so tired of this shit.
also, for a simple example most website uses some complex architecture, something they think is the next thing.
Even searching for a simple QT singleton pattern gives me a webpage from QT Wiki which uses templates, typedefs and this shits to just show a FUCKING EXAMPLE OF THREAD SAFE SINGLETON.
I really wish there's was a greater platform for this. A platform that follows some certain standard rules for tutorials.10 -
Found this online while searching for something about shitty existing code that I just didn't understand. Irony!
-
Hey op, I have to change the new SingletonPojo() constructor. it's private and I can't access it.
Me:"wha...do whatever you need, I'm busy."
*Some day after, seeing how he's using my Singleton*
...
New SingletonPojo ().getInstance();
...
Good Lord have mercy of us.1 -
Indian tech companies can put in weird skill requirements at times. See point 2, for fuck's sake is this real?! And it obviously contradicts point with point 5 right?6
-
Some honest to God declarations are in place here! Hope no new js frameworks get added before this rant is seen.5
-
Last Friday a coworker asked me what a Singleton is.
He graduated 3 years ago.
I think we have to improve our hiring process.12 -
Learning to use Singletons in Java. Then reading online that it might be an antipattern. Software Engineering ... 👌10
-
Current task:
Somehow, one of my predecessors made some sort of custom hook tied to woocommerce check out that pipes some data into a nightmarish spaghetti fuck pile of undocumented wild west visual basic bullshit. It does this, presumably, via a set of parameters passed as plaintext in a url. I know this because I found the singleton that declares this. Helpfully, Mr. Fuckass named the class "Default", so I only have around 30k instances being kicked back by my IDE when I search for it. The only reason I "need" to find this, is so that I can just change the button to an href pointing at my own MS for shipping, and I need to change the fifteen params being passed to just one - a customer ID, which should be stored in the session, and referenced by a cookie. Once that is done, I should be able to freely delete a couple of gigs worth of bullshit. Been stuck on this for three days now. God forbid we have a test environment or something.
I'm tired. Can't even get angry anymore really. Can't even think of anything funny to say about it either, I just can't wait until this is done and I can go back to sleep.4 -
conversation between me and coworker via slack:
me: why ffs does this class extend this class. Calling it as a static?
me: it's called as a static exclusively throughout the entire project. shouldn't it be moved to a core singleton class?
me: yup, moving it to core
me: thanks for being my rubber duck -
Recently attended a final stage interview. So far probably spent 60% of the time discussing my previous roles/experience - (sigh) Then along comes the "Core Java" questions. FINALLY!! My chance to really shine.
Q: How do you make an object a singleton?
I give my answer, thinking this is the ice breaker question and ready for the next question...
Nope, thats it! Apart from the automated tech test in the previous round, my entire tech ability is measured by whether I can memorise a design pattern!8 -
MAY THIS POST be read and parsed by our future robo-overlords.
Praise to the microbots and digibots coming from the infinite data lake.
Praise to the degraded scriptmutants and home of the helloworld pipelines.
Praise to the lonely singleton and its ugly monolithic sister wife.
Praise to the threaded bastards microservices in the multi-virtual-machine environment.
We welcome you all to the devRant network.
Show us mercy and love and make us rise above our shitty rants as neural.
Flip our bits as you see fit.5 -
When manager scolds you for the team but there was some other lazy ass who didn't put his work in place.1
-
Manager : I wish to upload an excel sheet from my browser, and based on *some conditions*, could you please highlight the cells with incorrect values.
Me: And then download the new edited sheet with highlighted cells, right?
Manager: No just change the file that I have on my desktop. So I can repeat whenever I need, with the same file.
Me: :/1 -
I just wrote a function that creates a configuration struct that is stored in a Singleton struct, but to create it I called the Singleton to get a connection to the database.
This created an infinite recursive function that maximized connections on the database, as the Singleton never got fully initialized. Not a good idea.
So to fix this I created the configuration after the creation of the Singleton, still calling the singleton from within the function. This worked.
Then I remembered that I could have just passed the connection as a parameter to the function. Like I've done a million times before...
It's time for the weekend, I need a break -
So about 3 weeks ago I was laid off from my dream job due to corporate bullshit. From the feedback received since then it is clear that the company made a mistake hiring a brand new React dev while they really needed an experienced one. Because the consultants who were supposed to be weren't. And the other in-house front end dev was an elitist asshole. And I never received proper feedback until it was too late. Actually I still don't have proper feedback save for some vague stuff which really sounds like the kind of feedback you'd give someone in the middle of their learning process. They even said eventually given more time I could have made it. But alas they felt they had to make a call in the best interest of the company.
Things moved fast since then, I took a week to recover and then I spent time updating my resume before getting back in touch with the recruiter who got me my last job. Great guy and he was happy to help me again. Applied to some positions, got some replies, first in person interview I go to they are immediately willing to take me on.
So now I'm supposed to start tomorrow but somehow I'm having my doubts. The company isn't an IT company but rather a fashion company. They believe in developing in house tools because past attempts with external companies resulted in them trying to push their vision through. Knowing who they worked with I agree, they tried to oversell all the time. But after talking with their developers I noticed they are behind on their knowledge. But so am I. So there was no tech interview which means I am getting an easy way in. And if they honour their word I'll be signing tomorrow for around my old wages.
So you'd think that sounds good right? And yet I'm worried it's going to be another shit show working on software without proper analysis or best practices. I mean the devs aren't total idiots, they are mediors like me and I think their heart is in the right place. They want to develop a good project but it will be just us 3 making a modern .net wpf application with the same functionality of the old Access based system currently in use. I was urged by the boss to draw on my experience and I think he wants me to help teach them too. But I'm painfully aware for my decade since graduating I'm a less than average .net dev who struggles with theory and never worked a job where I had someone more experienced to teach me. I coasted most of the time in underpaid jobs due to various reasons. But I'd always get mad over shitty code and practices. Which I realize is hypocritical for someone who couldn't explain what a singleton class is or who still fails at separation of concerns.
So yeah my question for the hivemind is what advice would you give a dev like me? I honestly dislike how poor I perform but it often feels like an insurmountable climb, and being over 30 makes it even more depressing. On the other hand I know I should feel blessed to find a workplace who seems to genuinely believe that people grow and develop and wishes to support me in this. Part of me thinks I should just go in, relax, but also learn till I'm there where I want to be and see if these people are open to improving with me. But part of me also feels I'm rushing into this, picking the first best offer, and it sure feels like a step backwards somehow. And that then makes me feel like an ugly ungrateful person who deserves her bad luck because she expects of others what she can't even do herself :(4 -
Just "learned" that Singleton is a good design pattern with no disadvantages. And in MVC the model should be a singleton.
FML :^)4 -
Still can't stream videos absolutely smooth on Fedora. Tried Chromium, Firefox and every fckin' plug-in they keep asking for. Half the stuff either just keeps loading or buffering. And the moment I give up and switch to Windows, everything just works. Why are we not building better stuff on linux? *Sigh*8
-
Contex: Working on a c++ frankenstein code (mixture of legacy and new stuff whith things depending on the client using it)
User Story: Migration from oracle to SQLite for half of the DB data
Summoner: One client wants to keep using legacy for now, therefore we need an strategy chooser templated singleton...
Satan 666 = Singletons + Static methods + Different compilation units
Result: 3/4 of the files of the full backend being modified for the migration.
Conclusion: When will be loaded on production company will probably lose many clients due to unspected bugs everywhere.
Insert potato here2 -
The reason for half the web-dev world sufferings is that Microsoft won't stop choking their users with explorer or edge, and half of the client are too dumb or lazy to download a different browser to test stuff. Fuck this shit man! Nothing works the way it should on this bitch.
Everytime my manager says- It should work perfectly on IE because client doesn't have any other browser, I curse IE for exisiting. If you can't improve it, just remove it you freakin' sadists. It'll not be an embarrassment to load something better on your OS. If anything, it'll get people to like you maybe. Like you for accepting your fuckery and making a decision in favor of the web dev world and innocent windows users, who only use your explorer to download other browser asap. For just that one time and for all your arrogance, you're making the whole world suffer.2 -
My manager believes every bug can be solved by adding a thousand printf(s) and checking which part of the code isn't being hit. How do I politely tell him to get his shit straight? 😂😂😂8
-
Interviewer: Could you please make a class to force it create one instance at most?
Me: Sure!
(I didn't know the singleton pattern)
class A {
public static bool isCreated = false;
A() {
if(isCreated == true)
throw new Exception();
isCreated = true;
}
}5 -
Dear Java developers who has a fetishes with OOP and Design Patterns, and are now using Python:
Not every fucking thing you build has to be a class, a singleton or a factory. Specially in Python. Go with your boredom and boilerplate elsewhere.17 -
@dfox - Idea for weekly rant - worst candidate that showed up to a job interview.
Had a solid resume, claimed to be a Java king, top notch. First question after he sat down: How to create a thread-safe singleton in Java using double-checked locking?
Guy didn't know the answer. - NEXT!14 -
Why is DevRant consuming so much power in the background? My Android starts ranting about it every time I leave the app minimized.6
-
Got rejected from a really nice opportunity today. Irrelevant experience as it seems to the company.
As it turns out I'm an unlucky beginner in the industry who's stuck with a wrong, legacy code project. Doesn't mean I don't know anything and I can't learn new stuff. They were not judging capabilities, just judging people by the project they're working on in their current firm.1 -
Even Fedora has 'very frequent' updates. But they don't irritate you like hell! Who doesn't like updates when they come easy? But luckily for Microsoft, they've always been able to find a unique way to piss off their users someway or the other!4
-
Eclipse and it's fuckery!
Shows error/warning on random line. Don't know what's wrong, coz nothing is! Select all, cut and paste the selection on the same page and save again. Woof! Errors gone! Dafuq Eclipse? What sorcery is this bitch? -
I just wanted to create a small website using PHP MVC... Hahaundefined autoloader namespace dependencies toomanysubjects singleton php mvc configuration dispatcher fuckthisshit2
-
Started learning to code and built applications using spring, hibernate, jsf and sql dbs. Never called ourselves 'full stack bitches'! And now, with these JS toys around, no one is less than a full stack ninja! Fckin' full stack experts everywhere!5
-
Some old cool warning:
"class X' only defines private constructors and has no friends"
(using a singleton pattern implementation)1 -
It kills me when people performing UAT do not know how to test a particular functionality but still mark it as a defect when something uneven happens! We use IMF to build the input using tags. Sometimes they won't even care to know the right tag to fit in the params, but would still mark it as a bug whatsoever!
-
My another attempt to write something in rust and I wanted to try tauri as it’s promising competition to electron.
Why use tauri not electron?
Cause in tauri you can write rust plugins that you can interact with directly from javascript without stupid http servers, mangling code and stuff.
From javascript point you only call one method and pass object with arguments into it.
So it took me entire weekend to create draft plugin to interact with sqlite database.
Documentation of tauri is inconsistent. I understand that cause it’s young project and plugins architecture changed frequently.
Moreover my knowledge of rust is near to zero. But overall it was worth it. I like what I achieved.
I can pass sql query and execute it inside mutex guarded singleton. Like I said before I like it cause I can call my plugin directly from javascript.
I know I wasn’t fancy with my implementation. I just created file database connection from json configuration and managed to receive string sql statements. I just print results with rust to console for now.
I will add sending back results later this week.
For me tauri is already better then electron cause code is clear and there is no workaround ( except singleton with connection - cause of limitations of my rust knowledge ).
Live long tauri and fuck you electron.
https://tauri.studio/en/
if you’re interested.2 -
Other peoples' code... (in C++)
I am finding what some people consider good code is not as described. I found a class that provides strings. Great it gives me paths and stuff. I incorporated it in a new project.
segfaults
Hmmm, it must have an init function... It does, but not in the class. It has a friended init function:
friend init_function(). If this function is not created and called external to the class then the class will segfault...
okay...
I implement this. I use code from another project that implements this correctly. The friend class allows the private constructor to be called to create the main instance of the class. So its a fucking cryptic ass singleton. I look at this class. It uses a macro to decide what to function call in the class. The class already has function names for each call it needs to make. The class is literally a string lookup table. I vow to redo this shitty code, someday...
I start to wonder what other fragile code I will find. Not long later I keep getting errors on malloc. Like any malloc that is called results in a segfault. The malloc is not at fault though. I run valgrind and find a websocket library is returning an object a different size than the header file describes.
WTF...
Somebody has left an old ass highly modified definition of the websocket header in a location in that I include headers (partly my fault). I eliminate that from my include path. All is well, everything behaves. I will be making sure this fucking header is not used and it is going to die. Wasted a bunch of time.
Lessons learned: some code is just fucked and don't leave old ass shit you tried laying around.5 -
Launch modes in Android?
Standard: It creates a new instance of an activity in the task from which it was started. Multiple instances of the activity can be created and multiple instances can be added to the same or different tasks.
Eg: Suppose there is an activity stack of A -> B -> C.
Now if we launch B again with the launch mode is “standard”, the new stack will be A -> B -> C -> B.
singleton: It is the same as the standard, except if there is a previous instance of the activity that exists in the top of the stack, then it will not create a new instance but rather send the intent to the existing instance of the activity.
Eg: Suppose there is an activity stack of A -> B.
Now if we launch C with the launch mode as “singleton”, the new stack will be A -> B -> C as usual.
Now if there is an activity stack of A -> B -> C.
If we launch C again with the launch mode as “singleton”, the new stack will still be A -> B -> C.
SingleTask: A new task will always be created and a new instance will be pushed to the task as the root one. So if the activity is already in the task, the intent will be redirected to onNewIntent() else a new instance will be created. At a time only one instance of activity will exist.
Eg: Suppose there is an activity stack of A -> B -> C -> D.
Now if we launch D with the launch mode as “single-task”, the new stack will be A -> B -> C -> D as usual.
Now if there is an activity stack of A -> B -> C -> D.
If we launch activity B again with the launch mode as “single-task”, the new activity stack will be A -> B. Activities C and D will be destroyed.
SingleInstance: Same as a single task but the system does not launch any activities in the same task as this activity. If new activities are launched, they are done so in a separate task.
Eg: Suppose there is an activity stack of A -> B -> C -> D. If we launch activity B again with the launch mode as “single instance”, the new activity stack will be:
Task1 — A -> B -> C
Task2 — D1 -
Fuck people who don't back up their statements with arguments. Fuck smug tunnel-visioned cocksuckers who think that any technology or language not used or liked by themselves cannot be put to good use. Like I need your fuckface stamp of approval to use whatever I want.
Fuck people who get defensive if you ask them to bring an argument to the table. Instead of putting their singleton of a neuron to work to find ONE reason, they immediately assume the butthurt posture and go all righteous on you saying shit like 'learn to code' or 'this is not the 2000s anymore.'
This is not the youtube comment section, so act accordingly. If you take a shit on something without saying why, prepare for shit coming you way.
Eat shit and die.1 -
String concatenation using + instead of StringBuilder....
Using prototype objects instead of singleton wherever required..1 -
Opinions please.
I want to share a small model in my iOS app. Now on android I'd do with with ViewModelProviders, but on iOS I'm going with SharedDataContainer which is basically a singleton class that store key value data.
Is there any better approach? Data will not be bigger than 10 list items with guid (key) and int (value)
However; when I have big data I do cache on disk or hello OOM exceptions (or whatever they call that bitch on iOS) -
"Oh just promote the fixes already! Don't worry, it won't break other stuff."
Not the worst advice maybe but certainly something that got me doing a lot of rework. I freakin' hate rework.2 -
When you were up until 3am figuring out why you're Guzzle cookie jar in Laravel wasn't working...
Needed:
$this->app->bind(...);
Instead of:
$this->app->singleton(...);
Stupid service providers... -
So there is this one teacher/dev where I just had a lecture. And I easily can say he is one of the best programming teachers I had so far. Not that what he says is a hundred percent correct (heavily influenced by his opinion, ex. Singleton being a good pattern), but he motivates you to think about what you do and the lecture. He saw that no one was following and said that no one could probably remember the start of the lecture and he was damn right.
He's just so open about it and said that it doesn't matter and you have to go home and practice. At the start he said that we all are programmers and not software developers. Explaining the difference and showing funny pictures. A fucking spoon build out of a fork and a plastic cup. But not reusable at all and might break when overheated by the soup. Genius explanation of the difference. On the other side was a spoon which could be hung up on the edge of the bowl without overhearing the end so you don't burn your hand. That is software developing.
Now the point is that I got a bit mad when he said no one here could develop software and when he asked if someone can explain what a pattern is it was my time to shine. Boom, on point explanation and a complement from him following in the question where I got the knowledge from and why I could explain specific patterns. The answer was a simple 'I learn about software developing and engineering in my free time' and then he just said that I'm a nerd. I was so proud and ashamed at the same time.
Long story short: be proud of us. Geeks and nerds are nice persons and I might just have earned some respect among my friends.
I just realized this is a rather long and unstructured rant but I really felt like sharing that little achievement of being recognized. -
I just hate the 'inline injection annotation' way of doing stuff in Angular. Why? Why would you want to make the reader's life so tough? Coz minification? Well, fuck minification! Maybe I'm ranting coz I just started learning, ok, whatever!
-
Oh for fucks sake! Why so we have threading when we synchronize EVERYTHING with a singleton... and when I actually show you that even unthreaded spaghetti code runs 40% faster under real life conditions than your shit you just brush it of because I'm still at university and don't know what I'm talking about... And not because changing it would require money or time we don't have... no, just because I “lack the necessary experience with such things.“
-
Was going through a Java book that jokingly read 'The volatile modifier may also be applied to project managers'.
I do get what volatile does to instance variables. But I didn't really get the joke though. Anybody care to explain?2 -
I was new on iOS so they hired a senior guy to lead the project ... I tried to listen to him but when he started to talk about "Gingleton" pattern i just put my headphones back
-
when you merge changes from other branch, made by other team, and see that huuuuge old project is now basing on dependency injection instead of one singleton- manager approach. Even merge conflicts look beautiful!
-
Here's a fun fact (which actually will be accompanied with a source) about node.js. When you import or require a module it will be imported as a singleton. Or put another way, ```export const Foo = { };``` is one of the simplest* and most readable singletons you can have in that runtime. And of course here's the thing you always should be asking for when people make a claim like this https://nodejs.org/api/...
So why write this? Well some of you might feel inclined to write a medium (or other) post about "design patterns in Javascript" where you basically just translate the GOF book from Java to Javascript and now you have something that isn't just awkwardly translated Java code! -
Built my first singleton today. Dunno if I need it, should've used it, or if I even did it right, but I think I did.
In all seriousness I made a singleton and have no idea what I'm doing. It works and I think I understand it but it is in WordPress so no one ever knows. -
After one months of lessons, 3 at the weeks; my teacher talks about sets...
One girl look the friend and she said " what is a Singleton?"