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
Ochowie
Nov 9, 2007

ExcessBLarg! posted:

If you can't think of a better way to differentiate the name of an interface and an implementing class other than "IFoo" or "FooImpl" or "MyFoo" (my favorite) then maybe you just need a class.

Can you mock a concrete class in all of the commonly used mocking frameworks?

Adbot
ADBOT LOVES YOU

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Well that's what they're for, right!

Except static classes, those can be a problem but if you're doing DI you shouldn't be using them anyway

Ochowie
Nov 9, 2007

baka kaba posted:

Well that's what they're for, right!

Except static classes, those can be a problem but if you're doing DI you shouldn't be using them anyway

I'm not sure if you're replying to my post, but after some brief searching, it seems like you can only mock virtual methods (at least for most of the .NET mocking frameworks).

john donne
Apr 10, 2016

All suitors of all sorts themselves enthral;

So on his back lies this whale wantoning,

And in his gulf-like throat, sucks everything

That passeth near.
Telerik's JustMock can mock static classes. But typically you mock a class when it represents some external dependency, and those really shouldn't be static classes.

Absurd Alhazred
Mar 27, 2010

by Athanatos

ExcessBLarg! posted:

If you can't think of a better way to differentiate the name of an interface and an implementing class other than "IFoo" or "FooImpl" or "MyFoo" (my favorite) then maybe you just need a class.

Embarrassingly, I just did this today. I created an interface and a dummy class when what I actually end up using is simply a partially-implemented class.

Sedro
Dec 31, 2008

ExcessBLarg! posted:

If you can't think of a better way to differentiate the name of an interface and an implementing class other than "IFoo" or "FooImpl" or "MyFoo" (my favorite) then maybe you just need a class.

Is it wrong that I don't mind this? You can describe which APIs are intentionally public by adding them to the interface, and not worry about public/private modifiers in the implementation. You can view the public APIs without scrolling through pages of implementation. You can comment the hell out of the interface and keep the clutter out of the implementation. Plus, you can easily mock the interface.

Xerophyte
Mar 17, 2008

This space intentionally left blank

Sedro posted:

Is it wrong that I don't mind this? You can describe which APIs are intentionally public by adding them to the interface, and not worry about public/private modifiers in the implementation. You can view the public APIs without scrolling through pages of implementation. You can comment the hell out of the interface and keep the clutter out of the implementation. Plus, you can easily mock the interface.

In C++-land there are also perfectly reasonable motivations behind "Impl" classes. Not having any private members and other implementation details in the public class header means that the user-facing class ABI won't change when you change the private details of the implementation, which helps with both compile times and compatibility. This is of course mostly the case because C++'s compilation model is a barely functioning dinosaur kludge, but still.

boo_radley
Dec 30, 2005

Politeness costs nothing
Microsoft's really doubling down on this active event thing.


I read through the article again and it seems like a squinty version of dispatch tables or strategy patterns? But with less coherency?

Also, this dude is pretty loving insane.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

boo_radley posted:

Microsoft's really doubling down on this active event thing.


I read through the article again and it seems like a squinty version of dispatch tables or strategy patterns? But with less coherency?

Also, this dude is pretty loving insane.

Active events is essentially the "stringly typed" anti-pattern rebadged as an actual design pattern (see StringlyTyped).

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I am not terribly familiar with EF, but I thought it did something similar with mapping dynamic objects. I don't know if any of the people at MS or that thread have ever heard the terms 'dynamic linq', or if I'm just misunderstanding something in his 'disrupt oop' speech.

Or have ever used python, or js, or google analytics ......

ExcessBLarg!
Sep 1, 2001

Sedro posted:

Is it wrong that I don't mind this?
If it's part of your style guide and consistently followed, and/or otherwise a requirement due to (often a deficiency in) your language or framework, then sure.

Personally I don't like unnecessary duplication of information, and it's nice to keep all the details of a class in one place.

Eela6
May 25, 2007
Shredded Hen

boo_radley posted:

Microsoft's really doubling down on this active event thing.


I read through the article again and it seems like a squinty version of dispatch tables or strategy patterns? But with less coherency?

Also, this dude is pretty loving insane.

It's like Javascript, but on purpose!

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

boo_radley posted:

Microsoft's really doubling down on this active event thing.


I read through the article again and it seems like a squinty version of dispatch tables or strategy patterns? But with less coherency?

Also, this dude is pretty loving insane.

This just has to be prep for April Fool's, right? ...right guys? .. ... .. right.?

:qq:

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

RandomBlue posted:

This just has to be prep for April Fool's, right? ...right guys? .. ... .. right.?

:qq:

Search your heart; it already knows the answer.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
Working my first job in webdev and I wonder... is all webdev held together by spit, duct tape and sticks?

fishmech
Jul 16, 2006

by VideoGames
Salad Prong

Joda posted:

Working my first job in webdev and I wonder... is all webdev held together by spit, duct tape and sticks?

No: some is held together by even less!

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Joda posted:

Working my first job in webdev and I wonder... is all webdev held together by spit, duct tape and sticks?

If I've learned anything in consulting for fortune 500 companies, banks, and insurance companies for the past few years, it's this:

EVERYTHING is held together by spit, duct tape, and sticks. You know what company's codebase is rife with SQL injection vulnerabilities? All of them.

Mr Shiny Pants
Nov 12, 2012

New Yorp New Yorp posted:

If I've learned anything in consulting for fortune 500 companies, banks, and insurance companies for the past few years, it's this:

EVERYTHING is held together by spit, duct tape, and sticks. You know what company's codebase is rife with SQL injection vulnerabilities? All of them.

This.

I've come around from "well they probably would have their stuff together" to "what are they not telling.....".

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

Joda posted:

Working my first job in webdev and I wonder... is all webdev held together by spit, duct tape and sticks?

What New Yorp is saying is no doubt true, but there's no denying webdev has historically been particularly bad, probably because of the lower barriers to entry, how easy it is to slap together something that mostly works, and the dynamic nature of the languages and technologies involved.

Modern web frameworks should theoretically help matters. At least modern web apps aren't as tightly coupled to their backends as they used to be since people are now more used to creating decoupled APIs that the frontend consumes the same way a third party client would. But in practice I think the frameworks often lead to even more cargo cult programming than before, because the complexity of creating a website goes up massively once you start using something like Angular.

So yes.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.
This is why I laugh whenever someone talks about being up to par with "production code".


I've seen the code in production. :psypop:

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

LOOK I AM A TURTLE posted:

What New Yorp is saying is no doubt true, but there's no denying webdev has historically been particularly bad, probably because of the lower barriers to entry, how easy it is to slap together something that mostly works, and the dynamic nature of the languages and technologies involved.

Don't forget the platforms being historically garbage. Needing, effectively, three different versions of your website, or just flat-out saying "this website is not compatible with $browser", used to be super-common. Hell, it may still be common in some limited capacity, but not to the scale I remember it being like back in the mid-2000s.

Volguus
Mar 3, 2009

TooMuchAbstraction posted:

Don't forget the platforms being historically garbage. Needing, effectively, three different versions of your website, or just flat-out saying "this website is not compatible with $browser", used to be super-common. Hell, it may still be common in some limited capacity, but not to the scale I remember it being like back in the mid-2000s.

Now, instead of Netscape or IE is Chrome. There are way too many websites out there that only work on chrome, using some non-standard feature of the browser. It's back to where we started, just different actors.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.
Duck typing ownsge: all types are implicitly interfaces


Hell yeah

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

TooMuchAbstraction posted:

Don't forget the platforms being historically garbage. Needing, effectively, three different versions of your website, or just flat-out saying "this website is not compatible with $browser", used to be super-common. Hell, it may still be common in some limited capacity, but not to the scale I remember it being like back in the mid-2000s.
We just moved that problem to the mobile landscape, where the diversity of browsers and resolutions still forces you to have a bunch of versions and hacks to cover all the corner cases. Responsive is an illusion.

Volguus posted:

Now, instead of Netscape or IE is Chrome. There are way too many websites out there that only work on chrome, using some non-standard feature of the browser. It's back to where we started, just different actors.
And IE is not out of the game yet. Now that it's effectively frozen, legacy users are clinging desperately to it as it's the only browser left that will support their precious plugin and ActiveX horrors.

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop

LOOK I AM A TURTLE posted:

What New Yorp is saying is no doubt true, but there's no denying webdev has historically been particularly bad, probably because of the lower barriers to entry, how easy it is to slap together something that mostly works, and the dynamic nature of the languages and technologies involved.

I think it's made worse by the literal children guiding webdev throwing tantrums every time an adult asks them to maybe please look at decades of learned lessons and not insist on loving up everything the same way.

See, for example, how hilariously stupid NPM is and how the entire concept is incompatible with mediocre-practice, much less best practice. We've got another month or so before some other tiny package that's used by literally everything in the javascript space gets broken/removed/rage-deleted and it shuts down half the fortune 500 companies because "deploy" means "download random poo poo from websites to production servers and hope it all makes it OK."

Are we even to the point where it's random signed poo poo yet? Because for a while it was "download random unsigned poo poo from non-ssl webservers" and that's what processes the form you type your credit card into. Of course it hasn't. You can pin by shasum but no guarantee that the hash that NPM came up with is the same as the file uploaded by the author

Tactical Shitpost
Jun 13, 2016
Speaking of which, I'd like to nominate the situation with AngularJS releases, compatibility breaks every 2-3 months and the policy of 6 months of support after release to a proper dumpster fire rank. I am so, so glad dodged that bullet by picking KnockoutJS instead.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Volguus posted:

Now, instead of Netscape or IE is Chrome. There are way too many websites out there that only work on chrome, using some non-standard feature of the browser. It's back to where we started, just different actors.

This is infuriating. You know who doesn't use Chrome? The majority of users on the web, that's who.

ullerrm
Dec 31, 2012

Oh, the network slogan is true -- "watch FOX and be damned for all eternity!"

Joda posted:

Working my first job in webdev and I wonder... is all webdev held together by spit, duct tape and sticks?

Ooh, look at this fancy lord with his duct tape and sticks!

(A lot of it is, yes, if not worse. It makes you appreciate a good dev house all that much more.)

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
It's not so much duct tape and sticks but more like various paper kites carefully floating due to the heat generated by a dumpster fire.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



my code is a jenga tower of turds

Dylan16807
May 12, 2010

Harik posted:

Are we even to the point where it's random signed poo poo yet? Because for a while it was "download random unsigned poo poo from non-ssl webservers" and that's what processes the form you type your credit card into. Of course it hasn't. You can pin by shasum but no guarantee that the hash that NPM came up with is the same as the file uploaded by the author

Pinning to hash should be just as secure as a signature, albeit less flexible. Signatures don't get applied to entire files; they hash internally.

Upgrading the hash is a separate issue.

Unless it doesn't verify the hash or something?

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Dylan16807 posted:

Unless it doesn't verify the hash or something?

I have a guess on that ...

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
the real coding horrors are the people who use npm without a proxy/replicated feed

Ghost of Reagan Past
Oct 7, 2003

rock and roll fun

Joda posted:

Working my first job in webdev and I wonder... is all webdev held together by spit, duct tape and sticks?
Someone once thought it was a good idea to have a Django model with only three fields: a foreign key (not implemented with Django's built in foreign key logic), a character field (there's also a model for this, naturally), and a date time.

Many times, you need to look at this and get the model the character field is attached to, so what you do is use the bespoke foreign key to get an object (this isn't the primary key of the object we're getting, of course), get a foreign key from THAT, then run a query on a third object with the word and the bespoke foreign key.

This runs hundreds of thousands of times a day.

Hughlander
May 11, 2005

Dylan16807 posted:

Pinning to hash should be just as secure as a signature, albeit less flexible. Signatures don't get applied to entire files; they hash internally.

Upgrading the hash is a separate issue.

Unless it doesn't verify the hash or something?

How do you know that the hash you're looking at is legitimate?

fishmech
Jul 16, 2006

by VideoGames
Salad Prong

Simulated posted:

This is infuriating. You know who doesn't use Chrome? The majority of users on the web, that's who.

That's not really true anymore:



I'm just using NetMarketShare because they have the nicest graphs without paying, but other market share tracking sites show the same thing - Chrome edging to a narrow majority in both normal and mobile browser share, as the primary beneficiary of the final collapse of IE on desktop/laptop and the ever shrinking popularity of iOS in mobile (particularly tablets, where iOS share has dropped significantly at the same time the tablet market's shrunk for 2 years straight).

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

fishmech posted:

That's not really true anymore:

I'm just using NetMarketShare because they have the nicest graphs without paying, but other market share tracking sites show the same thing - Chrome edging to a narrow majority in both normal and mobile browser share, as the primary beneficiary of the final collapse of IE on desktop/laptop and the ever shrinking popularity of iOS in mobile (particularly tablets, where iOS share has dropped significantly at the same time the tablet market's shrunk for 2 years straight).

That still doesn't make it OK.

curufinor
Apr 4, 2016

by Smythe

Harik posted:

I think it's made worse by the literal children guiding webdev throwing tantrums every time an adult asks them to maybe please look at decades of learned lessons and not insist on loving up everything the same way.

See, for example, how hilariously stupid NPM is and how the entire concept is incompatible with mediocre-practice, much less best practice. We've got another month or so before some other tiny package that's used by literally everything in the javascript space gets broken/removed/rage-deleted and it shuts down half the fortune 500 companies because "deploy" means "download random poo poo from websites to production servers and hope it all makes it OK."

Are we even to the point where it's random signed poo poo yet? Because for a while it was "download random unsigned poo poo from non-ssl webservers" and that's what processes the form you type your credit card into. Of course it hasn't. You can pin by shasum but no guarantee that the hash that NPM came up with is the same as the file uploaded by the author

So I used to work for this autocomplete company, called constructor.io. If you go to npmjs.com and type some poo poo in the autocomplete in the searchbar, you'll see "powered by constructor.io" right there in the lower right corner. I styled that thingy and did some weirdo poo poo with the integration, and talked a bit to some npm folks during that.

While talking, I learned that NPM Incorporated
1. Is for-profit
2. Took VC money

That tells you p. much what you need to know.
Their crunchbase: https://www.crunchbase.com/organization/npm#/entity

Dylan16807
May 12, 2010

Hughlander posted:

How do you know that the hash you're looking at is legitimate?

How do you know the signature you're looking at is legitimate?

Using http is stupid of course, and signatures are nicer than version pinning, but if you decide you like a version then a hash should be at least functional.

Adbot
ADBOT LOVES YOU

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

Volguus posted:

Now, instead of Netscape or IE is Chrome. There are way too many websites out there that only work on chrome, using some non-standard feature of the browser. It's back to where we started, just different actors.

The only browser that I've seen having compatibility issues are still IE and Edge, more Edge than IE10/11 now. You almost have to go out of your way to write stuff that doesn't work on Chrome, FF and Safari now.

Here's a fun .NET issues I ran into recently, find the WTF?, it's pretty easy to spot. Not sure if this is just another .Net Core issue or if older framworks had this problem too.

Path.Combine("C:\Some\SafeDir\", "test.txt") == C:\Some\SafeDir\test.txt
Path.Combine("C:\Some\SafeDir\", "anotherDir", "test.txt") == C:\Some\SafeDir\anotherDir\test.txt
Path.Combine("C:\Some\SafeDir\", "C:\Windows") == C:\Windows
Path.Combine("C:\Some\SafeDir\", "/Windows") == C:\Windows

Thanks assholes. The documentation even says if param2 starts with a root path param2 is what is returned, peroid. Someone actually made the design choice that this behavior was good and perfectly fine.

Looks like it's actually been this way a long long time, since .Net 1.1: https://msdn.microsoft.com/en-us/library/fyy7a5kt(v=vs.71).aspx

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