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.
 
  • Locked thread
Chalks
Sep 30, 2009

Bloody posted:

welp doing a few db inserts has absolutely ruined my application for some reason. was good at 2k requests per second with no db stuff, now some simple db logging is basically broken at 100 requests per second

How long does each request take?

The connection creation is probably your biggest overhead if you've not got connection pooling going on, but 100 requests per second seems low even taking that into account.

Adbot
ADBOT LOVES YOU

Chalks
Sep 30, 2009

Bloody posted:

i dunno! how does npgsql connection pooling work?

also i fudged together a bulk insert command and it is way faster than the non-bulk insert like 10x faster

Never used it myself but connectionstrings.com has this:

code:
Server=127.0.0.1;Port=5432;Database=myDataBase;Userid=myUsername;
Password=myPassword;Protocol=3;Pooling=true;MinPoolSize=1;MaxPoolSize=20;
ConnectionLifeTime=15;

Powerful Two-Hander posted:

I thought the sql connections got auto pooled or something? so even if you close the connection in code or dispose of it it actually gets retained in the background and reused

or something. i read like one tutorial today and realised that i know nothing and am actually just stack overflowing myself to success

There are usually settings that let you control how the pooling works in the connection string, but I have no idea what they default to if you don't specify them. You'd have hoped it would default to pooling but who knows.

Chalks
Sep 30, 2009

LeftistMuslimObama posted:

lol, the feedback was:

1)you code too slow and it didn't work the first time. um... ok? my programming style is very prototype-then-clean. im sorry you gave me a nontrival project to do in 45 minutes.
2)you didn't solve the problem with memcached fast enough or with the method we wanted. ok, but you also didn't ask if i had any experience with that product? ive never done poo poo with linux and said that up front. wtf.

they "don't believe in resumes", so none of the very cool real-world poo poo ive done matters. just a stupid toy coding problem. i see what y'all are saying about programming interviews just being pure bullshit

lol @ the idea that developers are expected to instantly write code that works first time. If a candidate ever quickly wrote perfect code I would immediately think that perhaps we've hosed up and given them a task they'd completed in the past or they had advanced knowledge or something.

The coding tests that we run for recruitment use a fictional language with unusual syntax and a subset of the features you'd normally expect in order to get candidates to take their time and solve the problem on the spot instead of just parroting something they've done a million times.

What strange feedback, especially about the resumes bit. I agree that you may have dodged a bullet here!

Chalks
Sep 30, 2009

hobbesmaster posted:

looking forward to updates on fark and digg!

- a post on somethingawful.com in 2016

Chalks
Sep 30, 2009

Shaggar posted:

that's not com's fault its word's

Yeah, the word com api is absolutely terrible. I've done work involving editing and generating documents via that API and holy crap you can do some wonderful things. We had code that deleted a particular line in a table embedded in the document. If the table didn't contain that line, the delete command still ran on the location it thought that element should be but instead managed to delete the end of the document.

I don't mean it deleted some content from the end of the document, but it literally deleted what ever concept word has meaning "the document ends here". The document would literally scroll infinitely downwards until word exploded.

Chalks
Sep 30, 2009

HoboMan posted:

when you want to make a rest api but your boss insists you use soap


e: wait, doesn't that setup come out to be literally the worst of both worlds?

Indeed. Unless you love soap envelopes, I guess.

Chalks
Sep 30, 2009

Bloody posted:

such an astonishing amount of effort to avoid writing sql

Linq is pretty good. Pissing around with sql data readers on the other hand...

Chalks
Sep 30, 2009

KidDynamite posted:

so a coworker ran into some poo poo yesterday that broke my brain and made me realize I am even more terrible than I thought, C# code

code:
    public void SomeMethod(...) {
        ...
        if(object == null) {
            var object = new rear end();
            object.listOfAsses = await AssService();
        }
        var objectCopy = new rear end();
        objectCopy.listOfAsses = new List<AssList>(object.listOfAsses)

        if(firstTime)
            objectCopy.SetAllAssesToFullOfFarts();

        ...
    }
why the gently caress is SetAllAssesToFullOfFarts() operating on object as well? shouldn't declaring objectCopy as new have it's values at a new place in memory? all SetAllAssesToFullOfFarts does is run a foreach on this.listOfAsses to access a subList within it where it sets a field to true. we were banging our heads against this for like 2 hours before we decided to go drink instead.

If the List<AssList> is a list of objects then it'll be a list of object references. If you instantiate a new list with that list of object references, I believe you'll get a new list of references pointing at the same objects. So you've got two distinct objects, with two distinct lists, but both lists contain pointers to the same objects so when you iterate over them you're looking at the same data.

