![]() |
|
Computer Science / IT / programming - Printable Version +- kanji koohii FORUM (http://forum.koohii.com) +-- Forum: Learning Japanese (http://forum.koohii.com/forum-4.html) +--- Forum: General discussion (http://forum.koohii.com/forum-8.html) +--- Thread: Computer Science / IT / programming (/thread-5446.html) Pages:
1
2
|
Computer Science / IT / programming - pm215 - 2010-04-19 Tobberoth Wrote:Yeah, people have a tendency to forget one of my basic principles when making software:A good rule of thumb, but not all working code is good code... One of the classic kinds of bad code is the sort that's written in a sort of random-try-and-fix mode, where the author has flailed around a bit with no real idea of how to fix whatever bugs they had until they happen upon something that works. It doesn't count unless you know why it works too :-) Quote:I agree with mentat that knowledge of algorithms is important, but this is definitely for the later optimization point. If you need a list, use one which works. If you later realize your solution is a bit slow, pick a different data structure.Me, I disagree. A lot of a CS degree course isn't really necessary day to day, but the core data structures (list, tree, hash, etc) are so fundamental that you ought to be able to pick a sensible one pretty much immediately. Premature optimisation *is* a bad idea, but "right data structure for the job" is as much about clean and comprehensible code as it is about performance. Computer Science / IT / programming - Tobberoth - 2010-04-19 pm215 Wrote:Me, I disagree. A lot of a CS degree course isn't really necessary day to day, but the core data structures (list, tree, hash, etc) are so fundamental that you ought to be able to pick a sensible one pretty much immediately. Premature optimisation *is* a bad idea, but "right data structure for the job" is as much about clean and comprehensible code as it is about performance.Certainly, that's sort of what I meant. Say, you have ten objects you need to keep track of for a loop. You COULD just randomly pick a hash structure and it would "work", but there wouldn't be any logic to it, so I would say that in this case, you didn't really pick a working solution, you just rolled a dice and picked a structure at random. I was mostly talking about knowing you need a hash and debating which kind of hash structure you need. Or even picking between a stack and a list if both options are viable. I mean, a stack can definitely be a lot more effective than a linked list, but there's a reason why both are implemented by the same class in many high level languages, such as python. If you understand the common structures to some basic degree, I really do think you will pick a "working solution" automatically just in that short period where you plan ahead how you will go about solving a certain problem. Then it will be optimization if you want to dwell on it longer and want to perfect your code. |