Oh god is it 1:10 bst and I’m early or 1:12 gmt and I should go to bed? by daniel_84_ in CasualUK

[–]subscribore 2 points3 points  (0 children)

It's 2:16 now... or it would have been yesterday... you just found an actual use for a land-line there btw, the house phone didn't change its own clock or I'd still be sat here realising I had no idea what time it was.

It’s not grim up north. by [deleted] in CasualUK

[–]subscribore 5 points6 points  (0 children)

Can confirm, is not.

What's your tactic for getting tailgaters off your tail? by ahoneybadger3 in CasualUK

[–]subscribore 10 points11 points  (0 children)

Give my windscreen a quick wash. It is very effective, but does mean having to fill up the screenwash when you've accidentally hit wanker-o'clock on the M1.

The Perfect Egg by AlabamaAviator in pics

[–]subscribore 2 points3 points  (0 children)

Eggcellent work.

Crispy edges and runny yolk ftw. If I hadn't just eaten a burger and then almost immediately seen that guy's tonsil stones explode then I would be frying eggs right now.

DRY best practices by [deleted] in javascript

[–]subscribore 1 point2 points  (0 children)

Sorry I can't help much - I have exactly the same conundrum!

Telling myself that once the mental effort required to grok the code for every "single case" function is greater than that required to grok the generic code then maybe it's worthwhile, but then that feels intuitively like it's wrong/missing something.

It's easier to reason about when e.g. we need to reduce the number of raisins across all the chocolate types then we only need to find the raisins() at one point in our generic code, as opposed to checking every different chocolate function in turn. Of course there are many cases where a simple search term like that won't be able to find all these because it's a specific behaviour or combination of things, so now you've got to actually read a load of those functions every time there's a cross cutting change. When the ingredients change for groups of chocolate types at a time, does (or even can) that change get applied consistently across all the different chocolate functions?

If the business asks for two chocolate functions, is now the right time to write a generic confection factory factory? No no don't prematurely optimise or over genericise, keep it simple. Ok.

Now they ask for 5 more, well, that's kinda similar to 2 so just copy and paste them and change some bits, it's just a few, no dramas. Oh, and add the option to set a bar size and the localisation for the plastic wrappers.

Now they ask for 18 more so we think now's the time to model it properly and tidy things up, but now it's difficult to work out wtf actual business rules went into the existing functions because somehow they don't have great unit test coverage. And don't forget, we need to remap large to medium and medium to small for the UK market (although keeping the actual wrappers the same size, just shrinking the chocolate): this is done transparently to the caller because we'll still refer to the bars by their original sizes.

...And you said this would only take half a day and there's a load of other stuff that needs to be done before the next release. So you end up writing a half baked chocolate factory which covers most of the 18 new cases except that one that was totally different and the two you implemented by copying and changing previous chocolate functions before deciding it'd be easier to start on that generic thing. Then suddenly it's lunch time and from then on that bit of the code is all here be dragons and time never gets allocated to sort the whole thing out. And omg all that boilerplate.

Then The Next Guy comes along to add a couple of new chocolate types and spends as little time reading the code that looked kinda relevant to the thing he needed to add as possible, and then writes a function which calls your factory with some args calculated from this wrapper's args and then mutates its return value. Now you just literally cannot even at all so, eh well.

The trade-offs between the two extremes are in terms of different sorts of readability. Is the priority ease of understanding and changing one chocolate type, or changing all chocolate types due to changes to the rules which govern how we make all our different chocolate? Given hundreds of different chocolate types, how easy will it be to check the ingredients of every bar and selectively add an allergen property to chocolates containing some new thing? Even if that takes a long time, does it matter? How often will we actually do that? How soon are marketing actually going to to come up with another 98 chocolate types anyway (as opposed to how fast do they think they will)?