You can do something like
code:
objectCopy.listOfAsses = new List<AssList>(object.listOfAsses.Select(x => x.Clone()));
Which should mean you get a copy of each AssList object. Perhaps. Your asses are confusing me somewhat.

Chalks fucked around with this message at 12:38 on Nov 18, 2016

Chalks
Sep 30, 2009

KidDynamite posted:

will report back if we remain terrible

If the object you're calling clone() on doesn't actually implement that function, you may be able to very quickly implement it yourself using MemberwiseClone or you might have to do something more fancy in the clone method. I've not used that function myself, but it looks cool.

Chalks
Sep 30, 2009

HoboMan posted:

wait, List doesn't have it's own Clone method????

It's easy if you've got a list of value types, everything gets complicated once you start dealing with object references though. There's no way for a clone function to instantiate a valid copy of an arbitrary object - even the MemberwiseClone function I mentioned earlier won't work on an object that's got its own object references.

Powerful Two-Hander posted:

im AssId "sqlexception"

I'm AssId "Object reference not set to an instance of an object"

I love FirstOrDefault().SomeFunction() 'cause it lets you error ever so slightly later than you would have with First()

Chalks fucked around with this message at 15:56 on Nov 18, 2016

Chalks
Sep 30, 2009

Bloody posted:

i tend to use firstordefault when i think there will probably be multiple things in the ienumerable but i dont care about them. also FirstOrDefault becomes much more tolerable when combined with the ?. and ?? operators

Yeah, FirstOrDefault is fine and ?. makes it actually really cool to work with - but I always laugh when someone's gone to the trouble of writing "OrDefault" then immediately written code that would crash if the default was ever returned. And when I say someone, it's me 90% of the time.

I usually use the function if I'm going to write some complex object creation code if the value is null, but I must admit I never knew about .Single() or .SingleOrDefault() so now I guess I'm going to start using those instead. I wonder how many latent bugs will be revealed as a result!

Chalks
Sep 30, 2009

Potassium Problems posted:

Keep in mind that both .Single() and .SingleOrDefault() will throw an exception if there's more than 1 element in the collection

Yeah, that's why I'm wondering if it'll reveal some pre-existing bugs. In pretty much every situation I use FirstOrDefault I can only have one result unless I've done something stupid like a cross product join or something, so it'll be good to catch any cases where that's happening.

Chalks
Sep 30, 2009

Bognar posted:

also if you use .Single in linq to sql, it pulls back the entire result set. entity framework is smart enough to just limit to top 2.

Pulling back the entire result set doesn't seem too bad if you're going to thrown an exception anyway if it's more than a single row.

Chalks
Sep 30, 2009

the talent deficit posted:

linq is cool but people should learn sql prob if they deal with databases. you have to learn 90% of it to use a lovely query generator anyways, may as well learn the last 10% and not rely on weird magic

Ah, you see, I started off with a 15 year old database and then had to implement entity framework database first which is something that entity decided wasn't supportable a long time ago. Hand crafting the entity generation logic onto a database that's only ever been interacted with using SQL certainly teaches you a lot about both technologies.

Now, not only do I know the data structures by heart, but I also have an intimate understanding of how the entities work and when it's all inevitably broken as gently caress, it's entirely my fault!

You really get a good understanding for why entity abandoned database first generation when you embark on something like this. Holy poo poo.

Chalks
Sep 30, 2009

eschaton posted:

lotta unironic Sybase love ITT

Put Oracle and Sybase side by side and Sybase wins every time IMO. gently caress oracle.

Chalks
Sep 30, 2009

raminasi posted:

in f# you can use double backticks to just type a drat sentence and it kinda owns

code:
[<Test>]
let ``When a butt poops the poop should be smelly`` () = blah blah

That sounds like something that could get a bit out of hand.

Chalks
Sep 30, 2009

Devops tip of the day: If you accidentally erase 1.7 million files, please don't just send an email to some senior staff members then keep using the disk for 8 hours until people wake up, read the email and poo poo themselves.

Today has been fun.

Chalks
Sep 30, 2009

Just spent a while trying to work out why some code was working perfectly on QA but crashing on production and eventually working out it's because the account id was being cast to a short at one point and all the QA accounts being tested with had low account ids. This isn't the first time we've had this either, for such an obscure bug I'm surprised how often the scenario has come up.

Chalks
Sep 30, 2009

Stringent posted:

an example of the kind of comment i'm talking about is one i just made on a bit of code that has to send a request to an external service
code:
# fields marked as optional in docs, but request returns 400 if not present
without the comment someone (me) just looking at the code later on is going to wonder why those two fields are present with static placeholder values and possibly just remove them.
i've done that kind of thing enough at this point to spot some foot guns in advance.

Yeah, the "a comment is an apology" concept might work well in a world where you're responsible for every line of code, but as soon as you start interacting with third party libraries that don't necessarily function in a sensible way, you're going to be commenting workarounds and unusual behaviour pretty often.

I write integration with accounting system software that's been around for decades and that stuff works in the most bizarre ways, often undocumented. Comment dat poo poo.

Shaggar posted:

Gotta optimize

To be fair it was interfacing with a language where integers are actually shorts, longs are actually integers and in order to use a long, you have to use a datatype called a longlong. I guess that makes it a bit less surprising that this sort of poo poo happens. What I'm saying is, never touch SAP Powerbuilder.

Chalks
Sep 30, 2009

Weekend Bridges posted:

alternatively, wrap it in a more sensible interface that can ensure proper access to the broken one. it's not always possible and it depends on how expressive your language is, but the great, great majority of the time there's nothing stopping you except putting the effort in, and that way you end up with a significantly more robust solution. sometimes you don't have the time to fix things, but i think it's worth keeping in mind that needing to comment things virtually always represents settling like that

Yeah, but often it's not just the usage but the behaviour - as in, you're setting a combination of settings for a reason besides their obvious purpose. In cases like that "proper" access is difficult to define since enabling one feature requires the alteration of settings that affect other features - putting that behind an interface makes those interactions less clear. You go from needing a comment to explain why you're altering other settings, to the developer not knowing those other settings are being altered at all which can lead to further problems. As a minimum, your wrapper would need to document the reasons for the calls you're making in comments.

Chalks
Sep 30, 2009

Weekend Bridges posted:

if those interactions are still visible to users of your wrapper, then you wrote a lovely wrapper

I think we're talking cross purposes. Say you're writing software that interacts with an archaic accounting system. In order to enable feature A, you have to change 4 different settings, each of which have a primary purpose entirely unrelated to what you're trying to achieve. If you write a function of "EnableFeature()" that just does all of that, a developer using it will suddenly find different parts of the system behaving differently than they expected. They may go and change some of those settings back after making the function call, or go into your wrapper and remove the lines that are changing these settings because why the hell are these lines of code there anyway?

Little do they know that you spent a week wrestling with this archaic and barely documented system to discover that these settings have to be set a certain way for the feature to work without exploding at some point in the future. Fortunately, commenting your apparently random code avoids this confusion.

raminasi posted:

I believe the point is that somewhere you have to write weird code, no matter how many layers of abstraction you hide it behind, and that weird code should get comments, because it's weird code

Exactly - when you're starting from scratch you can always refactor your stuff so that it's clear (I mean who the hell writes a feature as a side effect of a bunch of other settings being set to invalid or unusual values?) but when you're dealing with 20 year old third party systems they tend to be written by piling random bullshit on top of stuff that nobody really thought through, and weird code is the world you live in.

Chalks
Sep 30, 2009

loving hell why is proper source control so loving complicated.

Chalks
Sep 30, 2009

LeftistMuslimObama posted:

i mean, all y'alls first mistake is thinking gender can be used meaningfully for calculations anyway. a strict type doesn't matter because the reality is if you start using gender for calculations you are likely already loving up. for example, my creatinine clearance looks like im about to die if you use the gender to calculate reference ranges. using gender as a clinically significant factor for 90% of things is outdated medicine.

Surely using any physical attribute to estimate based on statistical averages has the same issue? I'm a little surprised that there's no distinction between "sex" and "gender" in a medical scenario, but I guess recognition of that sort of thing is more recent than many ancient systems big organisations like that would be working on.

Chalks
Sep 30, 2009

LeftistMuslimObama posted:

you misunderstand. this is my entire point. sex/gender is not a physical attribute. neither has any real bearing. sex has correlations with size, anatomy, hormones, etc, but it is not a guaranteed predictor. you're performing medicine-by-proxy when using sex or gender for these calculations. a big part of this push is moving people toward using the actual data they want (size, serum hormone levels, anatomy, blood pressure, etc).

Sorry, I mean I assume there's a medical term for the generic attributes of I referred to as "sex" (such that would be useful in diagnosis) and I just figured that medical systems would use more medicalised terminology.

