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
Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off
Ok, so this guy is a prick. I told him to take his java code and turn it into c# code, because we're a c# shop. And he said "<bosses name> has been riding me, and he said i could write it in java code", or something like that. Kinda pissed me off, but ok, can't over-rule the boss(at least not without talking to him first)
Next time I saw <bosses name> was at a meeting about the project.. This was also the first time i got to actually see idiot's code. He had put everything in a single 3000 line file. Not only that, but he had written everything in functions (or methods if you wanna get technically correct). Each method dealt with one line. And yeah, each method had code in it that parsed the given line. But it just printed out to the console. It didn't do anything with the result of that parsing, or decoding. really. This is what he had:
code:
void ParseLineType1(string Line){
    String field1 = line.substring(0,8)
    Console.WriteLine(field1)
    String field2 = line.substring(8,10)
    Console.WriteLine(field2)
    ...
    ...repeat for every field in line
    ...
}

...Repeat for every line type (about 3 thousand lines of code)
He had the actual field names instead of field1, field2 etc...and the actual line types for method names. That's not the point, it's that his code didn't do anything. It just printed out stuff to the screen.

This stuff has to go in a database, not to the screen. And besides, some lines are gonna have info that other lines need if you want to put them in a database, and link them together. For instance link the merchantId with the various authorization records. I knew this, and I hadn't even read the spec really. I kind of scanned over it. It's just common sense. There was no way his solution was gonna work, and he'd basically wasted his time.

I was more diplomatic than that though. I said look, you need to break this out into objects, and you're gonna want to use a base class, an abstract base class really. You might as well write it in c#. But it was as if he had no idea why he would need to do that. He really pushed back.

Oh, and the fact that he has a 3000 line code file that was not auto generated. If you find yourself in the middle of typing up a 3000 line file, you should probably rethink your career choice.

