|
NihilCredo posted:i'm curious, if you're writing in a statically typed language and the class api isn't an absolute spaghetti ball of implicit assumptions, how painful did you find the refactoring effort? you just made a massive incompatible change to your api. any other code that consumes yours now needs changing too - hope you dont write libraries! hell even if your project is self contained, anyone whos working on a different branch is going to hate you when they try to merge. whereas if you just define the interfaces up front you can add another implementation without even breaking binary compatibility, let alone source compatibility. its good.
|
# ? Jun 11, 2021 15:02 |
|
|
# ? Apr 27, 2024 06:12 |
|
it's a solution to a specific problem, if you're having that problem then they're great but if not then they're not.
|
# ? Jun 11, 2021 15:12 |
|
I had a coworker at Experts Exchange who wanted every class to implement a new interface called EEObject, which was to be empty, because they couldn't think of anything to put in it yet, but "just in case" we ever wanted to add anything that literally every class should have in common. I got the feeling my boss had my coworker come over and talk to me because Boss thought it was unnecessary, but couldn't find the words to explain why. So I said, "That sounds unnecessary." and they dropped it. You Aren't Gonna Need It is such a fun thing when it turns out to be right.
|
# ? Jun 11, 2021 16:04 |
|
Soricidus posted:you just made a massive incompatible change to your api. any other code that consumes yours now needs changing too - hope you dont write libraries! hell even if your project is self contained, anyone whos working on a different branch is going to hate you when they try to merge. most people are not writing libraries which will be consumed by other people. if a rename as simple as changing Foo to IFoo makes people hate you then how do you managed to ever change anything? is your codebase just an append-only nightmare?
|
# ? Jun 11, 2021 16:19 |
|
I work on a product that is implemented in C++. We rarely define new C++ (non-rpc) interfaces. I've kinda groomed our test strategy for "unit tests" to be like: * Wherever possible, use real implementations. * When required, use fakes/mocks (generally for the remote services we depends on) * Rarely mock anything else. It's going pretty OK for us! Hope this helps
|
# ? Jun 11, 2021 17:22 |
|
CPColin posted:I had a coworker at Experts Exchange who wanted every class to implement a new interface called EEObject, which was to be empty, because they couldn't think of anything to put in it yet, but "just in case" we ever wanted to add anything that literally every class should have in common. I got the feeling my boss had my coworker come over and talk to me because Boss thought it was unnecessary, but couldn't find the words to explain why. increasing the complexity of your code "just in case" is the worst - even when it occasionally turns out to be useful and saves you some time, you already wasted far more time than you saved scattering 1000 other "just in case" complications throughout the rest of the code. the best code is the code you decided not to write
|
# ? Jun 11, 2021 17:29 |
|
Chalks posted:increasing the complexity of your code "just in case" is the worst - even when it occasionally turns out to be useful and saves you some time, you already wasted far more time than you saved scattering 1000 other "just in case" complications throughout the rest of the code. This is the most secure and bug-free code I've ever seen. https://github.com/kelseyhightower/nocode
|
# ? Jun 11, 2021 17:36 |
|
Jabor posted:if you get it right the first time the sign was just tapped like a page ago
|
# ? Jun 11, 2021 17:53 |
|
yagni shouldn't even be classified as "extreme programming". nothing is ever correct period, never mind "the first time"
|
# ? Jun 11, 2021 18:00 |
|
raminasi posted:i am getting the sense that this is just one of the few concrete c#/java distinctions in the space; something like mockito wouldn't be possible in c# without getting weird, because in c# you can't just stub part of an object for free. (and fwiw i don't understand why mocking a whole object is more of a smell than stubbing individual methods on it - in the ideal well-factored case, wouldn't the second option not be sensible anyway because the methods are all designed to work together?) my friend are you familiar with proxying https://www.castleproject.org/projects/dynamicproxy/
|
# ? Jun 11, 2021 18:00 |
|
Bloody posted:my friend are you familiar with proxying https://www.castleproject.org/projects/dynamicproxy/ you are making my point for me posted:You can use DynamicProxy to generate lightweight proxies on the fly for one or more interfaces or even concrete classes (but only virtual methods will be intercepted).
|
# ? Jun 11, 2021 18:13 |
|
There is a Microsoft Fakes thing which I think can mock just about everything, but it's more work to debug and more confusing than just using basic language features. Interfaces are simple and work with all your tools.
|
# ? Jun 11, 2021 19:36 |
|
finishing the week with the following comment in some code:code:
happy Friday
|
# ? Jun 11, 2021 20:02 |
|
Powerful Two-Hander posted:finishing the week with the following comment in some code:
|
# ? Jun 11, 2021 21:39 |
|
fourwood posted:the coding horror is the use of backslashes instead of forward slashes for comments loving too hungover to even write a comment properly
|
# ? Jun 11, 2021 22:00 |
|
its great, it will fail to run so you cant miss it when you return
|
# ? Jun 11, 2021 22:06 |
|
I've definitely left syntax errors for myself so I know where to pick back up on Monday. Good strategy.
|
# ? Jun 11, 2021 22:41 |
|
sounds like a problem for monday me
|
# ? Jun 11, 2021 23:21 |
|
CPColin posted:I've definitely left syntax errors for myself so I know where to pick back up on Monday. Good strategy.
|
# ? Jun 11, 2021 23:30 |
|
necrotic posted:its great, it will fail to run so you cant miss it when you return tbf that was phone posting not copy and paste, the real comment is correctly formatted
|
# ? Jun 11, 2021 23:57 |
|
Soricidus posted:separate interfaces are good and idk why people are obsessing over the testing thing. i use them all the time and rarely for mocking. theyre a useful organisational tool, they make your public api explicit instead of relying on convention or coarse-grained visibility modifiers, they let you inherit structure without having to inherit implementation. its good stuff and a useful tool to make my life easier. annotating your methods with public/private is too "coarse-grained" so instead you copy and paste the whole interface? "public" is not explicit? grats on making GBS threads up your codebase for $5 though
|
# ? Jun 12, 2021 01:44 |
|
Whats todays fastest method for replicating files across a MAN? Multicast only works to a certain speed and needs recovery back channels. BitTorrent sounds better than it is supposed to, I recall Blizzard using it and some here saying they moved to something else? Up to around 2GB, mainly video. https://tech.ebayinc.com/engineering/bittorrent-for-package-distribution-in-the-enterprise/ I see Canonical has moved from the gimpy Jigdo thing that no one knew anything about to the more standard zsync system as referenced by Ebay above. CTO job is starting soon, and Who wants some Django, Postgres, Flask, and oodles of JS? I have a LG set top box, it looks like it cannot support HTTP streaming at anything from 40mbps and 10-bit colour h265 to 3mbps h264. Literally stutters on all versions of the wonderful jellyfish video, which apparently is a thing. https://jell.yfish.us/ MrMoo fucked around with this message at 06:13 on Jun 12, 2021 |
# ? Jun 12, 2021 04:40 |
|
duz posted:sounds like a problem for monday me fuckin
|
# ? Jun 12, 2021 05:59 |
|
Monday me, specifically after I get "settled in", so Monday afternoon me
|
# ? Jun 12, 2021 06:01 |
|
fart simpson posted:*clears throat* in haskell you can implement type classes (basically interfaces) for types you didnt write and also wrap existing types in newtypes and give the newtypes a different implementation of the same type class, and the compiler strips all of that away so that at runtime the type and newtype are identical but with different functions called on them i havent thought about haskell in a while so i went back to look at it again and i still dont understand why people use it in any practical context. i took a class long ago from a person who was absolutely smitten with haskell but during their hours of talking about "syntactic sugar", etc, they completely, totally failed to convey why we as potential users might want to consider it as an option over other languages that have better library support, simpler syntax, more resume value, or other conveniences. and now that i look into it again, the main pro-haskell arguments seem to mostly boil down to "smart people like how sophisticated haskell is". most of the other quoted benefits seem to just go out the window as soon as you have to do any i/o. need to do a database query? need to interact with something over a network socket? need to activate a physical device or get user input? your lazy evaluation is done. your functions are no longer pure, because they have side effects. you no longer get free parallelism. you have to handle raw signals, bytes or strings and convert them to whatever types your program likes to think about. can your program even do anything interesting without crossing those boundaries? and if not, why even use haskell? most programming work is just endlessly refactoring ancient garbage due to arbitrary business decisions, and i dont see how haskell makes that easier. even in optimal circumstances, haskell's lazy evaluation is bad with memory usage so it seems like a poor choice for performance. if i wanted to build a really elegant calculator or something, sure, i can see haskell as a good choice, but in the world where programs are made by the lowest bidder and have to talk to other people's programs, who dont even follow their own specifications, and where you spend most of your time writing regretful compromises, well, being as abstract as haskell likes to be just seems like doing extra work to create more problems for yourself. not meaning to call you out or whatever, its cool to use what makes you happy and i'm not asking you to defend it or anything. it just feels like there's something else there that i'm not getting and it bugs me.
|
# ? Jun 12, 2021 07:57 |
|
lmao that's great did you get it from reddit or something
|
# ? Jun 12, 2021 09:30 |
|
Powerful Two-Hander posted:finishing the week with the following comment in some code: Saturday morning and the not hungover brain kicks in... the problem i was failing to solve neatly was to take a list of object ids where the objects may contain a reference to another object id as parent-child relationship, and process it so that the parent objects were all handled before the children. this would be easier if the objects had their parent id as a property but they don't. or more accurately they do but you have to parse it out of an xml string which means you've got to load the whole thing first. so what was my brilliant fix? Iterate over the objects, check each has a parent I'd after loading it and if it does, stuff that id into another list of children, then once the parents are processed, process the children. In between, create a dictionary of created parents to link a parent id to the created object reference. sort of works, fails in a case where a child is also a parent but good enough, commit it with a comment and go lie down. today I realise that because the parent and child ids are all keys from the same sql table in their ultimate source syatem (which I maintain), I could have just sorted the ids and it would guarantee that each parent is processed before any possible children
|
# ? Jun 12, 2021 11:04 |
|
Powerful Two-Hander posted:today I realise that because the parent and child ids are all keys from the same sql table in their ultimate source syatem (which I maintain), I could have just sorted the ids and it would guarantee that each parent is processed before any possible children this is totally fine but please don't leave the id layout assumption implicit. keep a hash set of the processed IDs and when you process a child, check that the parent has been already processed before continuing
|
# ? Jun 12, 2021 12:35 |
|
men with puns posted:what is I/O monad or literally anything in the lang people love to use to write parsers source your quotes
|
# ? Jun 12, 2021 13:32 |
|
Even if you think the io monad is impractical (although you can really just do your whole program in the io monad and then it's just like an imperative language), it's one of the most successful attempts to make a language where functions have to somehow be marked based on whether they're pure or not, which is an extremely good idea. Effect systems are getting more popular though, so I wouldn't be surprised if in 10 years whatever the next rust is will have a limited, hardcoded effect systems with just "pure" "partial" and "io" as effects or something like that.
|
# ? Jun 12, 2021 14:25 |
|
men with puns posted:i havent thought about haskell in a while so i went back to look at it again and i still dont understand why people use it in any practical context. idk i just like it and programming in haskell fits my mental model of how things should work better than other languages do. hth
|
# ? Jun 12, 2021 15:05 |
|
haskell is cool op
|
# ? Jun 12, 2021 15:06 |
|
in micro examples it looks complicated i guess but when actually putting different things together i find all that extra haskell stuff makes it much easier to figure out whats going on and how it all fits together, and easier to come back a year later and edit things without having everything break. i dont like haskell because i think im smart, if anything its the opposite. i like it because im not smart enough to use c# or something like that
|
# ? Jun 12, 2021 15:12 |
|
NihilCredo posted:this is totally fine but please don't leave the id layout assumption implicit. keep a hash set of the processed IDs and when you process a child, check that the parent has been already processed before continuing Everybody is proud of sorting sequentially submitted data by ID until, bam, some idiot does a migration somewhere and suddenly everything needs new indexes with Submit_Date in them. (And, since you've been storing everything in local time, with no time zone, this whole time, suddenly your users start filing a bug every year that stuff is appearing out of order between 1AM and 2AM in November.)
|
# ? Jun 12, 2021 16:59 |
|
haskell is nice because of its type system. other statically typed languages like python get you part of the way there, but the amount of constraints and verification you can encode in haskell's type system really does make it fun to use
|
# ? Jun 12, 2021 18:03 |
|
Powerful Two-Hander posted:Saturday morning and the not hungover brain kicks in... i would simply assemble a DAG and do a breadth-first search over it
|
# ? Jun 12, 2021 18:16 |
|
psiox posted:i would simply assemble a DAG and do a breadth-first search over it well, actually this whole thing is to create a DAG. it's my (probably) pointless "spare time" work project that I do when I'm bored with real work (arguing about estimates). each node type implements and interface (stop it) so has a method that looks for all related nodes in the source and adds them to the DAG or returns them if they already exist (using a lookup to a dictionary of node and type keys), then adds the edges linking them and any grouping structure around them. It's all then thrown at cola.js to draw it. so i actually probably could do that and while loop it
|
# ? Jun 12, 2021 18:50 |
|
fart simpson posted:idk i just like it and programming in haskell fits my mental model of how things should work better than other languages do. hth that's cool. maybe some day it'll click for me
|
# ? Jun 12, 2021 20:36 |
|
men with puns posted:that's cool. maybe some day it'll click for me The problem is, once you understand monads, you become incapable of explaining them properly. Haskell as a language is kindof like that, but on a larger scale.
|
# ? Jun 12, 2021 21:14 |
|
|
# ? Apr 27, 2024 06:12 |
|
every programming language should aspire to be haskell, because every concept you steal from it will make you better, but never, ever actually *become* haskell
|
# ? Jun 12, 2021 22:23 |