And sorry if you thought I was interrogating you, I was just expressing surprise that a medical system wasn't using medical terminology from day one. I've always imagined that such systems would use all sorts of specific terminology to avoid ambiguity.

I obviously understand that statistical information obtained from basic attributes like age/race/sex aren't guaranteed predictors, but often more general information will be used prior to doing the physical testing to establish the real data, as you say.

Chalks
Sep 30, 2009

LeftistMuslimObama posted:

wasn't yelling at you in particular. more my idiot coworkers.

It's cool, I really appreciate you taking the time to respond to my dumb posts :)

I feel like I have more of an understanding of the issues now so maybe if I end up doing any work in that sort of field I'll be able to avoid being terrible!

Bloody posted:

actually i really like visual studio

I absolutely adore visual studio (although performance and stability wise it's on a bit of a downward slope in recent versions)

We use azure and visual studio team services at work and the integration is cool as hell. A really great IDE all over.

Chalks
Sep 30, 2009

fleshweasel posted:

isn't there a contradiction between "gender is just an idea invented and propagated by society" and "I am undeniably mentally a different gender than the gender I was raised as and whose genitals I possess"

Ones mind contains many ideas invented and propagated by society, gender being an extremely powerful one. But yeah, not really programmer chat.

Chalks
Sep 30, 2009

Soricidus posted:

well yeah, but gender is treated kind of differently from a lot of these things. we don't have different pronouns for rich and poor people.

You do have terms like Lord and Lady, but yeah, that sort of structure is mostly a thing of the past.

Chalks
Sep 30, 2009

carry on then posted:

today we are grappling with the fact that our git repo is 3GB and takes 50 seconds to print a git status welp cya

Is that just sheer quantity of code? We've had issues like this in the past but it's usually because someone decided to commit their binaries or something.

Chalks
Sep 30, 2009

HoboMan posted:

so i only put the dev in devops. how would i have vs2015 also rename some files on publish? or is there some 3rd party deployment thing i should use instead?

You can use .targets files to add extra tasks into the msbuild process. This might be useful to you:

https://msdn.microsoft.com/en-us/library/ms366724(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/3e54c37h.aspx

Chalks
Sep 30, 2009

LeftistMuslimObama posted:

dick presence sounds like a bloodborne secret boss

Either that or a really weird christmas

Chalks fucked around with this message at 07:59 on Dec 5, 2016

Chalks
Sep 30, 2009

Finster Dexter posted:

Agreed but as a bad programmer not sure how else to implement this very bad search filtering poo poo they want where they want to search through db rows based on any or all of about 20 different search parameters.

Generating a parametrised query in your code probably isn't too terrible, I assume you're not taking things like table names and field names from user supplied data.

I'm going to be needing to do a similar thing soon in order to have grouped filtering checkboxes on a product search. When generating dynamic (x and y and (a or b or c)) stuff, this seems like the only approach.

Chalks fucked around with this message at 15:11 on Dec 6, 2016

Chalks
Sep 30, 2009

NihilCredo posted:

I have learnt through much pain to never use nulls if any other way of representing a missing value is available.

If I have a foreign key relationship I am forced to use nulls, and if I'm doing a left join I will always get nulls for missing rows, but other than that a default value is the way to go as it's much less likely to gently caress poo poo up. Basically the null object pattern for sql

What sort of issues do you encounter with nulls? Other than .net's stupid DBNull type, I've never been particularly concerned by them. I get rather irritated by code doing things like putting blank strings into fields to indicate that the value has been cleared because it can lead to really subtle bugs.

Chalks
Sep 30, 2009

NihilCredo posted:

Well here's one from less than 48 hours ago:

We had a feature that was supposed to be active from StartDate to EndDate, but actually would end on the day before EndDate. Turns out a query was doing GETDATE() <= [EndDate] in its WHERE, thus taking the time of day into account and ending prematurely. I took my time to look for the right fix (because we have to technically support as old as MSSQL2005 where the DATE type doesn't even exist) and settled on some formula involving DATEDIFF. Tested it to make sure every edge case was covered, pushed it onto a few prod environments, everything's ok. Last Sunday it gets pushed to all prod environments, and a bunch of the really old ones break.

Turns out when those columns were originally added to the schema, somebody (who may or may not be currently paying my salary) half-assed the migration and left NULLs in the pre-existing rows instead of inserting default dates. This was like seven or eight years ago and I had no idea those columns had ever not existed - the current schema has had them as NOT NULL forever. But as it happens, GETDATE() <= NULL is perfectly legal and returns false, but DATEDIFF (NULL) throws and aborts the entire query.

So yeah, if I could know exactly with 100% certainty which columns can and can not be NULL, then I'd have no major issue with NULLs. But having to code against live production dbs that have gone through all sorts of grubby hands over the years, safely dealing with NULLs requires me to wrap literally every single column name in ISNULL() boilerplate, and it's always the one time I don't that I get bit in the rear end.

Wait, the database structure has the columns as "not null" but they contain nulls? Admittedly almost all my database experience has been with Sybase products but with those if you try to set a column to not null where it contains nulls you get an exception when trying to update the structure.

Dealing with nulls in .net is the biggest pain I've found - you'd have thought that if a column contains a null then returning null would be a pretty sensible thing rather than some bizarre "DBNull" data type that seems to exist solely to irritate me. You just have to extend the data reader to return actual useful nulls instead though and then it all just works but the main reason it annoys me is because I'm apparently too dumb to ever remember this until my code crashes. Can't cast DBNull to string! Fucks sake.

In general though I like nulls. In the example you mention, I guess there's some appropriate "default date" that you can use, but it could well be the case that if no end date is specified then there's some context specific end date that you use instead (like the end of the next working week or something based on other attributes of the record). I'd much rather use a null for that instead of setting the date to 01-01-2999 and then having a special case for that magic date or whatever. With dates that seems really insane but you see people doing magic crap like that with strings and integers all the time.

Chalks fucked around with this message at 21:31 on Dec 6, 2016

Chalks
Sep 30, 2009

HoboMan posted:

agreed that DBNull being it's own datatype is annoying as gently caress. lead to a bug for me just today in fact!

I've seen it argued that when you're doing something like execute scalar it's relevant to know whether you got a null value or whether the scalar returned zero rows, but my god there has to be a better way.

Chalks
Sep 30, 2009

redleader posted:

i know that vue.js (think knockout, but in 2016!) supports react-style server-side rendering. there's a third-party thing that allows server-side rendering in asp.net iirc

I've been impressed with vue.js in terms of being pretty straight forward to use when you're doing relatively simple things. I'm not particularly experienced with it though

Chalks
Sep 30, 2009

Just finally got to the bottom of one of our systems being really unreliable for no apparent reason.

Turns out that a third party API that we're integrating with will return the same authentication token to multiple login requests made by the same account. As soon as one of the processes calls LogOut, all other processes that happen to be running at the same time will break. Seems to be working fine in development but just randomly breaks in production because you're more likely to get overlapping requests.

Workaround until the third party fixes it: never call LogOut. :D

Chalks
Sep 30, 2009

Soricidus posted:

const has never meant "won't change".

Besides the fact that the word "constant" literally means "won't change"

Chalks
Sep 30, 2009

Soricidus posted:

maybe they'd have used the word constant if they had meant constant, instead of using a vaguely similar word to indicate a vaguely similar concept?

next let's discuss how dumb it is that the char type doesn't have anything to do with burning, cleaning, or fish

You mean the way that it's nothing to do with the word "Character"?

Maybe the word "Const" isn't a shortening of the word "Constant", or maybe it is. I'm tending towards the explanation that involves them being english words rather than completely random series of characters that just happen to coincide with words.

Chalks fucked around with this message at 11:47 on Dec 12, 2016

Chalks
Sep 30, 2009

ultravoices posted:

i wouldn't call myself competent, but I can google what I don't know.

This is literally the only thing you need to learn to be a programmer.

Nehacoo posted:

Why would I want git support in my editor? Someone mentioned that a page or so ago, I think, and I'm genuinely curious what the benefits are. I usually just keep a terminal open in another workspace and use git cli there and I've never felt constrained by that.

In VS you get little captions at the top of functions saying "Last updated by Dumb rear end in a top hat 5 days ago with a commit note of 'Farts' and work item 'Needs more farts'". Branch, commit, merge, diff, never leave your IDE again!

Chalks fucked around with this message at 17:53 on Dec 13, 2016

Adbot
ADBOT LOVES YOU

Chalks
Sep 30, 2009

Finster Dexter posted:

No that's... I don't...

If you're interviewed by competent managers/devs that should not happen at all. If you're not interview by competent managers/devs that think googling for answers is evil then my hot take is don't work there.

Yeah, in our interviews we intentionally set problems that require the solution to act unusually in certain conditions. They're free to use google to help them with the answer, but they'd better read and fulfil the specification. It's a much better test of someone's ability to actually carry out a real world task rather than their ability to pointlessly memorise algorithms.

  • Locked thread