Wow, sorry this is so long. But this guy really got under my skin. I've had a real breakthrough recently, and realized I need to stop coddling these guys. If I can tell they're not gonna work out after a week, I need to fire them (I don't really have the power to fire anyone, but the owner loves me, and trusts my opinion implicitly). It really wastes everyone's time to let them linger on

This was not the end of this guy, but I can assure you it has ended now. We have a new rule in my office. If you have a project with a 3000 line code file in it that was not auto-generated, you are fired. I have more about this guy if anyone cares.

.

Adbot
ADBOT LOVES YOU

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

awesmoe posted:

What's wrong with 3k line files? If you're looking at two different pieces of code at once,you're going to have to open another view(/window/split/tab) for the second piece. Why does it matter whether the code is 3k lines away or 10k lines away, or whether it's in a different file? (Unless you never learned to use your editor, I guess)

Yes longer files can be annoying and can be a code smell, but seriously, firing people for 3000 line files? That's a management horror right there.

I knew someone would fuckin' say this, so I'd just like to note that
1. I will make an exception for people who come to me first and I approve of their approach
2. They can always split there code into partial classes to get around the rule
3. I was kidding, there is no such rule

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

awesmoe posted:


...My main point is that messiness (not file length) is what matters when it comes to refactoring. I dislike the dogmatic attitude that guy had - and if I had a manager who made decrees like the above, I'd sigh heavily and start daydreaming about writing my code with line 2999 being #include "filename2.cpp"

Actually his code was not messy at all. Sure he had hundreds of methods that all did basically the same thing, but it was very neatly typed, indented and even commented in places. My point was that his code was not very extensible. I asked him how he planned to proceed with the project and he had no idea. I knew how he could proceed, but he wouldn't listen to me. And it took me and a coworker and my/his boss telling him to, before he agreed to.

And if it's so easy to navigate around one giant file in modern IDEs, why not put all of your classes in one file. Why this arbitrary practice of placing different classes in different files? Just shove em all in one big file. Saves a lot of time not having to right click->new class. Right?

Oh and in case you missed it the first time. I was kidding. It was a joke.

*edit* I think I'm gonna start coding this way, it really would be convenient!!

Jen heir rick fucked around with this message at 23:56 on Dec 15, 2012

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

awesmoe posted:

1. You haven't explained why it's an approach that needs special-case approval
2. So it's literally dogma, rather than an objection based on a short-files-enforce-reduced-class-length-to-maximize-responsibility-splitting argument (for example). Cool.
3. Well I guess if you're not actually doing what you said you were doing, it matters a lot less!
1. Jesus Christ you're thick
2. Jesus Christ you can't take a joke
3. That's right it was a joke, were you really reading and responding to these one at a time, and it was only at this point that you realized I'm "not actually doing what you said you were doing"? Or did you just waste your time writing out these detailed responses in order to argue with no one?


awesmoe posted:

I was replying to the guy who said "I refactored a long file into 3 short classes".
In your example, you weren't refactoring his code, you were binning his lovely code. Guess what? If he'd split it into six 500 line files you would still have binned it because it would still have been lovely! (I'm not arguing the shittyness at all, it all sounds very stupid.)
Yeah, I know who you're replying to. I'm replying in his stead, because you're being obtuse.. There always has to be some jackass jump in and tell someone they are the true horror. You are that jackass

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

awesmoe posted:


...
I don't! In fact, you're the one suggesting/requiring that closely related pieces of functionality should be split up for...inconvenience?
...

Who said the file contained "closely related functionality"? Unless by closely related you mean they're close together in the same file, and by functionality you mean they all do nothing of consequence.

By the amount of words you use when you post, I'm gonna guess you have made a few 3000 line files yourself. That's the only reason you're defending this guy. Well you can hire him. He'll be looking for work soon.

And you know what? I double take it back. I am gonna make a rule. Only the cutoff is now 3284, just to be even more deliciously arbitrary. No exceptions. I'll call it the awesmoe rule.

I have more awesome stories to share if awesmoe would just shut up. He's ruined my flow.

Jen heir rick fucked around with this message at 02:13 on Dec 16, 2012

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

Doc Hawkins posted:

This person is an intern, right? Like, they've never really programmed before. Give me that at least.

Fresh out of college. Rave reviews from all his professors. Must be a lovely college. I didn't really want him to do this project. I wanted him to tackle some easier stuff before he tried something of this magnitude. but my (sorta)boss went and gave it to him.

He (sorta boss)doesn't really understand that not all programmers are equal, and figured anyone would do. He's also not very good at determining how difficult something is. In addition we have poor communication because he's out of the office a lot. Largely because of this incident, all coding decisions have to go through me now, and hiring decisions go through me too(orders from the big boss), but we're gonna have to work on the communication issue.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

Doc Hawkins posted:

See, this is why I only work at shops that do %100 pairing.

Interesting idea. I like it!

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

Ruzihm posted:

I must be misreading something. How can flow go from running Task.Run to going "out" into running Scope.Dispose, when one is in an if and the other is in an else, and the only recursion occurs from the if block?

When I first read it, the horror I saw was that it should only need to spawn the one thread which could just be iterative. And from what Plorkyeran said, it should implement IAsyncDisposable and have the method be DisposeAsync.

Is it supposed to Dispose when 10 seconds have elapsed regardless of the refresh's progress? If not, then I think Volmarias nailed it especially with the if at the end.

I think the problem is that the code that calls dispose doesn’t know to wait for the task to complete. Once dispose is called the runtime is free to garbage collect the object as well as anything it references. So you end up with a race condition.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off
That looks like a CORS issue, nothing to do with leap year.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

OddObserver posted:

I would be surprised if failure at CORS preflight time was that sensitive to the request URL.

It’s not, somebody misconfigured a server sometime this morning causing CORS errors, and for some reason twitter is blaming it on leap year.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off
Ok, good to know I’m half right. It just really bugged me that everyone on twitter was saying it’s cause of leap year.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off
I think it is a little different to see a CORS error message and assume it’s a CORS error vs assuming it’s a leap year bug. But fair enough. I am the horror this time.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

Kazinsal posted:


This is an absolutely batshit insane hack and I both hate and love it.

Great post. I don't know much about hardware stuff. Why is this such a batshit insane hack?

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

Spatial posted:

It's so goddamn slow too.


Same. I don't know how it's so slow and lovely. I've literally just done a recursive DIR command on a directory, output to file and ctrl-f to find a file and it was faster than windows search.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

smackfu posted:

So I suspect Spotlight is involved.

Yeah spotlight sucks just as much as windows search. Which is crazy, because back in the macos 9 days, when it was called sherlock, search was instantaneous and actually searched your entire harddrive. Of course it only searched file names, but I have literally never found it useful to search contents on local search. Maybe that's the problem. I start typing "the.." and it tries to show me every file that has ever been written. Real useful.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

Kazinsal posted:

It was designed originally for COM components, then between 3.1 and NT they realized, oh man, we can just have programmers shove their config data in this structured, centralized database with optimized access routines, instead of littering the filesystem with INI files that need to be parsed line by line constantly.

Of course, the dipshits over at .NET a few years later went XML ALL THE THINGS and ruined that.

I don't know what you're complaining about. Com and the registry sucked all kinds of poo poo. It's much easier now.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

Tann posted:

Just found you can do something like sql injection in my game lol

I let you rename heroes between fights and it all uses my weird modding thing. If you rename them to eg "jenny.hp.500" then they gain the name "jenny" and 500hp.

This sounds like a cool feature, not a bug.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

JawnV6 posted:

https://x.com/ataiiam/status/1765089261374914957
:smug: its so clever a human couldn't write it

That's a lot of useless comments. Be nice if it said what the type is for and how it's used.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

NihilCredo posted:

It's code that given a schema object generates the types defined by that schema.

I've seen very similar code (quite a bit more complex, actually) in SDKs for services that let you define your own data shapes, like CMSs or e-commerce platform.

Like, you setup your ecommerce so your products have a barcode and a dictionary of nutritional values. At build time, you download from the ecommerce a json metadata file that looks something like this (omitting quotes because I'm pooping): { barcode : string | undefined, nutritionalInfo: { type: object, attributes: number }}. You put that into a type, feed that to MappedParameterType<> and you have a reasonably strongly typed representation of a product that will update at compile time when you change the ecommerce configuration.

e: it's just a very basic xsd.exe but built into the language's type definition syntax

So the traditional way would be to have a compile step that generates types from a schema right? That's how I've done it, it can be kind of fiddly, but you can manually define a custom schema map/template in the tools I've used. If this thing messes up, I think you're just hosed. Schemas can get pretty complicated.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

GABA ghoul posted:

:love:

I love this so much, especially because it doesn't even work if you execute it on a German Windows

So here is the correct version that is actually safe to deploy internationally

code:

string decimalSeparator = Directory.Exists("C:\\Programme") ? "," : ".";

is_odd = (number / 2).ToString().Contains(decimalSeparator);

You can also set the current culture to en-us:
code:
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("EN-US");
is_odd = (number / 2).ToString().Contains(decimalSeparator);
I see no downsides.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off
My isEven implementation:

code:
bool isEven(int number){
    if(File.ReadAllLines("all-even-numbers.txt").Count(x => x == number.ToString()) > 0)
        return true;
    if(File.ReadAllLines("all-odd-numbers.txt").Count(x => x == number.ToString()) > 0)
        return false;
    throw new UnknownNumberException("the number does not exist";)
}

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

Bruegels Fuckbooks posted:

Here's a C# version that precomputes all even numbers up to IntMax, which obviously will save on calculation speed. We improve the initialization speed using a Lazy<T> so we only pay the cost of the precomputation on first use of IsEven()

code:
using System;
using System.Collections.Generic;

public static class MemoizedEvenChecker
{
    private static readonly Lazy<HashSet<int>> _evenNumbers = new Lazy<HashSet<int>>(() =>
    {
        var numbers = new HashSet<int>();
        for (int i = 0; i <= int.MaxValue; i += 2)
        {
            numbers.Add(i);
        }
        return numbers;
    });

    public static bool IsEven(int number)
    {
        return _evenNumbers.Value.Contains(number);
    }
}
You should use Count instead of Contains. That way it'll iterate over all the numbers and you won't miss anything.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off
My new and improved version. No text files needed. Runtime may be a problem though, just get a faster computer.

code:
bool isEven(long number){
    if(AllEvenNumbers().Count(x => x == number)> 0)
        return true;
    if(AllOddNumbers().Count(x => x == number) > 0)
        return false;
    throw new Exception("the number does not exist");
}

IEnumerable<long> AllEvenNumbers(){
    for(long i =long.MinValue;i< long.MaxValue;i+=2){
        yield return i;
    }
}
IEnumerable<long>  AllOddNumbers(){
    for(long i =long.MinValue;i< long.MaxValue;i+=2){
        yield return i;
    }
}

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

Bruegels Fuckbooks posted:

I thought about it a bit and I think we can use tensorflow for this application. This may or may not work depending upon your CPU type and CUDA version present on your system - when you generate the model, it's important to take a vm of your working environment so you can ensure consistent results.

code:
import tensorflow as tf

model = tf.keras.Sequential([
    tf.keras.layers.Dense(128, activation='relu', input_shape=(1,)),
    tf.keras.layers.Dense(256, activation='relu'),
    tf.keras.layers.Dense(512, activation='relu'),
    tf.keras.layers.Dense(1024, activation='relu'),
    tf.keras.layers.Dense(2048, activation='relu'),
    tf.keras.layers.Dense(1, activation='sigmoid')
])

model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])

X_train = tf.range(0, 1000000, dtype=tf.float32)
y_train = tf.cast(X_train % 2 == 0, tf.float32)

model.fit(X_train, y_train, epochs=10, batch_size=32)

def is_even(number):
    number = tf.cast(number, tf.float32)
    prediction = model.predict([[number]])
    return tf.round(prediction) == 1

print(is_even(2))  # True
print(is_even(3))  # False
print(is_even(42))  # True
print(is_even(777))  # False

welp, I'm out. No idea how this works.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

The hero we need.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

Volguus posted:

If the alternative was python or electron on the desktop, gently caress yeah, Java is a million times more preferable to those abominations. If it was to be in a browser anyway, suggesting Java (as an applet? Web start?) that's is indeed a capital sin.

I don't think electron's so bad. Visual studio code is written in electron and it works pretty good.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

Breetai posted:

Had to look at some poorly running code.

Turns out the issue was a library, call it lnd.lib.input_vw for argument's sake. Every time it's used in a join spool space usage goes up like crazy.

Did some investigations in dbc.tablesv.

lnd.lib.input_vw is pretty much:

code:
select *
from lnd.db.input_tb

union all

select *
from hist.db.input_tb
where hist.db.input_tb is basically identical to lnd.db.input_tb, with only two differences:
1. hist.db.input_tb contains all entries for 2016 and before (e.g. it's a historical data store) and lnd.db.input_tb contains everything from 2017 onwards. File sizes are 2TB and 1TB respectively.
2. While it has the same primary index (on a unique alphanumerical key) as lnd.db.input_tb, hist.db.input_tb has never had statistics run on its primary index.

Even a

code:
select top 10 * from lnd.lib.input_vw
query will use up 5 loving Terabytes of spool space.


"Why do our programs run so slow?"

This is really a database horror than a coding horror isn't it? Not that it matters, poo poo still sucks.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

darthbob88 posted:

Javascript horror that just crossed my desk
https://twitter.com/eloffd/status/1770223037096329349

When making the regex, {} gets expanded to a string, "[Object object]". As a regex, a character set in [square brackets] means "find any character in this set in the given string". "mom" matches the "o" in "object", but "dad" doesn't match anything.

Yeah, but just don't do that. It's fine.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

pokeyman posted:

This is me writing any line of C++. "But does this really work the way I think it does???"

Adbot
ADBOT LOVES YOU

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off
What about COM. Anyone remember COM? Or DCOM, or COM+. It was supposed to be this magical technology where you could register a COM object and then any program would use it. And when you update with a new version it would automatically work. And you could move those COM objects to a remote server and your program would just magically keep working the same. And any update on the server would be automatically be picked up by the local program.

Except that poo poo didn't work. It was a pain in the rear end. You'd update version and the program keeps picking up the wrong one. And you'd pull your hair out trying to find the right incantation to make it work. Any type of remote COM had to be carefully designed to be called remote. So that's a leaky abstraction. poo poo was worse than what we had, which was just shared libraries resolve by PATH. Which is what we have now, which shows you how lovely com was.

Of course I haven't worked with COM in like 20 years So I may not remember the specifics, but I do remember COM sucking poo poo, and having to pierce the vale of magic was often needed to get poo poo to work correctly.

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