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
hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

MononcQc posted:

That's IEEE Standard 754 on floating points.

±∞ × 0 => NaN
±nonZero ÷ ±0 => ±∞

Not a javascript horror.

it's weird, it takes everyone by surprise all the time, but it's consistent across architectures, languages, etc.

e: I must hold some kind of record for unintentional snipes

Adbot
ADBOT LOVES YOU

KidDynamite
Feb 11, 2005

eschaton posted:

because you're not a loving idiot, that's why you want a normalized relational database

also at least some common "NoSQL" implementations turn out to be isomorphic to the relational algebra anyway, especially as used, just with worse performance and no ACID guarantees that a real relational database (even SQLite) can provide

there was a proof 5-6 years ago that I can't find now but I recall it being pretty straightforward

I'll try to find this proof then that sounds pretty solid.

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


CRIP EATIN BREAD posted:

it also depended on weird compiler/linker behavior such as allowing duplicate symbols to be linked together (and randomly picking one of them to use in the compilation unit).

instead of making a library it just linked .o files in at random from all over the project or just copy/pasted functions randomly into other files.

:shepicide:

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
i love Infinity. initializing variables like

var smallestDistance = Infinity;

just feels... right.

Progressive JPEG
Feb 19, 2003

GrumpyDoctor posted:

i have a terrible programmer question about testing (in c#). i am writing a plugin for other software. every api i interact with uses concrete objects. how do i fake objects for testing? for example, say i've got
a FiddleWithHostDocument(HostDocument doc) method, and i want to make sure that when it runs, it sets the HostDocument.IsModified flag on the document it's passed. i can't just mock out HostDocument, because it's sealed. the only thing i was able to think of (other than using one of those mocking frameworks that rewrites IL or whatever) was, for each host api class i care about, to create a corresponding wrapper interface and concrete implementation that forwards interface calls to wrapped actual host objects, and then have my logic only interact with the interfaces, but :barf:

i just know the java side of things but it looks like theres a couple mocking frameworks thatll let you mock sealed classes via some clr hooks so just use one of those imo

Progressive JPEG
Feb 19, 2003

unit tests are v useful for making it apparent how your code could be structured differently (if only to make the tests feasible), but writing new code/hooks solely for tests to use is bad imo

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
I think nosql databases are fine as long as you don't want to do anything relational with them, ever. For instance, if you just need to store a bunch of time-series data points, something like Cassandra actually works really well for that and can be fast even after millions/billions of records.

IIRC, the most recent World Cup streams were all running through a Cassandra db, i.e the actual video was encoded into h264 and the .ts chunks being fed to the m3u8's were all uploaded and served from Cassandra.

AWWNAW
Dec 30, 2008

GrumpyDoctor posted:

i have a terrible programmer question about testing (in c#). i am writing a plugin for other software. every api i interact with uses concrete objects. how do i fake objects for testing? for example, say i've got
a FiddleWithHostDocument(HostDocument doc) method, and i want to make sure that when it runs, it sets the HostDocument.IsModified flag on the document it's passed. i can't just mock out HostDocument, because it's sealed. the only thing i was able to think of (other than using one of those mocking frameworks that rewrites IL or whatever) was, for each host api class i care about, to create a corresponding wrapper interface and concrete implementation that forwards interface calls to wrapped actual host objects, and then have my logic only interact with the interfaces, but :barf:

the only lib I've used for this is Moq but there are some others like RhinoMocks

30 TO 50 FERAL HOG
Mar 2, 2005



GrumpyDoctor posted:

i have a terrible programmer question about testing (in c#). i am writing a plugin for other software. every api i interact with uses concrete objects. how do i fake objects for testing? for example, say i've got
a FiddleWithHostDocument(HostDocument doc) method, and i want to make sure that when it runs, it sets the HostDocument.IsModified flag on the document it's passed. i can't just mock out HostDocument, because it's sealed. the only thing i was able to think of (other than using one of those mocking frameworks that rewrites IL or whatever) was, for each host api class i care about, to create a corresponding wrapper interface and concrete implementation that forwards interface calls to wrapped actual host objects, and then have my logic only interact with the interfaces, but :barf:

I'm curious as to what software this is

triple sulk
Sep 17, 2014



https://gist.github.com/rauchg/5b032c2c2166e4e36713

this is it

it's peak javascript

Shaggar
Apr 26, 2006
lmao

30 TO 50 FERAL HOG
Mar 2, 2005



Amazing

raminasi
Jan 25, 2005

a last drink with no ice

Progressive JPEG posted:

i just know the java side of things but it looks like theres a couple mocking frameworks thatll let you mock sealed classes via some clr hooks so just use one of those imo

ugh i was hoping this wasn't the answer

Progressive JPEG posted:

unit tests are v useful for making it apparent how your code could be structured differently (if only to make the tests feasible), but writing new code/hooks solely for tests to use is bad imo

while this sounds great on paper i'm really unsatisfied with declaring all code that interacts with the host api fundamentally un-unit-testable and calling it a day

AWWNAW posted:

the only lib I've used for this is Moq but there are some others like RhinoMocks

neither of those (nor nsubstitute, which i'm using right now) can mock non-virtual or -interface methods

BiohazrD posted:

I'm curious as to what software this is

rhinoceros 3d

the plugin api is largely sane and easy to work with, but it's clearly designed only to accomodate non-programmers. (i asked all their forums about why all of their api objects were IDisposable if none of their sample code actually treated them this way, and in response i got a link to the msdn page for IDisposable)

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
twitter is the package manager we deserve.

Jerry Bindle
May 16, 2003
what about a package manager where users get to vote on lines of code?

the best lines of code will rise to the top, while the useless bug-filled lines will all fall to the bottom where they can be "garbage collected"

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

GrumpyDoctor posted:

ugh i was hoping this wasn't the answer


while this sounds great on paper i'm really unsatisfied with declaring all code that interacts with the host api fundamentally un-unit-testable and calling it a day


neither of those (nor nsubstitute, which i'm using right now) can mock non-virtual or -interface methods


rhinoceros 3d

the plugin api is largely sane and easy to work with, but it's clearly designed only to accomodate non-programmers. (i asked all their forums about why all of their api objects were IDisposable if none of their sample code actually treated them this way, and in response i got a link to the msdn page for IDisposable)

you workin on some Rhino stuff? I have a personal project that my wife wants me to do involving calling some grasshopper components via c# code. I guess that's not Rhino, per se, but in my initial research the grasshopper components seem relatively sane to call from C#, despite some wackiness in providing input params to the component.

e: on-topic content: If you think the current options for testing this stuff is unpalatable, well let me just direct your attention to the Shims in the Microsoft Fakes Framework. You don't know what unpalatable even is yet.

Finster Dexter fucked around with this message at 16:44 on Mar 24, 2016

Arcsech
Aug 5, 2008

KidDynamite posted:

where can i learn more about schema-less databases? boss wants me to have real reason for wanting a normalized relational db even though we we need to emulate relationships in a schema-less db. i think he's pushing me to my limits and trying to make me learn some poo poo rather that just letting me get away with saying schema-less is bad so i can grow as a dev. i really appreciate it and don't want to let him down. also i would like to get to coding so the quicker all this poo poo is taken care off the better.

first off, lets clarify some terms. non-relational databases are not synonymous with schemaless. they often overlap, but they arent the same - you can easily have a schema on a non-relational data store.

third, read about a few major non-relational databases in different categories: cassandra, neo4j, redis, and mongo. read about what use cases these are optimized for, and think about how those are different than what you'd be able to do easily in a relational database. some of them are optimized for speed at the cost of making your data and queries more structured, some for scaling out to multiple nodes, some for specific types of querying, and some for ease of use (generally for people who think sql is too hard). they provide different guarantees - for this, it's useful to read about the CAP theorem and ACID

unless you need the speed, or your data fits a pattern with a specific type of database built specifically for it (like graph databases), relational databases have a lot of advantages, such as flexibility of querying, automatic handling of certain conditions (delete cascades, etc), and ACID guarantees. if your use case doesnt fit what a nosql database is optimized for, you'll probably end up spending a bunch of time poorly reimplementing relational database functionality over the top of whatever you pick

its more complicated than just "nosql bad", but a lot of people who think they need nosql databases would indeed be better served by just using postgres instead

brap
Aug 23, 2004

Grimey Drawer

GrumpyDoctor posted:

ugh i was hoping this wasn't the answer


while this sounds great on paper i'm really unsatisfied with declaring all code that interacts with the host api fundamentally un-unit-testable and calling it a day


neither of those (nor nsubstitute, which i'm using right now) can mock non-virtual or -interface methods


rhinoceros 3d

the plugin api is largely sane and easy to work with, but it's clearly designed only to accomodate non-programmers. (i asked all their forums about why all of their api objects were IDisposable if none of their sample code actually treated them this way, and in response i got a link to the msdn page for IDisposable)

wrapper class around the API type with virtual methods or interface implementation is probably your best bet.

you could also try to make some unit testable functions just by not directly interacting with the API type but rather by returning some value that would be used to make a decision about what you would do to an instance of the API type. for instance instead of

code:
...
string input = ...
string s = result of a bunch of poo poo with input
...
apiThing.Prop = s;
do this
code:
string GetShit(string input)
{
	return result of a bunch of poo poo with input
}
apiThing.Prop = GetShit(input);
then test GetShit and just test manually to see if you do the right thing with apiThing

it is kinda too bad that you can't write extensions to types that cause them to implement a new interface. this is a neat Swift thing

raminasi
Jan 25, 2005

a last drink with no ice

Finster Dexter posted:

you workin on some Rhino stuff? I have a personal project that my wife wants me to do involving calling some grasshopper components via c# code. I guess that's not Rhino, per se, but in my initial research the grasshopper components seem relatively sane to call from C#, despite some wackiness in providing input params to the component.

yeah, I've spent the last 2.5 years doing rhino/grasshopper plugin stuff. afaik calling into gh components is something you're Not Supposed To Do (how do you even get to them? can you create them yourself? I've never tried) but pm me if you want

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo
had a programming take home test: read a file with rows of create/update commands and execute them following some business logic

was told to code however i want and don't overengineer. i just map()'d over lines to parse into an intermediate format and then used a reduce() to go line by line and update state.

i failed because there wasn't enough OOP !!!! this was javascript!!! i should have used visitor pattern i guess

HoboMan
Nov 4, 2010

u failed bcz u post here

This si breaking my brian:
code:
DateTime sunday = DateTime.Today.AddDays(Convert.ToDouble(0 - DateTime.Today.DayOfWeek));
 GotoDate.SelectedDate = sunday;
ShowSelectedDay((int)DateTime.Today.DayOfWeek);

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
you failed the minute you used javascript

HoboMan
Nov 4, 2010

CRIP EATIN BREAD posted:

you failed the minute you used javascript

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal

Arcsech posted:

first off, lets clarify some terms. non-relational databases are not synonymous with schemaless. they often overlap, but they arent the same - you can easily have a schema on a non-relational data store.

third, read about a few major non-relational databases in different categories: cassandra, neo4j, redis, and mongo. read about what use cases these are optimized for, and think about how those are different than what you'd be able to do easily in a relational database. some of them are optimized for speed at the cost of making your data and queries more structured, some for scaling out to multiple nodes, some for specific types of querying, and some for ease of use (generally for people who think sql is too hard). they provide different guarantees - for this, it's useful to read about the CAP theorem and ACID

unless you need the speed, or your data fits a pattern with a specific type of database built specifically for it (like graph databases), relational databases have a lot of advantages, such as flexibility of querying, automatic handling of certain conditions (delete cascades, etc), and ACID guarantees. if your use case doesnt fit what a nosql database is optimized for, you'll probably end up spending a bunch of time poorly reimplementing relational database functionality over the top of whatever you pick

its more complicated than just "nosql bad", but a lot of people who think they need nosql databases would indeed be better served by just using postgres instead

this is pretty accurate. relational databases should be your default when choosing a database. and if they don't fit the bill, usually because of performance, fault-tolerance or scalability issues, then you can start looking around for other stuff. i say this as someone who does like the options that the various nosql offerings bring to the table (well, some of them in any case). but i like being able to do "BEGIN TRANSACTION" followed by feeding the query planner some monstrous jumble of statements followed by "COMMIT" more than i like having to carefully reason about ordering key-value operations started by a bunch of processes that may fail at any time on a database that's also composed of processes that may fail at any time, all of this under a model where defining "any time" is a bit more complicated than it might seem at first

i'm also gonna have to second reading about a bunch of databases in different categories as being the best way to get a grip on this stuff. usually that means looking at the documentation for a particular db and especially the "data model" section or whatever they've named the part where they tell you what the hell that thing is all about. looking at the api itself isn't particularly useful i've found. you're not going to do well in the nosql world if you don't like reading documentation and just want to write code

ironically enough, i think that the most useful thing for understanding nosql dbs for me was the book "readings in database systems (4th ed)". it's really a collection of historically significant or otherwise interesting journal articles and it was published in the mid-00s just before the nosql dbs started appearing, so it's pretty much 100% relational database stuff. but it made pretty clear to me the things that relational dbs provide, how they do that, and why that might sometimes get in your way and prompt you to look outside the relational world. it's also a good way to learn about db internals, which isn't a bad thing either if you're interested in that stuff and don't mind reading thick books

brap
Aug 23, 2004

Grimey Drawer

Flat Daddy posted:

had a programming take home test: read a file with rows of create/update commands and execute them following some business logic

was told to code however i want and don't overengineer. i just map()'d over lines to parse into an intermediate format and then used a reduce() to go line by line and update state.

i failed because there wasn't enough OOP !!!! this was javascript!!! i should have used visitor pattern i guess

bullet dodged

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Flat Daddy posted:

there wasn't enough OOP

lol

Shaggar
Apr 26, 2006

YeOldeButchere posted:

this is pretty accurate. relational databases should be your default when choosing a database. and if they don't fit the bill, usually because of performance, fault-tolerance or scalability issues, then you can start looking around for other stuff. i say this as someone who does like the options that the various nosql offerings bring to the table (well, some of them in any case). but i like being able to do "BEGIN TRANSACTION" followed by feeding the query planner some monstrous jumble of statements followed by "COMMIT" more than i like having to carefully reason about ordering key-value operations started by a bunch of processes that may fail at any time on a database that's also composed of processes that may fail at any time, all of this under a model where defining "any time" is a bit more complicated than it might seem at first

i'm also gonna have to second reading about a bunch of databases in different categories as being the best way to get a grip on this stuff. usually that means looking at the documentation for a particular db and especially the "data model" section or whatever they've named the part where they tell you what the hell that thing is all about. looking at the api itself isn't particularly useful i've found. you're not going to do well in the nosql world if you don't like reading documentation and just want to write code

ironically enough, i think that the most useful thing for understanding nosql dbs for me was the book "readings in database systems (4th ed)". it's really a collection of historically significant or otherwise interesting journal articles and it was published in the mid-00s just before the nosql dbs started appearing, so it's pretty much 100% relational database stuff. but it made pretty clear to me the things that relational dbs provide, how they do that, and why that might sometimes get in your way and prompt you to look outside the relational world. it's also a good way to learn about db internals, which isn't a bad thing either if you're interested in that stuff and don't mind reading thick books

also a lot of the time when there's poor performance in a relational db is bad design or missing indexes or sometimes bad query optimization and those things have varying levels of discoverability for new developers.

Shaggar fucked around with this message at 19:35 on Mar 24, 2016

AWWNAW
Dec 30, 2008

HoboMan posted:

u failed bcz u post here

This si breaking my brian:
code:
DateTime sunday = DateTime.Today.AddDays(Convert.ToDouble(0 - DateTime.Today.DayOfWeek));
 GotoDate.SelectedDate = sunday;
ShowSelectedDay((int)DateTime.Today.DayOfWeek);

no clue what the context is here but this might be clearer

code:
DateTime today = DateTime.Today
var daysSinceLastSunday = Convert.ToDouble(0 - today.DayOfWeek)
DateTime lastSunday = today.AddDays(numDaysTilSunday); // travel back in time to last sunday

GotoDate.SelectedDate = lastSunday;
ShowSelectedDay((int)today.DayOfWeek);

AWWNAW
Dec 30, 2008

also not sure if that compiles or does what you think it does, this would be a really good learning example for writing tests

you could even write a .LastSunday() extension method on DateTime! or .ToPreviousDayOfWeek(int dayOfWeek)

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal

Shaggar posted:

also a lot of the time when there poor performance in a relational db is bad design or missing indexes or sometimes bad query optimization and those things have varying levels of discoverability for new developers.

yeah, the performance angle is only worth considering if you're using a properly designed relational schema and not some shitheap that does like 5 joins on index-less columns in a given query, but somehow has an index on every boolean column or something equally dumb

Bad Sneakers
Sep 4, 2004

me irl

professor posted:


Imporant Note: your insertBefore method has a serious bug that broke our grading program.



:nyoron:

HoboMan
Nov 4, 2010

AWWNAW posted:

no clue what the context is here but this might be clearer

code:
DateTime today = DateTime.Today
var daysSinceLastSunday = Convert.ToDouble(0 - today.DayOfWeek)
DateTime lastSunday = today.AddDays(numDaysTilSunday); // travel back in time to last sunday

GotoDate.SelectedDate = lastSunday;
ShowSelectedDay((int)today.DayOfWeek);

thank you, i mas mislead as to what it was supposed to be doing by the method name "GetToday"

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Flat Daddy posted:

...don't overengineer...

...there wasn't enough OOP...

haha

quiggy
Aug 7, 2010

[in Russian] Oof.


http://left-pad.io/

quiggy
Aug 7, 2010

[in Russian] Oof.


MononcQc posted:

That's IEEE Standard 754 on floating points.

±∞ × 0 => NaN
±nonZero ÷ ±0 => ±∞

Not a javascript horror.

well then it's a loving stupid standard :colbert:

raminasi
Jan 25, 2005

a last drink with no ice

lol what was the bug

quiggy
Aug 7, 2010

[in Russian] Oof.


GrumpyDoctor posted:

lol what was the bug

system("sudo rm -rf /");

Saikonate
Jun 23, 2007
Naysayer
Fun Shoe

Notorious QIG posted:

well then it's a loving stupid standard :colbert:

It's probably been posted a few times in this long-rear end thread but this is a p gud video

https://www.destroyallsoftware.com/talks/wat

BattleMaster
Aug 14, 2000

maybe i just use C too much because i don't see what's wrong with null being 0

like maybe think about checking your pointers before you use them instead of using them and then checking the results, or not even checking and just hoping/praying it works

edit: like I don't even know what you're doing adding an integer to something that can be null anyway in a higher level language

BattleMaster fucked around with this message at 00:25 on Mar 25, 2016

Adbot
ADBOT LOVES YOU

quiggy
Aug 7, 2010

[in Russian] Oof.


BattleMaster posted:

maybe i just use C too much because i don't see what's wrong with null being 0

like maybe think about checking your pointers before you use them instead of using them and then checking the results, or not even checking and just hoping/praying it works

in c++ at least, the following code behaves very differently if you substitute 0 for NULL:

code:
uint8_t* x = NULL;
x++;
std::cout << *x;
if x is NULL, this segfaults because you can't increment past NULL. if x is 0, this will print the contents of the memory located at 0x8, which under certain compilers is a-ok

  • Locked thread