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 - "arraylists"
-
How many of you use the right data structures for the right situations?
As seasoned programmer and mentor Simon Allardice said: "I've met all sorts of programmers, but where the self-taught programmers fell short was knowing when to use the right data structure for the right situation. There are Arrays, ArrayLists, Sets, HashSets, singly linked Lists, doubly linked Lists, Stacks, Queues, Red-Black trees, Binary trees,.. and what the novice programmer does wrong is only use ArrayList for everything".
Most uni students don't have this problem though, for Data Structures is freshman year material. It's dry, complicated and a difficult to pass course, but it's crucial as a toolset for the programmer.
What's important is knowing what data structures are good in what situations and knowing their strengths and weaknesses. If you use an ArrayList to traverse and work with millions of records, it will be ten-fold as inefficient as using a Set. And so on, and so on.31 -
An anti-rant: I just made some code and out of nowhere it suddenly had an awesome feature that I didn't even program. No, not a euphemism for "bug", an actual feature.
Here's the story: A few months ago I made a shortcut for "System.out.println(…)" called "print(…)". Then I developed it further to also print arrays as "[1,2,3]", lists as "{1,2,3}", work with nested arrays and lists and accept multiple arguments.
Today I wanted to expand the list printing feature, which previously only worked for ArrayLists, to all types of List. That caused a few problems, but eventually I got it to work. Then I also wanted to expand it to all instances of Collection. As a first step, I replaced the two references to "List" with "Collection" and magically, no error message. So I tested it with this code:
HashMap<Integer, String> map = new HashMap<>();
map.put(1, "1");
map.put(2, "");
map.put(3, "a");
print(map);
And magic happened! The output was:
{1=1, 2=, 3=a}
That's awesome! I didn't even think yet about how I wanted to display key-value pairs, but Java already gave me the perfect solution. Now the next puzzle is where the space after the comma comes from, because I didn't program that in either.
I feel a bit like a character in "The subtle knife", who writes a barebones program to communicate with sentient elementary particles (believe me, it makes sense in context) and suddenly there's text alignment on the left and right, without that character having programmed any alignment.4 -
yellow lemon tree sound starts:
"i'm sittin' here in a boring room, just another rainy sunday afternoon, i'm wastin' my time, i got nothin' to, i'm feelin' so lonely i'm waiting for my fucking graph coloring program to finally finishing this fucking piece of graph coloring in which i spent the last four days figuring out what the goddamn problem is and for some reason my arraylists and my hashmaps didn't get along that well and now i hope that i have finally found the solution to my problem and let this fucking piece of shit of program run otherwise i'll get crazy, but nothing ever happens, ... , and i wondeeeer ... *dum dum dum* *ding* -
Best documentation have probably been most language docs and references I've worked with, official or otherwise, especially C++. Completeness, consistency, tidiness and examples really help a lot, since I know I can rely on the docs for basically any problem and makes work so much easier since I'll be guaranteed to leave understanding what's up.
Worst documentation has got to be the internal docs we had to create for a seven-man uni project, you couldn't find shit in the sea of docs that were out of date or just plain wrong. It was so much easier to ask whoever was working on that part about the intricacies of the cobbled-together mess than to either read the code or the docs. One absolute mouthbreather was working on the database docs and put in that it stored ArrayLists. Fucking Java ArrayLists in a motherfucking database. One day I am going to rant so hard about this dumbass and it's gonna be a spectacle.
Bonus points goes to the company's public documentation at my internship. It was good and pretty complete, but sometimes there was a document from 2 years ago that had been written by a non-english speaker that was absolutely awful. Some of them were so bad that as soon as I'd finished learning what I needed to, my mentor told me to go and fix the docs, I don't blame him.