Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Get a devDuck
Rubber duck debugging has never been so cute! Get your favorite coding language devDuckBuy Now
Search - "at least it is solved"
This probably isn't the coolest bug I've ever solved, but surely the one with the biggest faceplam
So I was building a Bluetooth smart watch that pairs with your Android device for the final year bachelor's project. The submission was in a 2 days and it was all ready and it suddenly stopped working.. Spent hours trying to fix it, even tried to get a replacement Bluetooth module (was out of stock -_-).. After a day's worth of freaking out I discovered that Android phones (at least the OnePlus X) don't connect to Bluetooth modules when their battery is below 15% -_- and since I was freaking out I would let the phone charge a bit and get back to debugging and it never crossed 15% so it never worked.. One day of debugging attempts later it suddenly struck me that low battery might be an issue.. And voila! It worked after charging the phone
Shouldn't such things be clearly mentioned in documentation :/
(Btw, got full for the project, got a 10/10 GPA for the semester)1
"I'm almost done, I'll just need to add tests!"
Booom! You did it, that was a nuke going off in my head.
No, you shouldn't just need to add tests. The tests should have been written from the get go! You most likely won't cover all the cases. You won't know if adding the tests will break your feature, as you had none, as you refactor your untested mess in order to make your code testable.
When reading your mess of a test case and the painful mocking process you went through, I silently cry out into the void: "Why oh why!? All of this suffering could have been avoided!"
Since most of the time, your mocking pain boils down to not understanding what your "unit" in your "unit test" should be.
So let it be said:
- If you want to build a parser for an XML file, then just write a function / class whose *only* purpose is: parse the XML file, return a value object. That's it. Nothing more, nothing less.
- If you want to build a parser for an XML file, it MUST NOT: download a zip, extract that zip, merge all those files to one big file, parse that big file, talk to some other random APIs as a side-effect, and then return a value object.
Because then you suddenly have to mock away a http service and deal with zip files in your test cases.
The http util of your programming language will most likely work. Your unzip library will most likely work. So just assume it working. There are valid use cases where you want to make sure you acutally send a request and get a response, yet I am talking unit test here only.
In the scope of a class, keep the public methods to a reasonable minimum. As for each public method you shall at least create one test case. If you ever have the feeling "I want to test that private method" replace that statement in your head with: "I should extract that functionality to a new class where that method public. I then can create a unit test case a for that." That new service then becomes a dependency in your current service. Problem solved.
Also, mocking away dependencies should a simple process. If your mocking process fills half the screen, your test setup is overly complicated and your class is doing too much.
That's why I currently dig functional programming so much. When you build pure functions without side effects, unit tests are easy to write. Yet you can apply pure functions to OOP as well (to a degree). Embrace immutability.
It's really not helpful that a lot of developers don't understand the difference between unit, functional acceptance, integration testing. Then they wonder why they can't test something easily, write overly complex test cases, until someone points out to them: No, in the scope of unit tests, we don't need to test our persistance layer. We just assume that it works. We should only test our businsess logic. You know: "Assuming that I get that response from the database, I expect that to happen." You don't need a test db, make a real query against that, in order to test that. (That still is a valid thing to do. Yet not in the scope of unit tests.)9
Okay you bastards ya got me: I fucking enjoy using Linux as my dev environment.
There, I SAID IT -
BUT DON'T THINK FOR A SECOND IT MEANS THAT I STOPPED HATING IT
Oh the fucking love hate relationship to fucking Linux.
"Hey, ihatecomputers! How many hours per year did you spend fixing internet connectivity issues on Windows?" you ask. Well, close to fucking 0 you goddamned imbecile. But on Linux? I don't even want to talk about it.
And what about that time when I wanted to connect my bluetooth headphones so I could listen to music while studying? Well, by the time my headphones were connected to my machine (usually a one second operation) I had no time left for, you know, actual studying. Oh my god, it's the most trivial fucking thing.
Well, at least that particular issue got solved.
Unlike that fucking Ethernet connection which has been fucking out of commission since I started using fucking Linux. Wifi works just well enough to make it not worth pouring more time into troubleshooting that shit, but just barely though because my wifi IS FUCKING DOGSHIT ON LINUX
But fuck me if it isn't it the most lean thing ever! It's the goddamned opposite of bloated. So smooth and snappy. And free as in slurred speech, or whatever. It makes me happy. When I'm not seething with rage, that is.
Yeah I guess that's it, thanks for tuning in.
So yeah XML is still not solved in year 2018. Or so did I realize the last days.
I use jackson to serialize generic data to JSON.
Now I also want to provide serialization to XML. Easy right? Jackson also provides XML serialization facitlity similar to JAXB.
Works out of the box (more or less). Wait what? *rubbing eyes*
Why is my groups property (java.util.Set) rendered as two separate elements? Who the fuck every though this is the way to go?
So OK *reading the docs* there is a way to create a collection wrapper. That must be it, I thought ...
What the fuck is this now? This is still not right!!!
I know XML offers a lot of flexibility on how to represent your data. But this is just wrong ...
The only logical way to display that data is:
It would be better if the individual entries would be just called "group" but I guess implementing such a logic would be pretty hard (finding a singular of an arbitrary word?).
So yeah theres a way for that * implementing a custom collection serializer* ... wait is that really the way to go? I mean common, am I the only one who just whants this fucking shit just work as expected, with the least amount of suprise?
Why do I have to customize that ...
So ok it renders fine now ... *writes test for it+
FUCK FUCK FUCK. why can't jackson not deserialize it properly anymore? The two groups are just not being picked up anymore ...
SO WHY, WHY WHY are you guys over at jackson, JAXB and the like not able to implement that in the right manner. AND NOT THERE IS ONLY ONE RIGHT WAY TO DO IT!
*looks at an apple PLIST file* *scratches head* OK, gues I'll stick to the jackson defaults, at least it's not as broken as the fucking apple XML:
I really wonder who at apple has this briliant idea ...2
This is a story about my disappointment in modern GUI editors for desktop applications.
Well, first of all, I grew up with Delphi 5. Delphi has an awesome form editor. It's intuitive and works without any problem. It always does what you want it to do. Prototyping is really a problem of seconds here, even for people that never used it (I guess).
But the problem is that it is Delphi. Its so old, bloated, and most problems you'll ever have have been solved (through a hack) 20 years ago in some weird forum.
So I looked on and tried many other drag'n'drop gui editors.
The one for java is the biggest pile of crap I've ever seen. It slows down eclipse /intellij and does almost never do what I want. At least its not really intuitive.
Right after that, the one for C# (this xml Designer ) is okay-ish, but it's also not really intuitive and does not always what the user wants.
I also tried other ones. But I still miss an intuitive one that works without weird side effects.
I now can understand why the Web dev stack grows in the region of desktop apps. I can prototype stuff even faster in angular than in Delphi.
But shouldn't we improve the desktop stack instead of taking some bloated stack using a language that should have never existed?9
If they followed my suggestion and went straight to debugging the server issues they would have been solved it from week 1 and everyone would have thought the migration had a minor performance hiccup. In fact, we have already done such at least twice before and nobody batted an eye.
Instead they self-labelled the migration a failure on first error, setting the stage for apologizing to the client, and put themselves on the spot for a whole staging / production signoff, replication / backup worfklow, almost a blue-green "seamless" deployment reminiscent of DigitalOcean.
Well they're not DigitalOcean, and anyone who has spent any time understanding users knows they will not participate in "new system" tests long enough to find or report issues.
So of course the migration stretched out to almost three months up until the whole reason for the migration - the rapidly escalating risk of the old provider disappearing - hit like a freight train and now they have to go through the problem of debugging the server like I told them to on week 1. Only this time they've set the client mindset against it, lost any chance of reverting, have had grave risk for data loss, and are under pressure to debug other people's code in real-time.
This is why I don't trust devs to do ops. A dev's first solution to any problem is to throw tech at it.
Many of the problems I see people solving with these giant stacks could be easily solved understanding how websites work (html, css, js and how interact with each other) with no dependencies giving smaller (for end users at least) and more maintainable code (in the sense it would not require updating dependencies that may be discontinued...)
I do imagine situations where these are ideal... Since there are not absolutes and developing is very context sensitive, but man if I have js article fatigue for ridiculous scenarios.2
So there's one guy working on a Linux machine (everyone else is on a Mac) and it always caused problems because it kept freezing/crashing.
now he's going to get a Mac
turned out there was no swap assigned
Swap - Used: 0 Free: 0 Total: 0
At least the mystery has been solved5
At first glance, this week's group rant seems perfect for me since I have drunk coded at least 2 to 3 times per month (my TGIFs are usually followed by Saturday morning demo meetings).
However I cannot say I have had any particular "worst" code that I have done so far.
Yea I once formatted and installed some linux distro while drunk and couldn't remember the login info the next morning.
Yea I once exported, imported between dbs from prod and local while drunk and lost this and that data.
Yes I once decided to organize my repositories and somehow deleted some repos without any backup while I was drunk.
I was fine. I somehow solved my way out by either bullshitting or being quiet or fixing without any sleep. Most of the times nobody really comprehend the extent of my actions. So I was fine. Hence I really don't have any particular worst drunk coding experience yet.
Best drunk coding experience?
Well I do not agree that coding while drunk is a pleasurable or fun thing to do. So I don't really have that either.
This week's topic is actually a very tough one although it might seem easy.
When Icriticize a paid service for taking away or not providing functionality for all users equally but then a user comes back defending them with some BS reason...
Ok... I'll just continue helping myself only...
1. Can you put the New books tab with back in the bottom, scrolling down into the New section in the front page is annoying. At least make it a setting?
2. Where's the # of books read stat in Android?
Blinkist: Hi thanks for your message! The best way to view the newest titles on Android is to do just as you mention – scroll down to reveal the New section. As for BiB stats on Android, we're working on releasing this feature (it's only live on iOS at the moment).
Me: Hm... I liked the older way better. Faster and can tell when it was added. The problem is sometimes still new books don't refresh and I need to login out to get it to update. Also I notice sometimes the list changes randomly I think. One day a new book is there. The next day it's gone.
BiB stats have been in iOS for a year now? How hard is it to put it in Android. Personally it only took me a day to find out what my total is as I can write a program to do it so to me I don't understand how this could be taking so
Some user: Priorities and often it’s strategy for future features...
Me: you take away useful functionality and and can't release a feature that's been on the iOS version for a year already... fine,,, I'll just take it as a challenge... that I've mostly solved... for myself...3
Not a specific bug, but I always have that satisfactory feeling when I fix a bug inside a code like this:
1. Spaghetti af
2. Duplicated af
3. Heavy use of static fields instead of passing via callback when required
4. variable names like: textbox1 ..etc.
5. No comments
It is true that is a huge pain in the ass to deal with, but then I look at it as I was able to create something out of that mess, I mean all is mixed up nothing is clear, no clue where it starts and what caused it, but then I put the pieces together and end up with a solution of what I thought to be: It will never be solved when that mess is here.
Not an excuse for messed up code, I try fixing whenever possible, but hey, at least I did not run away and give up
Just spent a week creating a distributed api architecture which I found out won't work due to a singular issue which can't be solved - not unless I hack stuff to a degree where I might as well write my own frameworks.
I've been aiming the user application's requests towards my wsgi, which based on a custom header will proxy it towards the correct api. Each customer base has their own api and dataset, but they all visit the same address.
I've handled CORS manually, just picking up when there's an options request, asserting the origin, then returning the correct headers. Cool everyone's happy. Turns out, socket.io includes session id and handshake info as part of their options preflight, which I can't pair with my api header (or cookie, for that matter) which means my wsgi doesn't know where to send it. You get a 400! You get a 400! You get a 401! </oprah>
So my option is to either roll my own sockets engine or just assign each api to a subdomain or give it some url prefix or something. Subdomains are probably pretty clean and tidy, but that doesn't change having to rewrite a bunch of stuff and the hours I spent staring at empty headers in options preflights.
At least this discussion saved me some time in trying to make it work. One of my bad habits is getting in those grooves of "but surely... what the hell, surely there's a way. There has to be"
TLDR: Read the post.
Part of me watches the day fly by as I work through the various stories and issues my company has as we walk through the various phases and clean up of their own stupidity of outsourcing. I guess it would be unfair to say “stupidity” It was really a money thing. Excuses aside, the alcohol today tastes amazing as I work through the issues, nothing is ever the same, nothing is ever redundant or boring. There are times where you want to pull your hair out, jump off a building and question why the hell any one would write code, specifically Laravel this way.
I watch the internet from now and then and see the cry babies whine and complain about GitHub and Microsoft jumping into bed and their favourite, and mine too, editor falling into Microsoft’s hands.
It’s disgusting and completely childish, but I digress. The last time I was here the alcoholism and the loneliness had begun pushing me towards the Nicotine and suicide. I have managed to obviously push through and watch the money come in only for adult life to take it away, I guess that’s life. Complaining about it will do nothing other then show others how much control you lack in your own life. You quiet your complaints and bury them deep inside your mind where they fester and stir and become drowned in alcohol.
Dating is even harder, especially when you work from home, so much so that I have completely given up there, any semblance of social life is buried in Final Fantasy 14 online, where pixels and text other people write have become my friend, at least for a moment or two before the work takes over and I sit in a room blaring music and watching the code I write, appear on screen like some savant who has high functioning autism but can create amazing works of art. I don’t think I am autistic though.
The truth is I don’t mind my job, I love the money and the freedom as I stated before.
Code for me is like a seed of anger that starts deep in my core, festering, eating away at me, killing me slowly and branding me a fool. The problem is the best feeling, when there is a problem I can solve it with code, when there is a problem that cannot be solved by code I take solace in the problems that can be. I don’t like people, I hate offices and I despise dealing with my own personal issues, I would rather drink and vape until the nicotine and the alcohol has made me sufficiently numb.
Code is a place I can escape, a place I have control, a place where I don’t feel like blowing my brains out at the stupidity of other people. Have I mentioned that I hate people?
The internet is full of idiots, people ranting and raving about this and that and how it affects them oh so much, when they don’t even let their own code, there own programming problems, and in most cases shitty solutions, affect them. Look at this GitHub thing, the idiots are running around with their heads cut off, waiting for the world to end or in most cases acting like it has. Companies get bought, bill get paid, people leave each other – Shut the fuck up and deal with it.
I guess if you look back at what I have written you could say the same thing to me, boo-fucking-hoo working from home sucks sometimes, grow up and deal with it like an adult. Fair enough, I’ll take my lumps. Excuse me as I continue to drink this post away and watch the downvotes come in. I guess honesty comes with a double edge sword.
And yes I would rather use alcohol as a solution then deal with the issues.16
So for the past two days I had to deal with a problem where I have to do a nested query with sequelize, pretty straight forward reading the documentation, or that was I think. I implemented everything according to the docs but the query stills fails, why ? I had no idea, I double check my implementation, I googled the error, no luck, after a day searching like crazy I talked with the backend lead about this and he help me to realize that the naming convention was changing because sequelize is creating a nested (SELECT * FROM) because one of the relations has a one-to-many realtion with the root model and I'm why the heck is doing that? But we both didn't know, and the problem was solved by just modifying the names, so we let it through, and sent it to QA. The next day I see the task rejected by QA and the reason was after the changes were merged another part of the app was broken, ok np, I'll fix it right away, and oh God I found the error was caused by another query that was including the first query we fix yesterday ! It was a nested query with 3 lvls! And the names became even more complex ( like `model1->model2.colum1`), goddamit, ok, I spent most of the day searching again, nothing, read the specification of the findAll function, nope, tried to put that name in the ON clause as the docs suggested, still an error, shit, then the lead helps me again and creates a literal which can hold that name and voila! Everything is happiness, at least for that moment, but I was still curious about this behavior, so I keep digging on it and I've just found an issue where a great guy posted an option to the findAll method that is not documented in any version of sequelize ! WTF ! And this option was "subQuery" which if you set it to false it won't create that additional (SELECT * FROM) from before, FUUUCK! I can't believe it, I know that all the effort works in my favor because I learn more about sequelize, but FFS I'm still angry because this shit shouldn't happen, you need to update the god damn docs, it's just adding a row and telling the people what it does. Well to end this, after putting that in the query and replacing all the workarounds with the expected syntaxis everything works like charm.1