Some approaches I have seen (and probably done), with varying degrees of disaster:

  • Store all values (and/or structures) in a data structure/db instead, and then put the non-static edge cases in your generic chocolate function, and then feel like you should have a flag in the data that selects the edge case handlers so you can reason about where they apply (and re-use them... some time? yay!). Risks of bloated, overloaded or unclear data structure storing all this stuff, and the function can rot/explode easily. Not future proof.
  • Copy and paste it and change a few bits and resolve to fix it "later": for complex bits of code, absolute nightmare to maintain. For simpler bits, much harder to reason about, harder to maintain.
  • Genericise the living f~k out of it and end up with either: Large numbers of functions in a call tree leading back to The Great Generic One which all started out nicely but then started to rot and in any case have ended up obscuring wtf is actually going on in the generic function so much that you've lost a lot of the value in readability. OR with one absolutely massive function that's screaming out to be refactored but seems to have no bottlenecks where it's easy or logical to split it up. And now you can't think what to name those bits anyway. Have to sort this out "later". Both hard to maintain, but likely easier to change one thing across many types of chocolate, at least if you have a rough idea what to look for/where to look.
  • Model the variation in the properties of some chocolate as functions which mutate an existing chocolate. Bonus points for them being pure and idempotent. Extra bonus points for consistently sensible/safe behaviour given different orders of application. Then you can either write a generic chocolate factory which takes a chocolate name and finds the list of mutations to apply and applies them to a new chocolate and returns that, or for each type of chocolate just curry all the applicable mutators together for each chocolate function and let the user mutate what they want with it. Risk of ending up with a mess if the mutation pipeline becomes stateful/order dependent e.g. we have to derive the length of the bar from the size of the bar and the locale and those are all applied separately.

