« first day (1990 days earlier)      last day (2957 days later) » 

7:00 PM
I would try to group 8-11 and 33-36, just for fancy's sake, but that doesn't really matter.
 
The code's pretty readable
 
I feel like 17 and 54 can probably be combined into a helper function to munge paths
 
You said you would take the try/catch out of there, though? I do have one in the main function.
 
So i build a fiddel
https://jsfiddle.net/u0w5ergx/
Hope someone can help me. It hide parent if no child is visible but i don't visible it when it change filter
I got some problem with the parent hide part
 
Hidde?
 
7:04 PM
hide part
This part -> $('.month').each(function(){.....
 
@ndugger before when you weren't returning anything from catch, having it wrap the whole function was a bit odd
 
Move the assignment outside
 
what Jan said
 
lol you guys
do you really think I needed to see the alternatives? I was asking if it was an anti pattern
not "how do I do this other ways"
 
7:09 PM
It is.
 
don't just put code in front of us and expect it not to change :|
 
I'm sorry, next time I'll not post the code and just the question
 
good. God, you're the worst vamp ever.
 
I hope you get crabs then proceed to give it to every dude in your group
 
had enough crabs when I was out in Maryland in Jan
but it's totes an antipattern. I don't feel right declaring something without initializing it.
Usually you can avoid that, sometimes just by putting the init logic in a function and calling it right away.
 
7:12 PM
it's been a while since I've PHP'd but I recall seeing that all the time in CodeIgniter samples and docs
again, always assumed it was an anti pattern. never asked.
 
Declaration without assignment is fine. Assignment inside a conditional isn't.
 
@JanDvorak RAII bro
 
too bad we don't have the "falling outside the scope triggers cleanup" part, too.
 
crl
rai due?
 
totally changing it, I'd probably do jsfiddle.net/ycf5znb0
@JanDvorak if you do it right, it can
 
7:16 PM
Without openFile(filename, callback), I mean
Eh, you need the callback anyways due to asynchronicity.
 
crl
that getElement thing seems bad, but I confess I thought about doing that
 
@ssube tbh I find that less readable than the original
 
me too. I overdid it with the second function. jsfiddle.net/ycf5znb0/1
 
Still less readable than just putting the code there
 
crl
either you have none in dom or everything, you choose, and not make hacky things:p
 
7:23 PM
@Zirak but you can test it without actually having a DOM
 
What's poop? Is it an id, a selector? How's the element gotten? Is it from a linked list? Is it from the DOM? What if I don't have it in the DOM? What's that second parameter? Where is the element appended to?
 
@crl anything that touches the DOM will be hacky :(
@Zirak questions 1, 2, 7, and 8 can be solved with docs. 3, 4, 5, and 6 are not implementation details you should know.
 
You just parameterised constants, but the logic is still the important part and it's still exactly the same.
 
@Zirak actual situation (testing purposes) I get updates from the server, I want to see them all real time. so I check const [key,value] = read() then update the value on the DOM if it already exist (key is the id) and if not, put it in the dom and update it
 
@ssube Of course I should know them, and if you didn't use that function I wouldn't have asked questions 1-8
 
7:25 PM
but, aside from my crappy use. I can see it being a useful 'pattern'
 
@Loktar that video was pretty weird
 
lol yea
I felt bad for Palmer
 
It's not a generic function, it's just a template, it's a blob of code that's been de-constant-ed.
 
he wanted to show the rift and the dude didn't even have PC to use it on..
he went all the way to freaking Alaska!
 
in shorts and a t-shirt
 
7:26 PM
@Zirak No, you shouldn't know how or where it's be fetched from.
 
@rlemon oh, so you have a default-dict
 
I have no sympathy
 
haha yea
 
@ssube Dude, it says element in the function name
 
that was an odd choice of clothing.
 
7:27 PM
You can't tie every single little call all the way into the DOM.
That's going to be some ridiculously slow and you'll have spaghetti keeping you from ever doing something like React to fix it.
 
crl
var getShit = id=>id||document.body.appendChild(document.createElement('div').attr({id})) jk don't hate me
 
The function's already doing waaay too much
If you really wanted to be hip and testable... writing code, please hold
 
it's a basic getOrCreate factory
 
that Ross guy though, I see what people mean about being a scalper
he's all "Oh. Yeah. Cool."
 
yeah, he didn't seem crazy excited
I would have been pretty damn pumped man
as I'm sure you would have been as well
 
7:30 PM
I would have probably pooped just a little
 
Loktar hangouts ?
 
Also, who wouldn't love an autographed Rift
 
yeah that would be so sweet!
 
depends on the fact if its a rift to hell!
 
7:32 PM
The only autographed thing I own is a signed copy of a Bill Nye book
 
Notice how I did nothing in many lines of code
 
crl
// nothing in many lines of code, dang it ate my \n :(
 
Nothing is made clearer or simpler, you have to instead dig through several function calls to find out wtf I'm doing
That seems to be trendy though
 
@Zirak I raise you jsfiddle.net/ycf5znb0/6
 
Oh dear god
 
7:33 PM
@ssube I'm gonna be sick.
 
sensible defaults that can be replaced for testing, some abstraction but not much
 
You make me sick
 
@ndugger signed by whom?
 
@Zirak maybe, but I also (can) test my code
 
@KendallFrey signed by Bill Nye
 
7:34 PM
well
that's one more autographed thing than I own
 
@ssube That seems to be the excuse for any ugliness
It's convoluted, but by golly jee it's testable
 
@Zirak how is ctor/param DI ugly?
 
It's lasagna code with several layers of obfuscation but by golle jee it's testable
 
lasagna >>> spaghetti
you can split a lasagna apart and replace the meat with tofu, but if you have spaghetti, you're fucked
plus lasagna is clearly more delicious, possessing a cheese crust (when made well)
 
How about eating steak instead?
 
7:36 PM
have fun with your heart disease
 
I am
Won't invite you to the funeral
 
I wouldn't come.
 
Because I'm taking you with me to the grave
To the pain!
 
so... eternal cuddling?
also with steak?
 
I'm the big spoon
 
7:37 PM
seems ok
 
Coming at a funeral? That's just sick, man.
 
again, seems ok
 
I cuddle with steak all of the time
steak can't say no
 
You never had the good kind
 
you're cooking them too much
@Zirak I do agree that 4 helpers is silly. I just use them to keep DOM code from mixing in with my real code, because the DOM is so ugly.
 
7:41 PM
"Moooooo" is just 1 in Levenshtein distance away from "Noooooo"
 
@ssube you should drop that and use jquery
 
@JanDvorak Meh, I just tread the DOM like I treat any singleton. Carefully.
 
@JanDvorak I would kick you for that if somebody hadn't ruined joke kicks.
 
@JanDvorak That just made me irrationally angry.
 
@ssube For somebody's defense, it could have worked out just fine if there were no retaliation kicks every time that happened.
 
7:43 PM
@ssube Sure, if your code is DOM driven then you're probably doing things wrong. And I also used to be in the "functionise everything!" camp. but I've fallen out with that more and more recently after actually reading through a lot of my code and much more of other people's code.
Readability and bug hunting. A short example:
 
@Zirak the DOM API is ugly enough that I'm happy to work through an abstraction to keep it at arm's length
 
I don't necessarily functionize everything, but if DOM is an important concept in your app (and assuming you aren't using a special framework, than DOM is literally your means of output, so it's an important concept), you should build an abstraction over it, like a decent programmer.
 
something like Promises, with a nice documented API, I use directly
 
function foo() {
    doSomething();
    doSomethingElse();
}
 
but yeah, I/O should almost always have at least a thin abstraction like I think @MadaraUchiha is getting at
 
7:45 PM
What does foo do? That's a great question. You now need to take your time to study both doSomething and doSomethingElse to answer that question. That has its tradeoffs.
 
Just like you shouldn't be littering your server-side app with SQL statements and strings everywhere, you shouldn't have to deal with selectors and construction of HTML strings everywhere.
You need an abstraction over the DOM for you to speak to.
 
Usually we're really bad at naming so doSomething and doSomethingElse don't tell you too much, because they'll be named requestData and processResults
 
otherwise you get stuck working in a single browser, with a single database, on a single server
and this isn't 1994 anymore
 
@Zirak For starters, I'd much prefer
 
@Zirak backing up to the code that started this all: I just wrote function fuck() { console.log('the fuck') }
can you guess what it does?!
 
7:46 PM
function foo() {
  const result1 = doSomething();
  return doSomethingElse(result1);
}
 
@rlemon It swears
 
Now you can understand what lower functions in the chain do without necessarily understanding the ones up top.
 
@MadaraUchiha but his functions are totally unrelated
the smell there is having a container with two random functions in it
 
@ssube Then they shouldn't be bundled together... It's just bad coding...
 
The smell here are hidden dependencies
 
7:47 PM
Just functions don't provide structure.
Your code provides the structure, your layers of abstraction provide the structures.
 
((I'm in the middle of writing something else, but really? Nitpicking about a two line function? Do you see how low we've gotten?))
 
Functions are the tools to achieve that.
 
I usually go with something along the lines of writing a helper after I've done something the third time.
 
@Zirak Yeah, let's just require left-pad@0.0.3 and be done with it.
 
function foo() {
  // neither are atomic, the wrapping function was for convenience only.
  updateDOM();
  updateDataStore();
  // where is your god now?!
}
 
7:48 PM
meh, I lost my train of thought
 
@rlemon Yey globals?
 
First it goes in a utility class, then when that takes deps, a real class with DI.
 
Same problem, hidden dependencies
 
Yeah, you can nitpick endlessly on a 2 line function
 
My rule of thumb now is to stay at the same level of abstraction throughout the function and things tend to sort themselves out
 
7:49 PM
ctor DI is as far from hiding dependencies as you can get
 
But just because JavaScript allows you to have variables in an external scope, it doesn't mean you need to use it necessarily.
 
@ton.yeung Just today I debugged babel. It was horrible.
But that's unrelated.
 
Actually, you should only use that when necessary, because it by definition makes the distance between the variable's reads and writes greater.
 
90% of everything is crap.
 
@MadaraUchiha Nitpicking an example two-line function which calls two other lines isn't nitpicking, it's masturbation :P
 
7:50 PM
@ton.yeung That's not really avoidable, unless you're dedicated to rewriting and throwing away code (kinda like I am)
@Zirak In your words, it's pedophillia.
 
@Zirak you say that like it's not something you do nightly
 
@ssube I'm fine with that, just not all over me please
@MadaraUchiha Precisely
 
@MadaraUchiha I do that enough that I may have a problem. My programs evolve like the game of life, just turning inside out as they go.
 
It's 22 o'clock here, BTW
 
at the end, though, you have a really clear picture of what's happening
 
7:52 PM
@ssube That's not a problem if you work effectively.
I've found that this approach works best (for me) at the long term
 
@JanDvorak Time to turn into carriages?
 
It's hard to get others working with you to get on the practice though, which is why I only do it solo.
 
@MadaraUchiha if you keep things modular, rewriting one class isn't really that expensive
 
I guess I'm the engine....
 
@ssube I've found that Java devs see classes like Indians see cows.
 
7:53 PM
I'm the caboose
 
Getting rid of a class is blasphemy.
Although, admittedly, that might just be the Java devs I'm around.
 
My class design usually ends up being a pair of demigod classes tied together with a bunch of spaghetti
 
@JanDvorak And they fight each other for control over the cosmos?
 
@MadaraUchiha nothing is sacred. Throw it all away.
 
I've actually fallen in love with functional programming a lot recently... I don't hate classes, but god damn, they can be so unnecessary sometimes. I feel like my code is cleaner now that I've gone back to my roots, and do things a lot more functional
 
7:54 PM
Along with the flying spaghetti monster?
 
Chat Overflow
 
Split and merge like your classes are git branches
 
@DylanHarness Welcome to the JavaScript chat! Please review the room rules. Pleasedon't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@MadaraUchiha Not really. They're slaves to pasta.
 
@ssube I also found that I have a lot more test code than actual code
A rate of about 70/30 (haven't really measured)
 
7:55 PM
@MadaraUchiha oh yeah. Although I've found that can be a sign of poor mocks.
so now I have src/test/mocks with fake implementations and use those in multiple tests
 
@ssube It's usaully the framework that takes a lot of time and effort to develop and keep up-to-date
 
@ssube in that case I'd have everything in the main class, with some tiny side classes that I end up getting absorbed in the main class eventually anyways.
 
I'd rather write jQuery than tests... yuck.
 
Be it the mocks, the setup, getting the DOM ready, etc.
 
@MadaraUchiha yeah. Side effect of not having interfaces outside of the class, I think.
 
7:56 PM
@ndugger Hey FP lover, you do know that one of the main selling points of FP is testability, right?
 
hehe, a few weeks ago my co-worker slipped and said he'll do the testing for something I'm working on
 
@ssube Yes, that's true.
 
With a real interface, you can mock the contract and implement only the part you want.
 
Wrote it on our whiteboard, he'll never weasel out.
 
plus the god class would be called Master just because that's what the IDE defaults to.
 
7:57 PM
@ssube Yes, but I like not having interfaces.
Or rather, I like the different forms of abstractions that are made possible because there are no interfaces.
 
I go back and forth, but think TS' interfaces are pretty much ideal.
 
@ssube I really need to give TS a serious try.
 
You can't evade interfaces the concept.
 
I've played with it for a short while, but never really used it in a real project.
 
Especially enforcing that if you declare foo as a bar, foo must be known to be bar or a superset.
 
7:58 PM
@JanDvorak Of course not.
 
Interfaces the Java concept are a bit bloated, though.
 
And my tests pay for that.
For each abstraction I have tests ensuring it has this and that properties
(incl. functions)
 
@JanDvorak I actually think it's one of the things Java got sort-of right, but devs completely ruined
 
An interface would have spared me those.
 
@MadaraUchiha pls
 
7:59 PM
@Zirak marker interfaces are a bit of an abuse of the concept.
 
@ndugger I originally didn't like writing tests.
 
@JanDvorak As in Runnable?
 

« first day (1990 days earlier)      last day (2957 days later) »