Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Soricidus
Oct 21, 2010
freedom-hating statist shill

Steve French posted:

Ruby code:
describe ThingRetryWrapper
  let(:thing) { Thing.new }
  let(:thing_retry_wrapper) { ThingRetryWrapper.new(thing) }

  it "retries the right number of times" do
    thing.should_receive(:operation).exactly(3).times.and_raise(SomeError.new("oh noes"))

    expect {
      thing_retry_wrapper.operation
    }.to raise_error
  end
end
:barf:

(I assume you intended the horror to be Ruby DSLs, but if you had something else in mind then do please feel free to point it out.)

Adbot
ADBOT LOVES YOU

Soricidus
Oct 21, 2010
freedom-hating statist shill

M31 posted:

Composition is much more maintainable and having a standard class with all character attributes seems pretty logical to me in that context, even if you have a gazillion attributes.
This is the first time I've heard "gently caress it, let's just indiscriminately throw everything into a single class" described as composition.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Aleksei Vasiliev posted:

How to Multiply in C Programming
Looking through his other videos this doesn't actually look like a troll.
His name is Butt.

Soricidus
Oct 21, 2010
freedom-hating statist shill

qntm posted:

Code is not documentation. It doesn't matter if the code is tests which test other code. Tests need documenting as well.
God yes. I see people saying "just read the tests" and all I can do is wonder how they've gone so long without seeing the spaghetti that often passes for tests in the real world. Assuming the test suite even invokes the method you're interested in at all.

If someone* looking at a method can't understand what it's for and how it's used without referring to external documentation or tests, your code is bad. Sorry. That doesn't mean you have to write a thousand-word essay explaining every trivial getter, but it sure as hell does mean you need to document anything that's non-trivial - and that applies to any code that will ever be maintained, not just public APIs.

Unless your employer actively supports paying people to reverse-engineer their own products, I guess, but that seems like a rather inefficient way to run a business.

* Someone who knows the language and has a basic understanding of the domain you're working in, at least. For example: you, in six months' time.

Soricidus
Oct 21, 2010
freedom-hating statist shill
Could someone who's arguing that tests can make good documentation please post an example of a test suite they'd like to use that way? I'm honestly interested to see what you have in mind.

Soricidus
Oct 21, 2010
freedom-hating statist shill
I love the argument that comments might get out of date so you should just abandon them and use descriptive method names instead. Because there's no way anyone would ever change a method without updating its name ... right?

Missing method comments are a code smell. It might still be good code, but it's often a sign of sloppy maintenance.

Soricidus
Oct 21, 2010
freedom-hating statist shill

astr0man posted:

If it's obvious what your code is doing it doesn't need comments. In this case if your function was named handle_butts() or something it wouldn't need any additional explanation.
This very day, I was briefly stumped by a bug caused by a method called getValidPositions not, in fact, returning a collection of valid positions.

Fortunately there was an accurate and detailed method comment that explained what it actually did, so I didn't have to reverse-engineer it like I would have if its author had subscribed to the opinions of some posters in this thread of horrors.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Subjunctive posted:

I think we use libjpeg as JS for client-side image resizing now.
I long for the sweet embrace of death.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Deus Rex posted:

It ranges from trivially easy to pretty easy to set up in every operating system I've ever used. If you're not using it and value your data, you probably should be!
It's a tradeoff. Are the tiny performance hit, and the tiny risk that you'll forget your password and lose all your data, worth the assurance that nobody else will access that data without your knowledge?

On my phone, it's a no-brainer. The data's all in the cloud anyway, and the risk that someone else will get their hands on my phone is very high.

On my PC? Not such an obvious choice.

Soricidus
Oct 21, 2010
freedom-hating statist shill

sarehu posted:

If you would be screwed by a lost password then you'd also be screwed by a hard drive failure.
True. Encryption is still introducing an extra point of failure, though. (And would make it impossible to recover anything whatsoever from a failing drive.)

The risks are small. Backups exist, etc. But the risks caused by just not bothering to encrypt everything are also frankly insignificant, so why bother, unless you're paranoid about the Feds kicking down the door and stealing your cat videos?

Soricidus
Oct 21, 2010
freedom-hating statist shill

ATM Machine posted:

The more I learn about Java, the more I scream
Here's the fun part: the same kinds of gotchas certainly also exist in every language you like. You probably just don't know yet, because only a handful of languages, including Java, are sufficiently widely used and well understood for many people to be aware of such flaws.

Soricidus
Oct 21, 2010
freedom-hating statist shill

YanniRotten posted:

I understand that a pretty minimal level of application security is often 'good enough' for an enterprise application where your users are generally non-malicious, non-technical, and probably don't care at all about stealing or damaging data.
Maybe this used to be true. It's pretty clear now, however, that you cannot afford to have this attitude if your business depends in any way on your data remaining confidential (which it probably does, particularly if you're doing anything financial or healthcare-related). It doesn't matter if the vast, overwhelming majority of your users are nice people who wouldn't dream of trying to subvert any security. It only takes one Snowden to gently caress you up.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Scaramouche posted:

Not really coding horror, but sometimes funny, the underhanded c contest has started again:
http://underhanded.xcott.com/

Basically the idea is you're given the outline of an assignment and then have to program something that fulfils the initial criteria while also sneaking in some kind of underhanded functionality that isn't immediately obvious, either via obfuscation, the general obtuseness of C, or whatever.

I haven't seriously touched C in over 10 years so a lot of it flies right over my head. Anyone willing to take samples from previous years and explain why it's underhanded is certainly welcome to.

Brb, just submitting the OpenSSL source code.

Soricidus
Oct 21, 2010
freedom-hating statist shill
If you hate clearcase, wait till you've tried clearcase where branching is disabled in all vobs and the use of commit messages is strictly forbidden in favor of a separate central manually-updated commit log that in practice has barely been touched since 1997!

Soricidus
Oct 21, 2010
freedom-hating statist shill

Xenoveritas posted:

Well, I'm not going to post any actual code, instead I'll just say:
  • Single 3,000 line Java file
  • Which contains seven classes
  • In the default (empty) package
  • 150MB of dependencies, the bulk (135MB) of which appear to be data files for a single dependency
  • Sole public interface appears to be public static void main(String[])
  • But every method is public anyway
  • Except for constructors, which are all package access
  • Rather than throwing exceptions, all error handling is done using System.exit(1)
  • Conceptually this code is supposed to be made available as a web service...

Until you got to the last line there, I thought I knew which program you were talking about.

Now I'm just going to sob gently at the horrifying revelation that there's more than one of them.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Xenoveritas posted:

gently caress, I'm wrong about what it does if the lengths are equal. If the lengths are equal, it then goes through the string characters backwards and checks each character's lexicographical orders.

Java code:
    for (int i=(S1.length()-1);i>=0;i--){
        if (S1.codePointAt(i) > S2.codePointAt(i))
            return true;
        if (S1.codePointAt(1) < S2.codePointAt(i))
            return true;
    }
    return false;
Edit: God drat it, I still read it wrong. It returns true if any character is different anywhere in the second string. What is this even doing?!

Edit 2: Oh, another transcription error on my behalf, that second comparison isn't S1.codePointAt(i), it's S1.codePointAt(1).
This gets better and better!

Soricidus
Oct 21, 2010
freedom-hating statist shill

Munkeymon posted:

The nutbar that used to be the senior admin around here likes to use disaster names and rather presciently picked tsunami in November 2004. Wouldn't be so bad but the idiot didn't rename it before calling in for tech support in early January the next year to getting something set up. Tech support was, of course, in Indonesia.

Congratulations (?), you have managed to get the server-name derail back on topic.

Soricidus
Oct 21, 2010
freedom-hating statist shill
Also I ran into some servers named after my little ponies today and I think I want to kill someone.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Che Delilas posted:

Look man, it's not the enterprises' faults if they don't want to pay enough to attract more than entry-level talent.

I don't think you get the enterprise. The whole "gotta pay big money or you'll get lovely people" principle only applies to executives. Regular employees don't care about the money, they just want secure jobs with good benefits so the executives can save even more money when they outsource them, and get an even fatter bonus

Soricidus
Oct 21, 2010
freedom-hating statist shill

Ithaqua posted:

The people who don't care about being paid a fair market value for their skills are almost always lovely

You know that. I know that. The people who make hiring decisions for enterprise software development apparently don't.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Subjunctive posted:

Same as the apps that wrap a webview and ship a local-only node server as part of it; it's not the worst way to build an app

This is true, but only because the option exists to build an app with an Excel user interface driven by VBA.

Soricidus
Oct 21, 2010
freedom-hating statist shill

hobbesmaster posted:

It should pretty much only be used with enums and is horribly abused in practice with everything else.

switch/case on enums is basically a bad language's substitute for pattern matching on algebraic data types.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Skuto posted:

I don't even know what this is.

It's like switch statements, but better.

Soricidus
Oct 21, 2010
freedom-hating statist shill

QuarkJets posted:

In what sense? I've never heard of these before, so I looked up some code examples. Can you explain the advantages for us?

Strong typing and exhaustiveness guarantees. You can't easily get those if enums are just aliases for ints. Java-style enums get you part of the way, but still have annoying limitations.