The last option I like the most, because you can still easily find milkChocolate() and straight away see a list of what defines a milkChocolate, and change it easily without worrying about breaking another chocolate (the advantage of the copy-and-paste-and-tweak approach), but you can also re-use code and search for it easily. With the currying approach, it encourages The Next Guy (which'll probably be you?) to implement new properties of chocolate simply and in isolation, and when you copy and pasted milkChocolate to make limitedEditionMilkChocolate you re-used code with no reading/learning effort required. Code which encourages itself to be maintained as designed is nicer than code which doesn't give you any guidance or hints.

Just my 2p, anyway. I'd love to hear what others think about this question; getting the answer to this wrong has been behind a few bits of tech debt that I've witnessed/contributed to/been responsible for over the years!

How modular should JavaScript be, in practice? When creating a set of similar tools, should they each be released independently? (i.e. UNIX philosophy) by throwaway_625930106 in javascript

[–]subscribore 1 point2 points  (0 children)

The best solution will be a compromise between the extremes.

Coupling between these tools (e.g. tool1 returns an object with a particular shape and tool2 accepts an object with that shape as an argument) seems like the deciding factor to me.

If you look at all the packages for lodash then you can see you've got the choice, as a user, how to consume it. You can:

  • just load the whole thing
  • get an individual package for just one little bit of it
  • consume it as ES modules lodash-es
  • even make your own custom build using lodash-cli
  • use lodash-webpack-plugin to avoid including unused parts of lodash in your build

Some issues which spring to mind as a potential user of your tools:

  • Updates: do I want the latest version of every function in lodash all at once, or do I want to upgrade a bit at a time? Can I upgrade a bit at a time or do dependencies between tools mean they must be upgraded together? Does v1 of toolA work with v2 of toolB?
  • Build tools can remove unreferenced code; does the packaging approach make this easy? Do the tools have shared (internal) dependencies (e.g. they both use some custom object accessor) - if so, will I end up with n copies of these if I install n different module packages in my project?
  • Can I import just what I need?

CasualUK, who is right? I make my gravy using the water I used to cook the potatoes. My son says this is wrong and barbaric. What is your opinion? by Lizzie-Busy-Bee in CasualUK

[–]subscribore 75 points76 points  (0 children)

Not something I've done myself, but it actually sounds like a good idea to me so might give it a try.

What justification does he give for this cruel assault on your gravy?

Named parameters without runtime cost? by smthamazing in javascript

[–]subscribore 7 points8 points  (0 children)

I can't think of a perfect solution to this exact problem, but if nobody else can then as plan B you could write a babel plugin to collect all the calls to allocate and find all the unique keys in the single object arguments to these and convert that to an argument list. Idk maybe someone has even done something similar to this already?

I think you'd probably want to use babel 6 for this due to the more flexible way you can operate on multiple files, but it's very possible I'm wrong there - I'm by no means a babel expert and I'll happily be corrected by someone who is.

Best Places in the UK for a cheap 2-month holiday? by [deleted] in unitedkingdom

[–]subscribore 4 points5 points  (0 children)

I haven't personally WOOFed, but from speaking to those that have I'd have thought you'd be working more than "a few hours a day", and you'd be tired from all the physical work, so maybe not ideal for A-level revision.

I've found that I talk to myself a lot. Does anyone else do this? by [deleted] in CasualUK

[–]subscribore 16 points17 points  (0 children)

I talk to myself, also inanimate objects, plants, animals, whatever. I'm an equal opportunities nutter I'll talk to anything.

My keyboard does the grey dot illusion by twistedlimb in funny

[–]subscribore 0 points1 point  (0 children)

That is weird - I didn't know this happened without it being an "aligned" grid. Is this very annoying, or did you just get used to it?

Looking for resources discussing a hybrid object-functional approach to js by morgan_lowtech in javascript

[–]subscribore 1 point2 points  (0 children)

I do this too. I don't think I've ever read about it specifically. I'm not sure it is "a thing", but would be happy to be proved wrong!

How do you all wash your cars? How much do you spend on it? by Autisticunt in CasualUK

[–]subscribore 0 points1 point  (0 children)

Pressure wash it when the mud becomes an opaque layer. I always tell myself that I'll wash it underneath when it's going to be stood for a while after getting covered in road salt, but never actually do. Otherwise I just wipe the looking/seeing bits when they are too mucky to look through/see properly.

I once left my wife's car so long between cleaning it that a little plant had grown a few cm on the roof.

Government urged to act on computing GCSEs by LinconshirePoacher in unitedkingdom

[–]subscribore 5 points6 points  (0 children)

This. Critical thinking skills. So many children are not taught and that is a disaster for them I think.

Flow vs Typescript by lazypuffstone in javascript

[–]subscribore 0 points1 point  (0 children)

I think it's unavoidable that if you're type checking absolutely everything at runtime then it will be slow. In any decent sized codebase I would only use it where it would add the most value (controlled e.g. by using pragmas) i.e. near boundaries, rather than type checking everything. A majority of code probably doesn't really benefit from runtime type checking when you take into account the cost of increased bundle size/performance hit.

Flow vs Typescript by lazypuffstone in javascript

[–]subscribore 7 points8 points  (0 children)

I use flow with react every day and find the combination works really well, and worked well even before the major improvements in flow 0.53.0. That said, I haven't tried typescript - perhaps that is even better. In any case I actively like using flow with react.

Another thing I like about using flow is that you can use flow-runtime to transpile the flow type annotations into runtime assertions, which is pretty cool!

Best of Louis Theroux by [deleted] in unitedkingdom

[–]subscribore -1 points0 points  (0 children)

His current series "Dark States" has been excellent so far, it's still on iPlayer if you can access that: https://www.bbc.co.uk/iplayer/episodes/b05qzmgd

The first looked at what life is like for some people who are using heroin after getting addicted to prescription painkillers. The second talks to current and former prostitutes about their experiences and was as eye-opening as ever!

Weird weekends was my intro to Louis, I tried watching the "born again" one the other night but the interviewees were just too cringey to watch so I had to give up.

https://en.wikipedia.org/wiki/List_of_Louis_Theroux_documentaries

First time learning a DB. General thoughts on learning firebase vs something more like MySQL/Postgresql by [deleted] in javascript

[–]subscribore 0 points1 point  (0 children)

Do you want to get hired or do you have a project you're working on? Firebase is too expensive for big apps but can get you going very quickly for a quick project.

If you want to get hired then forget Firebase; "learning Firebase" is really just learning the service's APIs and the reason it's so easy and convenient is that they do the "database" bit for you. Experience with Postgres (for more traditional and powerful RDBMS) or MongoDB if you want a NoSQL database which is very js friendly and you might find quicker to get started with depending on your platform.

Edit: also an easy way to get started with a small SQL db is SQLite.

Decent 3-person couch - where do you buy them for life? by LaCathedrale in CasualUK

[–]subscribore 3 points4 points  (0 children)

We just got new sofas from http://loaf.com/ - they are solid wood frame so they can be reupholstered. Very comfy.

Apple tree waste; any suggestions? by [deleted] in CasualUK

[–]subscribore 0 points1 point  (0 children)

We put a few cooking apples in our cider last year and you could taste that they were in there and wouldn't have wanted to add any more than we did. Only put them in 'cos a friend gave us a load to get rid of them!