|
I think that example's funny because I'm sure that even if I had no experience of programming, I'd be able to look at it and think "else balance = balance + 0? What's the point of that?" Plus withdraweing monety and stuff I guess.
|
# ¿ Mar 2, 2010 13:14 |
|
|
# ¿ Mar 28, 2024 10:43 |
|
Sebbe posted:To be fair, I've seen quite a few people write that sort of code in introductory programming classes; it's more of a sign that they don't really understand what they're writing than a horror, in my opinion. This is something I was thinking about only yesterday, as I was doing some teaching for a first-year calculus course (I'm a postgrad and we're asked to give a certain amount of help teaching every semester). It's fairly basic stuff that all of the first-year mathematics students have to do, and so you can understand how some of them will find it boring and switch off. But you do come into contact with students who seem not to readily engage with the idea that they need to think critically about what they're doing. By this I mean that they often seem to be used to the idea that there is some algorithmic, rote method that they will be able to learn and apply dutifully to whatever problem they're presented with. To do mathematics at a higher level they need to try and have a real understanding of the ideas they're working with, but while the introductory courses we give try to instill this in them, I have the uncomfortable impression they often don't succeed. I'm talking about my discipline which is maths, but I can readily believe it applies to other technical disciplines too. I know you weren't criticising the student who wrote this, just observing that he didn't understand what he was writing. I tend to feel that while there is a value in "learning by doing", you shouldn't present a piece of work, purporting to be a genuine solution to a problem, in which you've written something you don't understand. I'm not sure in what way it is best to get students to understand that they really need to engage with the material they are learning, however. I'm rambling so I'll shut up now.
|
# ¿ Mar 2, 2010 14:01 |
|
Athas posted:\exists and \forall are an E and an A mirrored across both axes. He means, if you rotate W in one direction it looks like an E and if you rotate it in the other direction it looks like \exists.
|
# ¿ Mar 10, 2010 14:52 |
|
evensevenone posted:Or his "IT" professor didn't know or give a poo poo about php. I think it's clear that even if his professor did outright state what the guy claims he did, it's still something you might think to check somehow, if secure passwords are important in what you're doing.
|
# ¿ Mar 19, 2010 23:33 |
|
WildFoxMedia posted:Deciding to poo poo up another thread with your "OMG PHP SUCKS, EVERYONE WHO DOES PHP SUCKS" bullshit? Well, at least the first of those statements is correct. I do scripting in PHP and I have a soft spot for it, but I can recognise that it does objectively suck pretty badly. I don't think there should be an argument about it in this thread though.
|
# ¿ Mar 20, 2010 22:20 |
|
Parantumaton posted:How the gently caress did that guy even managed to get something compiled He threw things together until it worked, didn't you read the quote?
|
# ¿ Mar 21, 2010 16:15 |
|
Using an if block, for block, or whatever and omitting the braces is just bad in my opinion. It's like omitting brackets just because you know what the order of operations is; why make things less clear for the reader?
|
# ¿ Mar 27, 2010 19:31 |
|
Plorkyeran posted:Do you write x * y + z as (x * y) + z? No. Although I would not object to seeing it. I think BODMAS (or whatever you learnt it as) is sufficiently basic to be assumed. Obviously some base level of knowledge could be assumed in all instances. But I would stop short or writing, I don't know, x and y or a and b when I could write (x and y) or (a and b), because buggered if I can remember whether and or or has higher precedence.
|
# ¿ Mar 27, 2010 20:12 |
|
Plorkyeran posted:So in other words, you support leaving out the parentheses when you know the order of operations but want them there when you don't? Yep, fairly close to that. But I'd certainly be charitable enough to put them in when I don't feel it's sufficiently "common knowledge" what the order of operations is.
|
# ¿ Mar 27, 2010 20:33 |
|
HappyHippo posted:So what does this have to do with leaving the braces out of an if block? Nothing instrinsically. They are two separate things that I consider to be bad ideas on the grounds of contributing to poor understandability.
|
# ¿ Mar 27, 2010 21:03 |
|
https://www.youtube.com/watch?v=bOtMizMQ6oM
|
# ¿ Apr 23, 2010 01:38 |
|
Janin posted:Programming is math, but that doesn't mean it uses the same weird notation as algebra. (a) is a fairly natural way to express binary relations between mathematical objects, (b) needn't be seen as having any greater connection to algebra (in either the layman's or the mathematician's use of the word) than it does to any other field in which set theory is used.
|
# ¿ Jun 19, 2010 01:52 |
|
code:
|
# ¿ Jun 23, 2010 16:56 |
|
dark_panda posted:Further to that, the MySQL Gotchas list. I looked through that list and I would say the things on it fall into three categories.
dark_panda posted:schizophrenic features that sometimes work on certain table engines but not on others... While I can see how that might be frustrating, I don't see how they could have implemented a flexible system for allowing swappable storage engines without having features that work on some engines but not others; and the swappable storage engines are nice to have. At any rate, most applications are fine sticking with InnoDB for just about anything, maybe MyISAM for text searching. Can't comment on spatial data types, never used them. I have no reason to doubt what you say about them.
|
# ¿ Jul 2, 2010 14:05 |
|
dark_panda posted:As for some problems that can be solved by traditional mode, well, even those cases seem flat out weird. For instance, even with traditional mode enabled, "SELECT 1 / 0;" still returns NULL, 'cause apparently the ERROR_FOR_DIVISION_BY_ZERO option only errors out on INSERTs and UPDATEs; meanwhile, for SELECTs, a warning is silently produced. I didn't know about that. That is not very well implemented. quote:Further to that, why do they handle division by zero but not the square root of negative numbers or any other situation where the result of an expression is mathematically undefined? This works fine: Yeah, I would agree that throwing an error would be appropriate here. Although as a mathematician I feel the need to be picky and say that the result isn't "undefined mathematically", it just isn't a value that MySQL is designed to be able to manipulate. But it is a definite value and NULL isn't appropriate. quote:Speaking of collation support, I find it bizarre that the default encoding and collation settings are latin1 and latin1_swedish_ci respectively. Collation is a bit harder to default, I guess, and I know MySQL AB is based in Sweden, but I would at least think that these days UTF-8 would be the more popular choice for the encoding. Arguably, but you have to bear in mind that MySQL will reserve 3 bytes per character if you make a CHAR column UTF-8, so it is not without side-effects. quote:The swappable storage engines can be alluring, but in the end it seems to cause so many headaches that you start to wonder if it's worth it. You could take either of two positions on the subject. On the one hand you could say that it's good to have swappable storage engines in principle, because it means that developers have the freedom to create engines optimised for all sorts of different tasks. This is largely a theoretical advantage, although you can see it to a certain extent in the existence of the ARCHIVE and MEMORY engines. On the other hand you could argue that it leads to huge duplication of effort and results in none of the engines being as polished as a single engine could be if it was focused on by the design team.
|
# ¿ Jul 4, 2010 14:32 |
|
dancavallaro posted:At first I thought that was way too spot-on to be real, but I'm honestly not so sure anymore. In his post about "landing a high-paying new job", he mentions and links to a post he made on Reddit (http://www.reddit.com/r/programming/comments/c2lcy/ask_proggit_any_excellent_beginner_books_on_crypto), where he asks about books that will help him learn crypto without delving into "overly complex" topics like rainbow tables and ciphers (what the christ?). And the post on Reddit seems pretty real, it's a pretty typical "asking for help" post with a healthy dose of stupid on top. If this guy is faking it, he's doing a really loving good job. That doesn't demonstrate that he's for real. He could equally be trolling or trying to drum up more visitors for his blog while remaining in character.
|
# ¿ Jul 7, 2010 17:10 |
|
tef posted:they're called race conditons because they make the code go faster what you need here is a big red stripe!! and maybe a chevron
|
# ¿ Jul 8, 2010 18:21 |
|
FinkieMcGee posted:Just found out in one of our applications database credentials are being passed via a querystring through an iframe. You mean the user enters credentials and they're submitted this way, or...?
|
# ¿ Sep 13, 2010 01:57 |
|
king_kilr posted:I've never been responsible for employee interviews before, but if I ever am, I'm asking a question about how the candidate feels about type coercions. are you going to ask that in order to see whether they agree with you, or to see what knowledge they display about the subject and what reasoning they give for their opinion?
|
# ¿ Sep 27, 2010 13:30 |
|
Lysandus posted:
I think this could be defensible, depending on what exactly it's being used to do. Similar to how while (true) {...} can be a useful control structure.
|
# ¿ Sep 27, 2010 15:00 |
|
Mustach posted:Have you heard of the if statement? Yes, I have. I sense that you think you are making a point in a pithy fashion. Please make your point more explicitly.
|
# ¿ Sep 27, 2010 17:46 |
|
Ryouga Inverse posted:It does things exactly once. Unless you are doing i--; in the body... Yes, I realise that. Ryouga Inverse posted:... which is just all kinds of hosed up. It wouldn't appear likely to be the best way of achieving whatever is intended, but I don't think it's clear-cut enough to write off as definitely wrong in all situations. Chances are high (given the thread) that in the code it was taken from it was not appropriate, but I cannot conclude that any and every use of it would be indefensible. Ryouga Inverse posted:while(true) is a completely different control structure and actually has a use. Different in effect, certainly. I'm not sure it qualifies as being different in style. Both are ways of using looping structures that aren't on the face of it the "usual" or most straightforward way of using those structures.
|
# ¿ Sep 27, 2010 18:21 |
|
pokeyman posted:You might've had a point with do { .. } while(0), but you missed your chance. I don't see what you mean. Yes, do { ... } while (false) is another good example, although as far as I am aware it only provides the same functionality as goto.
|
# ¿ Sep 27, 2010 18:22 |
|
pokeyman posted:Sorry, I thought we were playing "seemingly odd but legitimate uses of loops", not "heh everything is a goto". Well, it could be that there is a use for do { ... } while (false) that has not occurred to me, but my own use of it has been limited to error checking; as in code:
I don't know what you mean by "heh everything is a goto". I don't think I've said anything to that effect.
|
# ¿ Sep 27, 2010 21:34 |
|
Mustach posted:The point is that they implemented the if statement with a for. I'm sorry, but I don't understand your reasoning. How is that in any way an implementation of the if control structure?
|
# ¿ Sep 27, 2010 21:40 |
|
Lysandus posted:I challenge thee to provide an example. I cannot.
|
# ¿ Sep 27, 2010 21:44 |
|
Janin posted:do { } while(0) is really only useful for preprocessor macros. That use of it for error handling is obscene, just use goto, gently caress, it doesn't bite. I would use goto, but it isn't available in PHP until version 5.3, and I want my scripts to be portable to hosts running versions 5.0 and above.
|
# ¿ Sep 27, 2010 22:53 |
|
Quote is not edit
|
# ¿ Sep 27, 2010 22:54 |
|
pokeyman posted:I had no idea we were talking about PHP. My apologies. For myself, I didn't think what we were talking about was specific to PHP - what's different in other languages? Tell me more.
|
# ¿ Sep 28, 2010 00:53 |
|
Bozart posted:I am totally unfamiliar with PHP, but why wouldn't you just use an else if? That break in each of the if blocks makes me want to check that it exists in all of them or if there is some kind of bizzaro override. I tried using if... else if... else if... else but didn't like the way it turned out, chiefly because it's too easy to end up with something like this: code:
|
# ¿ Sep 28, 2010 09:18 |
|
Sagacity posted:This is actually quite amazing. For all the weird quirks and invitations to abuse the language PHP has, it only recently acquired the goto statement? Yup, I was surprised when I realised this as well.
|
# ¿ Sep 28, 2010 09:43 |
|
WildFoxMedia posted:Ever considered using Exceptions? I've heard of them but I haven't made the effort to learn about them yet. I'm a little suspicious of them because I don't understand where the flow of control goes when one happens, but this is entirely down to me not knowing anything about how they work. Fehler posted:I always do something like this: (code) Yes, in places where I want to list all the errors (rather than stop after the first one) I do something similar.
|
# ¿ Sep 28, 2010 12:45 |
|
fletcher posted:My friend was taking an online quiz and I noticed how lovely the website looked, so I did a View->Source to have a laugh. All of the answers to the questions were in there as <input type="hidden"/>. Not only that, but the last 10 questions had incorrect answers marked in the key. After you finish the quiz it doesn't tell you your score or which ones you got wrong, it's just a pass/fail, so who knows how long this has gone by without notice. What kind of online quiz? One of those "WHICH FAMILY GUY CHARACTER ARE U???" type ones, or something important?
|
# ¿ Sep 30, 2010 00:45 |
|
Argue posted:Okay, here comes another wonderful piece of architecture from our client, incidentally a very large company that's well-known in my country. Hahaha "Your PIN has been reset. Have a nice day!" "What nooooo"
|
# ¿ Nov 8, 2010 09:32 |
|
pokeyman posted:So two of them should bring your hard drive right back. Good point! Better stick another couple in just to be safe.
|
# ¿ Nov 11, 2010 21:14 |
|
GrumpyDoctor posted:Maybe I'm the real horror here, but I think I agree with the lead dev on this one. Agree that it's more concise, or that it's better? (It is one of those things, but not the other.)
|
# ¿ Dec 3, 2010 02:22 |
|
The argument in defense of Microsoft isn't that they're competent, merely that they're not necessarily being dishonest. Also, the whole thing is still in beta isn't it?
|
# ¿ Dec 8, 2010 19:32 |
|
The whole "omg PHP type-juggling" thing is a bit of a dead horse isn't it? Yeah it's not always terribly consistent, it's meant to allow you to Get poo poo Done quickly. It's not necessarily optimised for that, but it doesn't do too badly. It does give you ways to compare things carefully when you need to do so. The main comparison-operator complaint I have about PHP is that if you want to check whether a variable exists and is null, you have to use array_key_exists($var, $GLOBALS). You can't use isset() (because it returns false if the variable is set but is null) and you can't use is_null() (because it returns true if the variable doesn't exist) (you still shouldn't use is_null even if it didn't do this, mind, because it will cause unset variable notices).
|
# ¿ Dec 9, 2010 21:21 |
|
tef posted:You are claiming to be a painter but all you do is cover walls in your own faeces because you can't get the paint cans open. If you want to slate PHP, I can think of at least 10 things that are more worthy of criticism than type-juggling.
|
# ¿ Dec 9, 2010 21:48 |
|
|
# ¿ Mar 28, 2024 10:43 |
|
king_kilr posted:Yeah, I forgot "gently caress my life" == 0 really helps make websites faster :?: I interpreted this as: "Your post is wrong, because type-juggling does not cause websites to run more quickly". This is a misunderstanding of my post - my implication is that it makes some general-purpose scripts easier to program (where strict attention to the types of data is not required). That is, writing code can be faster. There are many situations in which type-safety is required, in which case it is available. Hammerite fucked around with this message at 16:40 on Dec 11, 2010 |
# ¿ Dec 11, 2010 16:34 |