Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

09-08-2018 , 10:44 AM
Quote:
Originally Posted by Grue
Imo if you don't push every commit eventually you will lose work. It might take a long time but it will happen. Since we squash and merge to master I don't care about feature branch history anyway.
with git reflog you can get every commit on your local. no matter if you hard reset (ie undo) it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-08-2018 , 11:09 AM
Grue’s point though is that you could lose your local disk and any work you just have locally.

I guess he’s probably right but it doesn’t seem like a fight worth having given how incredibly rare this would be.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-08-2018 , 01:26 PM
I used to work for an HDD company. I backup to remote daily if that tells you anything
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-08-2018 , 04:10 PM


Can someone explain what this means? Like you instantiate an object once, then you can't ever change the value of any property - instead you have to create a new object?

Ok I guess so. https://en.wikipedia.org/wiki/Immutable_object
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-08-2018 , 04:28 PM
Yes, look into immutabe js.

This is kinda like typescript in that it seems kinda annoying at first but its worth doing and avoids tons of bull****.

It is a pattern I originally learned from Redux and then went down several rabbit holes and now if I ever see "object.foo = x" I immediately cringe, or the even more cringeworthy "delete object.foo".
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-08-2018 , 04:40 PM
I feel like a case where you get an object back from the DB and want to delete a couple of sensitive properties before sending on to the browser should be an exception.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-08-2018 , 05:40 PM
Any opinions on this? - Tuple Spaces (or, Good Ideas Don't Always Win)

Quote:
It's as if the metric system had failed, and we had to do physics with foot-acres and what-not.
Fair assessment?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-08-2018 , 06:18 PM
Quote:
Originally Posted by suzzer99


Can someone explain what this means? Like you instantiate an object once, then you can't ever change the value of any property - instead you have to create a new object?

Ok I guess so. https://en.wikipedia.org/wiki/Immutable_object
gaming_mouse (don't think he's been around much lately?) used to espose things like this too, I think.

I'd be curious to see a large codebase full of immutable objects in action, anyone know of any on Github?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-08-2018 , 06:20 PM
Well react is basically built on that concept right?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-08-2018 , 08:46 PM
Quote:
Originally Posted by suzzer99
Well react is basically built on that concept right?
I can say that Elixir is based on that idea. You never modify an existing object. You create a new one.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-09-2018 , 12:53 AM
Quote:
Originally Posted by suzzer99
I feel like a case where you get an object back from the DB and want to delete a couple of sensitive properties before sending on to the browser should be an exception.
create a new object?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-09-2018 , 01:05 AM
Why? You're not gonna use the object for anything else, it dies as soon as the response is passed anyway.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-09-2018 , 11:05 AM
In a robust system with sufficient logging it lives on somewhere.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-09-2018 , 12:44 PM
Quote:
Originally Posted by suzzer99
Why? You're not gonna use the object for anything else, it dies as soon as the response is passed anyway.
bc those are the rules. in other words, bc thats how it passes code review.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-09-2018 , 03:00 PM
Quote:
Originally Posted by Larry Legend
In a robust system with sufficient logging it lives on somewhere.
You also don't want sensitive data going into logs.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-09-2018 , 03:17 PM
Well you could just ask only for the data you need. Or take your model object and use a serializer or decorator to map to a new object without the sensitive fields.

You can see how starting to add special cases where mutation is ok begins adding additional cognitive load. Much easier for the language to just not support it or to disallow with a linter or whatever.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-09-2018 , 03:21 PM
These objects come from back end services we don't control. How is a model object or decorator less cognitive load than deleting a couple properties before sending JSON to the browser?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-09-2018 , 04:47 PM
Well it doesn't make a huge difference for that exact use case. But in the general it's very easy to go from just deleting a sensitive key to just deleting a sensitive key, just translating a value, just adding a default value...

So in my mind holding to the rule even in the simplest case is helping to prevent death by a thousand cuts.

I don't really have a strong opinion about this in languages that support and encourage mutation, but I do appreciate elixir for eschewing it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-09-2018 , 09:39 PM
Quote:
Originally Posted by suzzer99
You also don't want sensitive data going into logs.
Yea true logging wasnt the best example for that.

But in practice I've always just copied the object by picking the keys that you want in the new object.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-09-2018 , 10:19 PM
Quote:
Originally Posted by suzzer99
These objects come from back end services we don't control. How is a model object or decorator less cognitive load than deleting a couple properties before sending JSON to the browser?
I don't necessarily care about enforcing immutability per se but I think in this case constructing a new object with just the fields you need is the right thing to do anyway since you want to control exactly what fields are sent to the client. Otherwise backend services can add fields to the payload and you will end up automatically including them.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-10-2018 , 12:22 AM
Well the counter is that maybe you want to include them. So now instead of changing code in two places (api, client) to add new fields you have to change it in 3 places (api, client, middleware). I think for some cases a field blacklist instead of whitelist is fine - but it's obviously highly situation dependent.

That's the only time I can ever think of using delete.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-10-2018 , 07:12 AM
I think you're making this too complicated. Instead of thinking every time you want to change an object, you just make a copy of that object with the properties changed. Some languages make this easier than others.
For example, in kotlin (java makes this more verbose) you can just say:
Code:
data class DataState(
  val user: User,
  val goldStars: Int,
  val isOnline: Boolean
) { 
fun setUser(user: User) = copy(user = user)
}
Then to make a new object of the DataState:
Code:
val newDataState = oldDataState.setUser(newUser)
in the above example, oldDataState is immutable and doesn't change. Anything referencing it always points to the same values. Immutability matters a lot more in multi-threaded applications (but thats most of them) because side effects won't occur as a result of the data changing
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-10-2018 , 12:17 PM
Yeah you can do that for sure. But delete is still less code, and I just don't see an advantage to making an object immutable for immutability's sake in a node/express app - where literally the whole framework is based on muting objects (adding to res.locals to pass along through the express middleware chain).
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-10-2018 , 07:53 PM
Btw I made a greasemonkey (now called tampermonkey) script to scroll pages back to the correct first unread post - after the tweets load inline and screw up the scroll position.

Code:
// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://forumserver.twoplustwo.com/*index*.html
// @grant        none
// ==/UserScript==

(function() {

    setTimeout(() => {
        $('html, body').animate({
            scrollTop: $(window.location.hash).offset().top + 'px'
        }, 100, 'swing');
    }, 3000);

})();
On Chrome tampermonkey is an extension, not sure about the other browsers. I set the timeout to 3 seconds which is a total guess. Seems to work ok so far.

It also should be easy to wire up to a hotkey to scroll back to the correct position instead of 3 second timeout if that's preferred.

Ideal would be to capture the event when all the tweets are done loading. But aint nobody got time for that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-10-2018 , 08:17 PM
I don't think they're globally exposed anyways? Theres no xhrs so it has to be iframes. No idea how you'd get in there from the console to get exposed to things happening in there.

Maybe a better solution is to count the iframes and move the window up iframe count x 400px or something?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m