[rant] Somethings you'll learn in college but should NEVER use in the real world
2 23 Jan 2017 21:37 by u/lmkevin
As we know colleges in America have deteriorated greatly. Here is some advice short from saying not to go.
- Linked list do indeed have a solid engineering concept, however they are absolutely worthless and there is not 1 logical reason why you should use them programmically. Analogically, if a static buffered array were a metal chain, and a resizable temporary array were a rope, a linked list would be a slinky.
- UML made by hand is complete garbage, though it is important to model your software you should not force yourself to use only OOP concepts. Nor should names for variables and functions be the main focus in a model. Software design is suppose to describe the software, the best information UML conveys is what naming standard you used.
- At anytime when you're programming and thinking about using recursion, there is a 90% chance you're doing something wrong. If something can be done in a iterated form, do it in an iterated form. Colleges teach recursion like it's needed on every line in every function in every class on every program made by every company ever.
11 comments
7 u/Phen 24 Jan 2017 01:42
Linked lists have O(1) random insertion (if you're already at your link node), array lists do not. Array-based lists have O(1) random access, linked lists do not. The correct choice depends on the workload.
Nearly all lists I work with on a day-to-day basis are just collections to be iterated over for some sort of processing like validation or whatever. Algorithmically, either would be fine. Array lists have a lower memory overhead, so it's reasonable that they should be chosen for most cases, especially if you have a good idea of the buffer size.
But they certainly should not be chosen for ALL workloads.
For example, the application I write at work maintains a navigation stack. Depending on user action, we may need to remove the head or tail of the stack, pop or push navigation states. If the user navigates to a screen, we push the screen on the top of the stack and pop the tail so that we don't keep too much history. As the user goes back and forward, the list node moves to previous or next. Etc. How is that stack implemented? A linked list, of course! Anything else would be silly. It could have be implemented as an array list, after all the number of elements is so small that there would be no measurable performance impact. But we'd just have to write an interface overtop of the array-based list that looks the same as what the linked list already provides, so why bother?
HOWEVER, I think all of that misses the point of education entirely. Even if the linked list isn't used all over the place, you still need to understand the algorithms! That's the point of education. A college education in programming shouldn't just be bunch trade school style instructional courses where you're told what to do and how to do it. You have to understand the abstract data structures, why they're used, why they behave as they do, why you should use them, why you should avoid them.
If you don't, you'll risk winding up like my coworker who uses linear lookups for everything even when hashtables are the obvious solution. (Curse you LINQ!)
4 u/ketezer 23 Jan 2017 22:36
I use recursion to build/search trees and it works well. I've never seen UML by hand but the idea of it sounds awful.
1 u/roznak 24 Jan 2017 20:36
Spot on! I have created millions of lines of code and rarely needed recursion.
0 u/freed00m 23 Jan 2017 21:58
I hate Linked lists, that I agree with you on.
UML by hand is also waste of time in my eyes.
But what about finding a node in a tree? I would use recursion, for high quality demand we have MISRA and stuff like MISRA.
0 u/lmkevin [OP] 23 Jan 2017 22:00
Yeah thinking on it, I knew that recursion does have actual use (hense the 90%), you can't get away from recursion when dealing with trees.
0 u/freed00m 23 Jan 2017 22:07
I don't think you "can't" but I just do it with recursion. The other memory ease method usually linked lists :D and that I hate more. All MISRA sets should be satisfied with linked lists. There you go :D
0 u/lmkevin [OP] 23 Jan 2017 22:08
Maybe I should just rid of points 1 and 3 and replace it with the phrase "avoid trees if possible"
0 u/cruelecole 24 Jan 2017 19:44
At risk of
Excelbeing rejected as programming: hiding rows/columns when it's always better to group (select row/col and thenalt,d,g,g) or save a new version and delete (alt,e,d) the rows/columns; respectively, the rows/cols are either meant to be seen again, or they are not - the middle ground of hiding creates confusion in the former case and fails to achieve the goal in the latter.