|
pseudorandom posted:Maybe I'm dumb and stupid, but I loving hate CORS so much. As far as I can tell, it is only good for awful legacy apps that accepted requests like `GET /delete-everything`. But, GOD FORBID anyone like me wants to implement a `DELETE` route or use a non-standard header, because now I need to manually whitelist poo poo and endure a preflight `OPTIONS` request before anything can happen. cors does protect against some very real issues but the design and usability could maybe use some work in my case tho cors was "protecting" requests for fonts, which apparently only require cors headers because some font authors were real upset about the possibility of people stealing their copyrighted works and were apparently oblivious to the idea of requests that don't enforce cors and/or rehosting font files elsewhere.
|
# ? May 2, 2019 05:37 |
|
|
# ? Jan 15, 2025 23:37 |
|
HoboMan posted:nginx: its a hard g hth
|
# ? May 2, 2019 05:53 |
|
HoboMan posted:nginx: for the longest time I read it as en-genics, like eugenics but with “en” instead of “eu” which I mean it’s a predominantly Linux thing, of course it would have a name like that
|
# ? May 2, 2019 06:02 |
|
florida lan posted:cors does protect against some very real issues but the design and usability could maybe use some work I don't understand why they didn't change cors to be part of the actual request in http2 or whatever. A separate request to ask if you're allowed a resource seems so dumb
|
# ? May 2, 2019 06:08 |
|
HoboMan posted:nginx: I'm pretty sure it's the "engine x" version, but drat you've got a good case for "once you see it you can't unsee it".
|
# ? May 2, 2019 06:10 |
Java question: I have a few large-ish functions, each of which I would like to call with two (possibly later more) different possible input types. The implementation of these functions would be largely the same when called with either input type, but there's just a small method or two in each function that would be different for each type. I know I could implement this roughly like this:Java code:
However, this feels pretty inelegant. For one thing, it doesn't scale well to more functions / more types. For another thing, it doesn't behave nicely if I pass it the wrong types: at best I can just make it fail at runtime. So what's the best strategy here? A little more info: while Foo and Bar both extend Baz, Baz as a whole is very broad and most of it's subclasses won't work with these methods. I do not directly control Foo and Bar, so I can't e.g. make them both implement an interface which does what I want.
|
|
# ? May 2, 2019 06:12 |
|
pseudorandom posted:I'm pretty sure it's the "engine x" version, but drat you've got a good case for "once you see it you can't unsee it". joking aside, its actually pronounced like the vietnamese name nguyen
|
# ? May 2, 2019 06:27 |
|
VikingofRock posted:Java question: I have a few large-ish functions, each of which I would like to call with two (possibly later more) different possible input types. The implementation of these functions would be largely the same when called with either input type, but there's just a small method or two in each function that would be different for each type. pass in the different methods as parameters
|
# ? May 2, 2019 06:29 |
|
VikingofRock posted:Java question: I have a few large-ish functions, each of which I would like to call with two (possibly later more) different possible input types. The implementation of these functions would be largely the same when called with either input type, but there's just a small method or two in each function that would be different for each type. I know I could implement this roughly like this: Does Java have Traits yet? Alternatively, I think C# had a way to define methods where `void exampleMethod(Foo someObj)` could be called like `myFoo.exampleMethod()`; though it's been a while since I've used it. Does Java have anything similar now where you could define methods for each class that don't require you to control their full implementation? If not, it might be hacky, but maybe make a wrapper class, or classes, that you pair with an interface.
|
# ? May 2, 2019 06:40 |
|
HoboMan posted:also in case anyone cares (i know you don't) the very helpful "cannot GET /" error i was getting was from angular silently failing to compile lmao
|
# ? May 2, 2019 06:43 |
|
VikingofRock posted:Java question: I have a few large-ish functions, each of which I would like to call with two (possibly later more) different possible input types. The implementation of these functions would be largely the same when called with either input type, but there's just a small method or two in each function that would be different for each type. I know I could implement this roughly like this: if you will only be calling it on objects whose precise type is known at the call site, then you can do Java code:
this has the additional advantage that you can’t call the method on a different type of Baz by accident however, this obviously won’t work if all you know at the call site is that you have a Baz. in that case you really do just have to grit your teeth and use instanceof
|
# ? May 2, 2019 08:27 |
|
Fun answer. Use reflection to workout what methods the object has and call one of them, all the downsides of using instanceof but even more inscrutable to debugging. The Consumer interface is probably the best answer, not used it yet myself, but seems the best fit. It's a tricky situation though where you want to work on Baz objects but Foo and Bar are so diverged from it that they don't share methods that do broadly the same thing.
|
# ? May 2, 2019 08:50 |
|
inheritance should only be used for polymorphism. if you're trying to use it in order to reuse code then you done hosed up. if you have code that is almost-but-not-quite polymorphic between foo and bar, and you really really do want to reuse your implementation, and you can't change foo and bar to make it completely polymorphic over a general interface? then write an adapter interface that covers the things your implementation needs, and a FooAdapter and BarAdapter that wrap a Foo/Bar and conform to that interface. your real implementation only accepts the adapter type. that way your code is truly polymorphic over the interface, and the only stuff specific to one particular implementation is the adapter that deals with that specific implementation. if you need to expand your implementation to cover more types later, just write another adapter.
|
# ? May 2, 2019 09:21 |
|
lol if you don't have a 20-deep inheritance tree stuffed full of 3000-line abstract classes
|
# ? May 2, 2019 12:49 |
|
Krankenstyle posted:joking aside, its actually pronounced like the vietnamese name nguyen nginxy face
|
# ? May 2, 2019 13:02 |
|
i have some c# code thats doing a lot of reflection to find everything that inherits this one base type, instantiate it, and stick it in a collection. i would like to do this without reflection, but i do not know how. like the least-worst idea i've come up with is to just do the reflection but at build-time to auto-generate out a thousand lines of constructors but that seems dumb. surely there is a better way
|
# ? May 2, 2019 14:50 |
|
Bloody posted:i have some c# code thats doing a lot of reflection to find everything that inherits this one base type, instantiate it, and stick it in a collection. i would like to do this without reflection, but i do not know how. like the least-worst idea i've come up with is to just do the reflection but at build-time to auto-generate out a thousand lines of constructors but that seems dumb. surely there is a better way [taps thread title]
|
# ? May 2, 2019 14:52 |
|
Bloody posted:i have some c# code thats doing a lot of reflection to find everything that inherits this one base type, instantiate it, and stick it in a collection. i would like to do this without reflection, but i do not know how. like the least-worst idea i've come up with is to just do the reflection but at build-time to auto-generate out a thousand lines of constructors but that seems dumb. surely there is a better way you could maintain a static list of all the types by hand! generally reflection is how this is done. if you keep doing lookups, you can cache the results from the first time and then use the cached results instead
|
# ? May 2, 2019 14:57 |
|
does c# have anything like jandex in the java world? jandex basically it runs at compile time, does analysis of the code, and builds an index that is packaged in the jar, and you can query for super fast reflection lookups without actually doing reflection.
|
# ? May 2, 2019 15:29 |
|
its annoying because its poo poo thats statically known at compile-time but instead i am paying a performance penalty on startup to resolve it at runtime!!!
|
# ? May 2, 2019 15:43 |
|
if you use the hand maintained list of classes you can add a test that fails when the list isn’t updated. but also if startup speed isn’t an issue id just use reflection but also be really annoyed by the necessity. DONT THREAD ON ME fucked around with this message at 16:01 on May 2, 2019 |
# ? May 2, 2019 15:49 |
|
yep, seems like if the angular compiler throws an error visual studio ignores it and keeps on truckin', hosting a website with no content if i want to see what the error is i have to open the command line and try to compile it from there
|
# ? May 2, 2019 15:59 |
|
HoboMan posted:yep, seems like if the angular compiler throws an error visual studio ignores it and keeps on truckin', hosting a website with no content If it makes you feel any better, I have the same problem with React in VS Code + webpack dev server
|
# ? May 2, 2019 16:17 |
|
DONT THREAD ON ME posted:if you use the hand maintained list of classes you can add a test that fails when the list isn’t updated. I added a few tests like this at a previous job. We kept having issues where people were adding values to a certain enum and not covering them with tests, so I made a test that iterated through all the values and verified via reflection that a (non-ignored!) test matched it. Got pretty entertaining calling out the devs who ignored the big "RUN THE TESTS WHEN YOU CHANGE THIS" warning before the habit really solidified in people. I wonder nowadays if somebody's ripped those tests out since I left.
|
# ? May 2, 2019 16:35 |
|
dependency injection feels like an antipattern it makes it so much more difficult to actually know where poo poo is used or where its coming from
|
# ? May 2, 2019 17:18 |
|
it can become an anti-pattern, but it makes things like setting up logging and data sources so much easier.
|
# ? May 2, 2019 17:24 |
|
Bloody posted:dependency injection feels like an antipattern it makes it so much more difficult to actually know where poo poo is used or where its coming from Foo comes from FooImpl Anything more complicated than that you're doing DI wrong
|
# ? May 2, 2019 17:27 |
|
Well OK maybe you use di to set up URL routing as well or something in which case look at your di definitions file where all the routes live I guess
|
# ? May 2, 2019 17:28 |
|
Bloody posted:dependency injection feels like an antipattern it makes it so much more difficult to actually know where poo poo is used or where its coming from yeah but in the end it's still constructing something with dependencies, so whether it came from the DI system or you manually constructed it it's the same.
|
# ? May 2, 2019 17:56 |
|
HoboMan posted:in retrospect i wish i had done GET /flask rather than just GET / you cannot get ye flask
|
# ? May 2, 2019 18:02 |
|
CRIP EATIN BREAD posted:yeah but in the end it's still constructing something with dependencies, so whether it came from the DI system or you manually constructed it it's the same. yeah but reading & understanding the manually constructed code is imo much easier (and the tools are much better at it) than the DI objects-from-thin-air architecture
|
# ? May 2, 2019 18:03 |
|
Bloody posted:yeah but reading & understanding the manually constructed code is imo much easier (and the tools are much better at it) than the DI objects-from-thin-air architecture this has more to do with the java inspired DI frameworks being bad than DI itself being bad. i very much hate poo poo like guice but i use it whenever i do java DONT THREAD ON ME fucked around with this message at 18:16 on May 2, 2019 |
# ? May 2, 2019 18:09 |
|
and here i've been mostly impressed with how well intellisense has been handling javascript compared to vs 2015
|
# ? May 2, 2019 19:11 |
|
how to do field masking now that jquery is haram? e: or disallowing characters HoboMan fucked around with this message at 20:55 on May 2, 2019 |
# ? May 2, 2019 20:48 |
|
shaggar what is the deal with .net remoting and is migrating to wcf the correct thing to do when stumbling upon remoting in a code base
|
# ? May 2, 2019 20:50 |
|
yes wcf is the replacement for .net remoting and it’s worth making the transition
|
# ? May 2, 2019 21:01 |
|
Bloody posted:shaggar what is the deal with .net remoting and is migrating to wcf the correct thing to do when stumbling upon remoting in a code base that was before I used .net so ive never heard of it. as with any old code unless you need to start maintaining or changing it i'd leave it the gently caress alone.
|
# ? May 2, 2019 21:10 |
|
i might need to refactor it anyway so i am mostly debating the degree to which i burn down the world
|
# ? May 2, 2019 21:15 |
|
if its a soap thing then WCF is super easy. if its like com or something there are probably better ways to do it
|
# ? May 2, 2019 21:16 |
|
|
# ? Jan 15, 2025 23:37 |
|
DI frameworks are a pain in the rear end. this is just singletons everywhere but with a veneer of shame on top of it
|
# ? May 2, 2019 22:33 |