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
Skandranon
Sep 6, 2008
fucking stupid, dont listen to me
I agree, don't send back URLs. You should have a well defined data layer which handles creating routes, so if you are going to fetch spouse #3, you call data.getSpouse(3). Blindly fetching URLs told to you by a backend service sounds like a disaster waiting to happen.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Roy Fielding, the inventor of REST API's would disagree. So would Martin Fowler.

keyword: HATEOAS


(that being said, I'm lazy and rarely developing something that anyone will care about in a couple years so I usually just send back IDs)

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Thermopyle posted:

Roy Fielding, the inventor of REST API's would disagree. So would Martin Fowler.

keyword: HATEOAS


(that being said, I'm lazy and rarely developing something that anyone will care about in a couple years so I usually just send back IDs)

RESTish? I've never thought of REST being a concrete set of rules, but general guidelines that are flexible to what you need.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Thermopyle posted:

Roy Fielding, the inventor of REST API's would disagree. So would Martin Fowler.

keyword: HATEOAS


(that being said, I'm lazy and rarely developing something that anyone will care about in a couple years so I usually just send back IDs)

If you only send back IDs and something changes, every client must re-write code. If you send a URL, you don't. There is no reason you can't also send a list of IDs.... but then you probably aren't by the book REST.

That said, when I write an API, I too am lazy and only send IDs. :v:

Tei
Feb 19, 2011

I don't have a strong opinion one way or another. I guest the numbered list is easier to parse [1,54,2,7,5].

Simple is better than complex.

It probably matter has much than this "decision" how well documented is and that is consistent to how the same api do things in other areas.

ROFLburger
Jan 12, 2006

Lumpy posted:

If you only send back IDs and something changes, every client must re-write code

Could you elaborate on this?

ddiddles
Oct 21, 2008

Roses are red, violets are blue, I'm a schizophrenic and so am I
You'd have to rewrite any API call if the URL changes to account for it.

Unless you keep all that info in a constants file and import them into any API call, then it would only require a change in one place.

Space Kablooey
May 6, 2009


ROFLburger posted:

Could you elaborate on this?

If one of your endpoints is, say, https://api.butts.com/butts/1/farts/, if you want to change to https://api.butts.com/api/v1/butts/1/farts/ or anything else then you will have to update all the clients to add the /api/v1/ bit. And there's the problem that not all clients for your API will be under your control to change that constant.

If you were sending the URLs in the responses then the work just needs to be done server side.

Space Kablooey fucked around with this message at 19:51 on May 18, 2017

Tei
Feb 19, 2011

I don't know why anybody would want to send the whole url. But I guest theres a strategy to it. Maybe is to make some sort of sacrifice to autodocumentation? [1,3,4,5] seems simple enough for me.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

ROFLburger posted:

Could you elaborate on this?

Why yes, I'd love to:

HardDiskD posted:

If one of your endpoints is, say, https://api.butts.com/butts/1/farts/, if you want to change to https://api.butts.com/api/v1/butts/1/farts/ or anything else then you will have to update all the clients to add the /api/v1/ bit. And there's the problem that not all clients for your API will be under your control to change that constant.

If you were sending the URLs in the responses then the work just needs to be done server side.

:v:

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Tei posted:

I don't know why anybody would want to send the whole url.

I just linked the page you should read about the subject.

Space Kablooey
May 6, 2009


Lumpy posted:

Why yes, I'd love to:


:v:

Which can be summarized as

Lumpy posted:

If you only send back IDs and something changes, every client must re-write code. If you send a URL, you don't.


:v:

kedo
Nov 27, 2007

Why not provide both? Disclaimer: I have never written an API but interact with them a whole lot.

Space Kablooey
May 6, 2009


kedo posted:

Why not provide both? Disclaimer: I have never written an API but interact with them a whole lot.

You could, but the question is why would you?

Tei
Feb 19, 2011

Man, there are so many people on software that want to make things complex.

I like simple things.

They themselves grown to complex, but then are still manageable. But if you start complex, then what?

Space Kablooey
May 6, 2009


Returning URLs should not be any more complex than returning a list of ids, with the trade off that clients are simpler to build (they only parse the relevant fields and make the requests). Conversely, returning a list of ids is also simple, but now the clients have to, in addition to parsing the fields, manage the endpoint URLs and also build them before making the requests.

ROFLburger
Jan 12, 2006

Something I don't like about returning URLs is that you lose some flexibility. What if I want to use the children to act on some other resource using each child's ID? I need to either parse the URL and try to extract the ID, or I have resolve each URL individually

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



ROFLburger posted:

Something I don't like about returning URLs is that you lose some flexibility. What if I want to use the children to act on some other resource using each child's ID? I need to either parse the URL and try to extract the ID, or I have resolve each URL individually

Maybe I'll be a nice API implementer and accept URLs as child IDs. Hell, maybe that'll be all it accepts as a child ID.

kedo
Nov 27, 2007

HardDiskD posted:

You could, but the question is why would you?

I can see arguments for doing it either way, tbh.

As someone using the API, I want to make sure my code isn't going to break because someone decided to update the API. Therefore maybe URLs are better because if they're updated to use a different format my code will keep working and I won't even notice.

Then again, if I have a lot of different ways to run queries against the API and the URL isn't going to be stable, I'd rather have the ID. That way I can keep the URL as a variable in my code and update it as needed as the URL changes.

So why not provide both? I mean... if I'm getting an object from an API I expect to get an ID by default. I might also expect to get URL-like things (permalinks? aliases?). Neither of them seem out of the ordinary. I realize using both bloats things a little bit, but it doesn't seem like it'd bloat things too much.

Anywho, did I mention I know nothing about writing APIs? :P

kedo fucked around with this message at 23:21 on May 18, 2017

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

When I normalize incoming data i parse out the ids and keep both the url and the id for later use.

Space Kablooey
May 6, 2009


TBF the REST API I'm implementing is a small personal project. It's not exactly a toy project but it's not what I would call big in any way. I've used APIs that returned ids and they were fine, and I dabbled in a few APIs that returned URLs, namely Facebook's and Youtube's, and they were fine as well. The arguments that I've seen for using URLs sounded good to me, and the little practice I'm having while implementing URLs APIs made them feel better than the alternative already. Even then I can't really talk about their pros and cons too much because I'm still learning what makes them tick.

Having said that, I think returning both ids and URLs is mistake, but I can't really articulate why beyond that I feel it's just redundant info. In addition to that, I also think that if the API returns URLs and a client still needs to parse the URLs then something has gone terribly wrong in the API architecture.

ModeSix
Mar 14, 2009

I've recently been getting into React and React-Native and was wondering if anyone could share some good guides/tutorials for it.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
Create-react-app, the lynda.com tutorial, and the codeacademy courses are the go-to things i recommend.

Oh and obviously the documentation

Dominoes
Sep 20, 2007

I had an easier time learning by focusing on functional components, with state existing at a high level. Ie keep your state outside the components, (You could start with a global object or Map, or dive right into something like Redux) pass it to a top-level component, then pass what you need to sub-components as props.

EatinCake
Oct 21, 2008
This is driving me crazy, maybe someone here can help.

I've got a site that displays a the site font smaller Google Chrome browser than anywhere else. When I push the code up to Github or look at my localhost in Firefox, Safari, everything's fine. For that reason I don't think the problem is my code per say but some Chrome feature that's misbehaving... but only for my local run of it. I'm not seeing this issue with any other site, and yes, I'm viewing the tab in Actual Size.

I'm wondering if anyone has seen this sorta thing before and can point that it's either:

- A special setting of Chrome that handles rem values differently... but only for locally run code,

- Does localhost default to using local fonts now for some reason? Maybe there's differences in the google font vs. local one.

Love Stole the Day
Nov 4, 2012
Please give me free quality professional advice so I can be a baby about it and insult you
Question for you guys: In the game makin' world, they have these game jam things for people like me who aren't good enough to make something completely on their own yet or for people who want to be in groups to help motivate them to finish a thing. Is there anything like that which I could get in on? Sort of like a web jam or whatever? Because there isn't exactly a place for people to come together and work on stuff in groups and get experience under their belts afaik.

kedo
Nov 27, 2007

I've heard of a few before, though they tend to be web-app oriented as opposed to traditional websites. I have a buddy who does them all the time, I'll ask for some recommendations.

The buddy in question is a design/ux guy with antiquated coding chops, so I think there's a place for all skill sets/levels.

Snak
Oct 10, 2005

I myself will carry you to the Gates of Valhalla...
You will ride eternal,
shiny and chrome.
Grimey Drawer
it's also not too difficult or expensive to just try building your own website using something like amazon web services or some other web host. Like, sure, it will cost you a little bit, but if you're serious about learning, it's not a large expense.

EatinCake
Oct 21, 2008
No one answered my Q here, but it was definitely Chrome loading my local version of the font instead of the one from Google Fonts.

I ended up fixing it by just loading the font locally on the site via a .Woff intsead. Unsure if that's gonna punish the load time at all, but I haven't found a browser it differs in yet, so *yay*.

Tei
Feb 19, 2011

EatinCake posted:

No one answered my Q here, but it was definitely Chrome loading my local version of the font instead of the one from Google Fonts.

I ended up fixing it by just loading the font locally on the site via a .Woff intsead. Unsure if that's gonna punish the load time at all, but I haven't found a browser it differs in yet, so *yay*.

I am not a expert but...

Not using a CDN adds a linear time to load resource. So if your website is in usa, in europe the load time per resource can be 200 ms/slower. In asia it can be 500 ms slower (numbers pulled from my rear end). CDN makes sense if you want your website to feel snappy and have users around the world. But if your resource is usa only or something like that, I don't think you "need" a cdn.

Of course, maybe cdn's help with load if your website show in the news, and you have a spike of 3000 visitors in 20 minutes so more people load something, instead of a timeout error.

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
Use a CDN with a local fallback - best of both worlds.

denzelcurrypower
Jan 28, 2011
I'm looking to create a RESTful API, which will allow me to login users using their LinkedIn and Facebook profiles. It looks like I will need to implement OAuth2 authentication. My goal is to consume this API as the back-end for C# Web MVC projects as well as mobile development projects. Any suggestions as far as a language to use and/or useful guides or tutorials to follow? I thought Java might be a good choice so that it will integrate easily with Android projects, but then I realized that my web host can't run Java. Maybe C# is the way to go and host the API on Microsoft Azure? Then I can use the API for Xamarin apps and ASP.NET MVC? Any suggestions are welcome, I am a beginner as far as developing my own APIs. I've created basic SOAP services with Java as well as WCF with C# in the past, but I'm not sure the best technologies to achieve my goal for this project.

denzelcurrypower fucked around with this message at 16:40 on May 23, 2017

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Ornithology posted:

I'm looking to create a RESTful API, which will allow me to login users using their LinkedIn and Facebook profiles. It looks like I will need to implement OAuth2 authentication. My goal is to consume this API as the back-end for C# Web MVC projects as well as mobile development projects. Any suggestions as far as a language to use and/or useful guides or tutorials to follow? I thought Java might be a good choice so that it will integrate easily with Android projects, but then I realized that my web host can't run Java. Maybe C# is the way to go and host the API on Microsoft Azure? Then I can use the API for Xamarin apps and ASP.NET MVC? Any suggestions are welcome, I am a beginner as far as developing my own APIs. I've created basic SOAP services with Java as well as WCF with C# in the past, but I'm not sure the best technologies to achieve my goal for this project.

Microsoft already did all of the hard work for you and you can basically get OAuth2 working with Facebook, Google, Twitter and Microsoft by editing credentials for each service into a file in a project template: https://docs.microsoft.com/en-us/aspnet/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

I did that for a toy project last year and the hardest part was getting all of the 3rd party credentials set up.

denzelcurrypower
Jan 28, 2011

Munkeymon posted:

Microsoft already did all of the hard work for you and you can basically get OAuth2 working with Facebook, Google, Twitter and Microsoft by editing credentials for each service into a file in a project template: https://docs.microsoft.com/en-us/aspnet/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

I did that for a toy project last year and the hardest part was getting all of the 3rd party credentials set up.

Is that for hosting a web service though? It seems like it's just for setting up a web application, but I'm looking for a tutorial which integrates this authentication into a RESTful API service. Forgive me if it's a foolish question, I'm new to the topic.

e: I think this link describes what I need, can anyone comment if it looks like it will serve my purpose? https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/individual-accounts-in-web-api

denzelcurrypower fucked around with this message at 20:44 on May 23, 2017

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
Does anyone know the name(s) of some of the nice, big, free icon sets that currently exist? I'm specifically for a set of icons that indicate counting on one's fingers (ie, icons with 0, 1, 2, 3, 4, and 5 fingers up), ideally in a scalable format. Better yet would be an animation of the fingers being raised, but that's less likely to be kicking around somewhere.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Ornithology posted:

Is that for hosting a web service though? It seems like it's just for setting up a web application, but I'm looking for a tutorial which integrates this authentication into a RESTful API service. Forgive me if it's a foolish question, I'm new to the topic.

e: I think this link describes what I need, can anyone comment if it looks like it will serve my purpose? https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/individual-accounts-in-web-api

Yeah, that's a guide to how ASP.NET's Identity features work over a RESTful service. The one I linked to was more of a setup guide.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Newf posted:

Does anyone know the name(s) of some of the nice, big, free icon sets that currently exist? I'm specifically for a set of icons that indicate counting on one's fingers (ie, icons with 0, 1, 2, 3, 4, and 5 fingers up), ideally in a scalable format. Better yet would be an animation of the fingers being raised, but that's less likely to be kicking around somewhere.

This one is huge, but according to wikipedia it has all the ASL icons in it, so that might include counting:
https://sourceforge.net/projects/openiconlibrary/

denzelcurrypower
Jan 28, 2011

Munkeymon posted:

Yeah, that's a guide to how ASP.NET's Identity features work over a RESTful service. The one I linked to was more of a setup guide.

The one you posted doesn't appear to be for a Restful service which is what I was looking for!

The one I posted has examples of regular authentication, but it doesn't show how to authenticate with third parties like Google or LinkedIn! Very irritating that the documentation does not cover the topics listed in the title/subtitle.

Sab669
Sep 24, 2009

I have limited Design knowledge and found myself working on some CSS-related issues on my web application when I came across a lot of syntax I've never seen in CSS before.

I looked it up and found they're called "At-rules". Seem pretty cool/powerful, but I'm a little confused on some stuff. For example, here's the @media at-rule.

It lists "-webkit-device-pixel-ratio" however my CSS file uses "-webkit-min-device-pixel-ratio".

So why/how does that work?

And furthermore, on that page below the list of Media Features they provide some examples, one of which is for the min device pixel ratio. But it's also colored in green on their example which typically implies a comment, although I'm going to assume it's just an issue with how they mark up code blocks.

Lastly, is there somewhere better than MDN for JavaScript and CSS APIs? Like I said I generally don't do much design work -- and while I do use JS plenty I don't often "do new things" that require much more of me than a cursory search of StackOverflow. Any time I do use their site I'm typically happy with the information but the CSS stuff seems to be lacking a lot of Browser Support/Compatibility information.

Sab669 fucked around with this message at 17:27 on May 25, 2017

Adbot
ADBOT LOVES YOU

Tei
Feb 19, 2011

[oh, you was asking something different. I misread]

Tei fucked around with this message at 13:38 on May 25, 2017

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