|
spitefulcrow posted:Even the example of a testing framework probably doesn't need this since object attributes are mutable by default, mock.patch achieves the same goal in most cases without overwriting the innards of the actual function. It's conceptually cleaner to monkey-patch the entire function rather than violating the abstraction boundary. Yes, I know Python doesn't have real encapsulation because everything's mutable and this is just another case of that, but why break the conventions when you don't need to? It looks like you can't do it to methods of classes, so things aren't quite as nuts as they might look: Python code:
|
# ? Jul 13, 2013 19:50 |
|
|
# ? May 21, 2024 06:35 |
|
shrughes posted:Because of obviosity? Why would you ever change a function body via spooky action at a distance? Maybe if you wanted to confuse everybody or had some other malicious goal in mind. Any language with reasonable reflection capability will be capable of modifying behavior with spooky action at a distance. You can only choose how verbose the syntax is.
|
# ? Jul 13, 2013 19:50 |
|
evensevenone posted:It looks like you can't do it to methods of classes, so things aren't quite as nuts as they might look: Python code:
|
# ? Jul 13, 2013 20:13 |
|
pokeyman posted:KVO uses isa-swizzling, not method swizzling. (That is, it dynamically changes your object's class.) Oh - did not realize that! The more you know. Thanks.
|
# ? Jul 13, 2013 20:33 |
|
UraniumAnchor posted:I think the eventual consensus was that the assignment in the non-executing block still causes the interpreter to make "what" a local variable from that point on, instead of a function. So I guess Ruby functions aren't truly first class? code:
Thing is, it's pretty rare to define global methods in anything but short scripts and tutorials. If I'm going to write a script that does stuff mostly in the top-level anyways, I'd probably be using lambdas.
|
# ? Jul 13, 2013 21:27 |
|
Doctor w-rw-rw- posted:Oh - did not realize that! The more you know. Thanks. It's actually pretty cool. Apple has a very tiny bit of info on the implementation, and the fabulous Mike Ash wrote it up in considerably more detail.
|
# ? Jul 13, 2013 21:33 |
|
spitefulcrow posted:Thanks for talking down to me Chill, that was meant to be tongue in cheek. This is still a comedy forum. shrughes posted:Because of obviosity? Why would you ever change a function body via spooky action at a distance? Maybe if you wanted to confuse everybody or had some other malicious goal in mind. A concrete example from the top of my head: Swapping an interpreted function body with a (byte-)compiled version. It's indeed not something you want to do, unless you really are hacking at the language level. Ruby and Python are lovely languages for meta-programming, but coupled with their popularity it enabled a bunch of domain-specific languages and framework interfaces that would otherwise not be possible in, say, C.
|
# ? Jul 14, 2013 00:24 |
|
I don't really have any specific code to share, but I've recently been learning assembly as per a requirement for this embedded systems course I had to take. Microcontrollers, gotta love 'em. But really, I think that language really makes any coding a horror story in and of itself. The memory management... Oh god, the memory management...
|
# ? Jul 14, 2013 00:49 |
|
No code here but I just got something from a Java dev and the directory structure is like this:code:
|
# ? Jul 14, 2013 22:47 |
|
Wardende posted:No code here but I just got something from a Java dev and the directory structure is like this: That's from Apache Maven, it handles all dependency management, running of unit & integration tests on build and packaging into an actual artifact. It does lead to problems on Windows when you have path lengths longer than 256 characters, especially if you have classes like AbstractSingletonProxyFactoryBean. As for foo - that's because the class will be in the com.host.project.common.foo package, and package declarations have to be the same as on the file system, so you end up with pointless com\host\project folders with nothing but a subfolder in them.
|
# ? Jul 14, 2013 22:52 |
|
JakeLiebenow posted:I don't really have any specific code to share, but I've recently been learning assembly as per a requirement for this embedded systems course I had to take. Microcontrollers, gotta love 'em. But really, I think that language really makes any coding a horror story in and of itself. And then you will come to the insight that C is a high-level programming language :p The loops you have to jump through, eldritch incantations and litres of chicken blood to get the C runtime working with a simple usb or ethernet stack ... Had any fun with the interrupt vectors yet?
|
# ? Jul 15, 2013 10:33 |
|
Wardende posted:No code here but I just got something from a Java dev and the directory structure is like this: Personally, I hate it. The workaround is to never ever look at a java project without an IDE.
|
# ? Jul 15, 2013 16:07 |
|
Dren posted:Personally, I hate it. The workaround is to never ever look at a java project without an IDE. It's not a workaround, it's a requirement. Don't go against the grain, you'll only hate yourself even more.
|
# ? Jul 15, 2013 16:34 |
|
Also make sure that your version control system is included as part of your FIGNORE environment variable so you can tab complete through the empty directories more quickly.
|
# ? Jul 15, 2013 17:09 |
|
Strong Sauce posted:Apparently ruby's parser/lexer is a horror. I got through the first two sentences and immediately thought "Oh gently caress, this is sounding a lot like... PHP " Dren posted:Personally, I hate it. The workaround is to never ever look at a java project without an IDE. Stare into the abyss
|
# ? Jul 15, 2013 17:22 |
|
This is magnificent.
|
# ? Jul 15, 2013 17:26 |
|
We have some code where the author kind of jammed all behavior into a single class hierarchy. One of the not so nice things that resulted was overuse of member variables. Like any time the author thought something might be needed he squirreled it away in a base class protected rather than scoping it to the functions that used it. So anytime you see a variable anywhere it's effectively a global and you (the reader) have no clue where or when it is modified without tracing the whole program. Can people give me some language to help talk about this? When I phrased it the way I just did the author didn't seem to understand the issue. I want to be sure I have my language right before I talk about this again so I can hopefully communicate more effectively.
|
# ? Jul 16, 2013 20:16 |
|
Dren posted:We have some code where the author kind of jammed all behavior into a single class hierarchy. One of the not so nice things that resulted was overuse of member variables. Like any time the author thought something might be needed he squirreled it away in a base class protected rather than scoping it to the functions that used it. So anytime you see a variable anywhere it's effectively a global and you (the reader) have no clue where or when it is modified without tracing the whole program. Can people give me some language to help talk about this? When I phrased it the way I just did the author didn't seem to understand the issue. I want to be sure I have my language right before I talk about this again so I can hopefully communicate more effectively. God class?
|
# ? Jul 16, 2013 20:24 |
|
b0lt posted:God class? That's pretty good. I'd also really like a way to invert the phrase "don't make the scope of a variable larger than it needs to be" and turn it into something like "Scope variables to the top-level function that uses them, then pass them to helper functions".
|
# ? Jul 16, 2013 20:30 |
b0lt posted:God class? Bad encapsulation, poor separation of concerns, spaghetti in the making. I think also cyclomatic complexity refers to stuff like this, for something that can be measured. More class members increases the amount of state contained by the class, making it harder to reason about its correctness, if you want more of a "hard CS" argument. And Google for "big ball of mud".
|
|
# ? Jul 16, 2013 20:34 |
|
I guess this is ironic but I found the BBoM paper to be kind of unfocused so I stopped reading it after a bit. Still, it's a nice name. Thankfully our problem isn't there yet. I've been thinking on a more specific way to phrase the concept "don't scope a variable larger than you need to". How's "Identify the scope of the first function where the variable is needed, then scope the variable below that function." If followed, it forces authors to pass state to helper functions rather than hold onto it as a pseudo-global class member or something. I like it because it applies to constructs like classes and modules where people who have been told that globals are bad will happily create pseudo-globals.
|
# ? Jul 16, 2013 21:19 |
|
Hammerite posted:always use the braces even when they are not needed. prevents accidental "oh I'll just add another line of code to this block. welp something is wrong" bugs C++ code:
|
# ? Jul 16, 2013 21:27 |
|
We had a bug that was caused when one of our contractors did a mass replace of System.out.println with //System.out.printlnJava code:
Zorro KingOfEngland fucked around with this message at 22:46 on Jul 16, 2013 |
# ? Jul 16, 2013 22:21 |
|
NFX posted:Or the more exotic ones. I ran into this thing a few days ago at work: But I de-indented the else if statement so it'll go with the first if statement right? (although that is actually how it works in Python)
|
# ? Jul 17, 2013 00:30 |
|
NFX posted:Or the more exotic ones. I ran into this thing a few days ago at work: http://en.wikipedia.org/wiki/Dangling_else It's apparently a big debate in language design. I just always loved the straightforward answer "throw an error if it's ambiguous"
|
# ? Jul 17, 2013 01:54 |
|
NFX posted:Or the more exotic ones. I ran into this thing a few days ago at work: Zorro KingOfEngland posted:We had a bug that was caused when one of our contractors did a mass replace of System.out.println with //System.out.println
|
# ? Jul 17, 2013 02:26 |
|
Zorro KingOfEngland posted:We had a bug that was caused when one of our contractors did a mass replace of System.out.println with //System.out.println The real horror is that doImportantBusinessThing(null); does something important.
|
# ? Jul 17, 2013 02:29 |
|
butts could be some sort of state object, and passing it a null generates state0.
|
# ? Jul 17, 2013 02:44 |
|
Suspicious Dish posted:The real horror is that doImportantBusinessThing(null); does something important. It's java according to the code tag, so the if would try and cast null to a boolean primitive and throw a NullPointerException. So no worries on that front.
|
# ? Jul 17, 2013 04:10 |
|
I thought if (foo) was the same as if (foo != null) in Java.
|
# ? Jul 17, 2013 04:18 |
|
You're all wrong. edit: That code would still be valid if it were a boolean, which in Java is a primitive so can't be null. carry on then fucked around with this message at 04:33 on Jul 17, 2013 |
# ? Jul 17, 2013 04:30 |
|
carry on then posted:edit: That code would still be valid if it were a boolean, which in Java is a primitive so can't be null. It could also be a Boolean, which works as a boolean expression because it implicitly unboxes to a boolean (and naturally throws a NPE for null) Java code:
|
# ? Jul 17, 2013 05:04 |
|
Suspicious Dish posted:I thought if (foo) was the same as if (foo != null) in Java. Nope, boolean or not null Boolean only.
|
# ? Jul 17, 2013 05:25 |
|
The default user password is the same as a full access database password. The password contains the username of that database account. There is a user account with the same credentials as that database account. The user password database is not salted. pls e: It won't build when I try to use our framework's salting option, what's going wrong? code:
Amarkov fucked around with this message at 01:05 on Jul 18, 2013 |
# ? Jul 17, 2013 23:54 |
|
csammis posted:We once had a minidump faxed to us for debugging purposes. It ended up being 84 pages long. When we asked why they had to fax it the answer was "in case it needs redaction" Heh, I get logs, xml files, stack traces and all kinds of other crap faxed to me all the time. A hazard of having your software running in secure facilities with ironclad policies about moving electronic info out. Call it an Occupational Horror.
|
# ? Jul 18, 2013 15:44 |
|
Amarkov posted:The default user password is the same as a full access database password. Amarkov's coworker posted:No, see, it's okay to just use an MD5 hash, because we're using AWS! I'm pretty sure Amazon isn't going to get hacked bro.
|
# ? Jul 18, 2013 19:47 |
|
Amarkov posted:[quote="Amarkov's coworker"] Semi-related note: a developer once told me with a straight face that a bunch of admin controllers without permission checks were safe because "they were only accessed through AJAX."
|
# ? Jul 18, 2013 20:29 |
|
It turns out my assumptions were fatally flawed. What I thought was the production database was actually a secondary database, used for stuff we haven't ported off of MySQL yet. The actual production database, of course, is configured not to accept direct requests from anywhere except localhost. As such, it does not require a password. (On the plus side, they've agreed to let me actually fix this now.)
|
# ? Jul 18, 2013 21:53 |
|
Amarkov posted:The actual production database, of course, is configured not to accept direct requests from anywhere except localhost. As such, it does not require a password. That's fine because it means that a hacker would have to physically be at the machine which hosts the database to hack it. *takes a monster glue huff* wooooooooooooooooooooooooooooooh. Anyway, we use keycards, so we're covered.
|
# ? Jul 20, 2013 04:44 |
|
|
# ? May 21, 2024 06:35 |
|
Wardende posted:That's fine because it means that a hacker would have to physically be at the machine which hosts the database to hack it. *takes a monster glue huff* wooooooooooooooooooooooooooooooh. Anyway, we use keycards, so we're covered. But then there's no reason to not have a password, right? So you may as well have one in case, heaven forbid, a hacker gets to the physical machine and has someone's keycard + pin?
|
# ? Jul 20, 2013 05:48 |