Then proper sum types extend the enum concept by allowing you to associate variable data with some members, which is similar to, say, using a combination of an enum and a union in C, but again with actual type-checking. And pattern matching then lets you destructure those and use bits of their data in the matching process. It gives you a very nice natural representation for things like trees with associated data.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Powerful Two-Hander posted:

Are all developers poo poo?

Yes

Soricidus
Oct 21, 2010
freedom-hating statist shill

QuarkJets posted:

Variable declaration and scope are way simpler in Python than in any of those other languages, so this is just :psyduck:

Probably the problem is the whole "global" mess where you can read from something but trying to write to it without saying please will break everything.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Someone I would be fired for naming posted:

We don't need source control anymore now that we've switched to Python.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Hammerite posted:

The worst thing about this code is that it uses a double for something in a particular unit and that the user has to be reminded with a little comment what unit they are supposed to use. Good until at some point in the future someone has a brain fart and forgets about units, and assigns a value which is actually in calories per half-hour per acre. It should use instead an object representing the value, from a class that is aware of units and unit conversions.

That would be a great idea if Java had operator overloading.

Soricidus
Oct 21, 2010
freedom-hating statist shill
guys, guys, this language that I am intimately familiar with behaves the way I expect, so clearly what it does is natural and logical and anyone who thinks it's flawed or inconsistent simply doesn't get it

Soricidus
Oct 21, 2010
freedom-hating statist shill
Python is fine and often a good choice, but it's dumb to pretend it doesn't have a bunch of warts.

The same goes for pretty much every language. If you can't list a bunch of nasty design flaws in a given language, you probably don't know it as well as you think.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Thermopyle posted:

Stop saying probably wrong things that many people are obviously going to disagree with you on and then going "but I'm not going to explain them except in some amazing magnum opus that I'm not actually going to write".

That's bullshit inflammatory arguing.

Actually please carry on doing all that, but in yospos

Soricidus
Oct 21, 2010
freedom-hating statist shill

JawnV6 posted:

Such as?

Java or C#. Either is a better choice than a plang in any non-throwaway situation where a plang was an option in the first place.

They're quite expressive enough in practice, it's easy to find people who know the languages, performance and tooling will be vastly better, and you get to take advantage of all kinds of useful static analysis that is flaky at best in a plang.

Any other opinion is born of ignorance or prejudice.

Soricidus
Oct 21, 2010
freedom-hating statist shill

QuarkJets posted:

And what if you're solving a problem that hasn't been solved before?

If you think you fall into this category, you are probably mistaken.

Feel free to keep right on reinventing the wheel, though, rewriting things in increasingly inefficient ways has kept programmers employed for decades now and there's no reason to suppose you can't spin it out for the rest of a lucrative career!

Soricidus
Oct 21, 2010
freedom-hating statist shill
Hitler trusted professional cryptographers instead of rolling his own, and look what happened to him.

Don't be like Hitler.

Soricidus
Oct 21, 2010
freedom-hating statist shill
When I want to crypto I usually make a one time pad, which is where you use rand() to seed itself so the seed is also random and nobody can recreate the key. Then you just xor that with your message, making sure it's the same length as the key otherwise it's not secure. Send the key in one email and the message in another from a different address so even if the nsa intercept one they'll still be out of luck. Don't forget to encrypt the subject line too because if you just send it saying "cipher key" they'll probably notice that. That's all it takes really, dunno why everyone makes it out to be such a big deal.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Dr. Stab posted:

What else would you name a variable that flips itself and does nothing else?

x

Soricidus
Oct 21, 2010
freedom-hating statist shill

pigdog posted:

Even if you can't code for poo poo and the code you first come up with is completely retarded, you can still be confident that it works

You can be confident that it passes your tests, and nothing more. Congratulations, you have successfully moved the point of failure from one chunk of code you wrote to another chunk of code you wrote!

Soricidus
Oct 21, 2010
freedom-hating statist shill

Steve French posted:

Or maybe you choose not to implement your code only considering the narrow circumstances of one test at a time, and you realize from the get go that an if statement for every combination of inputs is loving stupid, and avoid wasting your time.

Exactly.

Like, the only thing I can see people arguing against is the idea that you should deliberately write incorrect code at any point and expect this to improve the end result.

Soricidus
Oct 21, 2010
freedom-hating statist shill

carry on then posted:

The entire degree program should be this. If you can't hack it in a fast paced, high skill environment, you don't get the degree. Can't pivot on a moment's notice? Fail. Can't put in 12 hour days 7 days a week like a team player? Fail. We need to be much better and finding and promoting rockstar programmers and getting rid of everyone else.

Please source your quotes.

Adbot
ADBOT LOVES YOU

Soricidus
Oct 21, 2010
freedom-hating statist shill
The horrors are coming from inside the thread

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply