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 - "string comparison"
-
Me, trying to create a LaTeX document: *googles "latex string comparison"*
Customer and boss walk in.
Google: *shows NSFW results*
I.. Let...- Let me explain, it's not what it looks like!14 -
Just looking at code, my colleague ("Senior Java Developer"), wrote...
if (process == "null") {...}
As you can guess, process is a String.
I just don't know what I can tell him. It's just so wrong, in every possible way...10 -
My first year of computer science.
Programming exam
1) we had to write c++ code on PAPER in 2013
2) I couldn't remember how the string comparison function worked so I asked the professor if he could tell me what the function gave as output. He said he could not 😡 i wrote the comparison function by hand
It's 2018 and I'm still mad about it12 -
About 2 years ago, our management decided to "try outsourcing". I was in charge for coordinating dev tasks and ensuring code quality. So management came up with 3 potential candidates in India and I had to assess them based on Skype calls and little test tasks. Their CVs looked great and have been full of "I'm a fancy experienced senior developer." ....After first 2 calls I already dismissed two candidates because they had obviously zero experience and the CV must have been fake. ..After talking to the third candidate, I again got sceptical. The management, however, started to think that I'm just an ass trying to protect my own position against outside devs. They forced me to give him a chance by testing him with a small dev task. The task included the following statement
"Search on the filesystem recursively, for folders named 'container'. For example '/some_root_folder/path_segments/container' " The term 'container' was additionally highlighted in red!
We also gave him access to a git repo to do at least daily push. My intention was to look at his progressions, not only the result.
I tried the task on my own and it took me two days, just to have a baseline for comparison. I, however, told him to take as much time as he needs. (We wanted to be fair and also payed him.)
..... 3 weeks went by. 3 weeks full of excuses why he isn't able to use git. All my attempts to help him, just made clear that he has never seen or heard of git before. ...... He sent me his code once a week as zip per email -.- ..... I ignored those mails because I made already my decision not wanting to waste my time. I mean come on?! Is this a joke? But since management wanted me to give him a chance .... I kept waiting for his "final" code version.
In week 5, he finally told me that it's finished and all requirements have been met. So I tried to run his code without looking at it ..... and suprise ... It immediately crashed.
Then I started to look through the code .... and I was ..... mind-blown. But not in a good way. .....
The following is what I remember most:
Do you remember the requirement from above? .... His code implementing it looked something like this:
Go through all folders in root path and return folders where folderName == "/some_root_folder/path_segments/container".
(╯°□°)╯︵ ┻━┻
Alone this little peace of code was on sooooooo many levels wrong!!!!! Let me name a few.
- It's just sooooo wrong :(
- He literally compared the folderName with the string "/some_root_folder/path_segments/container"...... Wtf?!?
- He did not understand the requirement at all.
- He implemented something without thinking a microsecond about it.
- No recursive traversal
- It was Java. And he used == instead of equals().
- He compares a folderName with a whole path?!? Wtf.
- How the hell did he made this code return actual results on his computer?!?
Ok ...now it was time to confront management with my findings and give feedback to the developer. ..... They believed me but asked me to keep it civilized and give him constructive feedback. ...... So I skyped him and told him that this code doesn't meet the requirements. ......... He instantly defended himself . He told me that I he did 'exactly what was written in the requirements document" and that there is nothing wrong. .......He had no understanding at all that the code also needs to have an actual business purpose.
(╯°□°)╯︵ ┻━┻
After that he tried to sell us a few more weeks of development work to implement our "new changed requirements" ......
(╯°□°)╯︵ ┻━┻
Footnote: I know a lot of great Indian Devs. ..... But this is definitely not one of them. -.-
tl;dr
Management wants to outsource to India and gets scammed.9 -
Previous dev needed to validate new user names as unique. His solution? Query Top 1000 rows and do a string comparison. Totally scalable, amirite?5
-
Just had a discussion with a coworker. I noticed he was storing dates as string in mongodb, saying it was better for comparison and because he stored them in UTC. WTH, mongo already stores all dates in UTC and a string date is imposible to compare. I wasted 8 hours finding that last part out.6
-
I spent 20 minutes looking at my Java if statement wondering why it's not working as intended:
if (word == "ABC")
I need some sleep/more coffee 🙃3 -
How the fuck does php type juggleling evaluate an variable as an integer on my system and passing all tests.
Then on the server as string, failing a typesafe comparison for authentication.8 -
Trying to learn c and I forgot the name of the string comparison function, so I googled "c string"
O boi....4 -
Some Java code I looked through to figure out how to accurately rework a mapping of value intervals to status colors:
• 16 levels of indentation
• Calls an instance method one line before a null-check
• Assigns that same value to a new variable and null-checks it again
• Insistently loops over existing HashMaps' entry sets to find a value by key
• Stringifies a Gson object, parses back the string and then null-checks the result.
• Mixes up the 'leq' and 'geq' comparison operators twice, which is why I went to check the implementation in the first place.
And this wasn't even legacy code. It's from last year.1 -
Probably not worst but back when I was in graduate school I used '=' instead of '.equals()' for a string, by mistake. My professor was so pissed and taunted in front of whole class about how dumb people are here without taking any names(btw I didn't realize that guy was me until later) and gave me a low score
I told her later it really doesn't matter if I used either because '=' worked just fine in my case. She was a little more pissed after knowing that I wasn't wrong. 😜6 -
Where to start, maybe from string.
Empty string conditions and string comparison.
if “”: - python
“” == false - javascript
.equals() - java1 -
What is the best string comparison algorithm ?
Example Use case: group messages from your telco into groups of related messages.
I have gone through the various algos and implanted them. I just want your opinion if you have experience on this.15 -
Another hours wasted on debugging, on what I hate most about programming: strings!
Don't get me started on C-strings, this abomination from hell. Inefficient, error prone. Memory corruption through off by one errors, BSOD by out of bound access, seen it all. No, it's strings in general. Just untyped junk of data, undocumented formats. Everything has to be parsed back and forth. And this is not limited to our stupid stupid code base, as I read about the security issues of using innerHTML or having to fight CMake again.
So back to the issue this rant is about. CMake like other scripting languages as bash have their peculiarities when dealing with the enemy (i.e. strings), e.g. all the escaping. The thing I fought against was getting CMake's fixup_bundle work on macOS. It was a bit pesky to debug. But in the end it turned out that my file path had one "//" instead of an "/" and the path comparison just did a string comparison without path normalization.
Stop giving us enough string to hang ourselves!rant debugging shit scripts of death fuck file paths fuck macos string to hang ourselves fuck strings cmake hell12 -
How should you override Equals in Java?
We have model classes with lots of fields and the we override the details equals to compare all the fields. I guess like doing a deep comparison.
And in all these classes SONAR is complaining about lots of ifs, complexity, etc.
And it's killing the analysis time... Old issue never fixed because whoever setup sonar was too incompetent to bother asking, researching, or fixing...
Is there a better way to override the equals to get the same result but without triggering SONAR issues?
Pretty sure this is a solved problem. And well if the top of my head, is just create a Util method that uses reflection like
Boolean equals( Object a, b, Class class)
foreach (String f: class, getFields()) {if !compare(class.getField(f,a),class.getField(f,b)) return false; }
return true5