« first day (3167 days earlier)      last day (1782 days later) » 

8:00 PM
either bot is part of client or client is part of bot
 
who do you want to be the parent here?
 
the Client constructor would set this.bot = bot
@DaveS the bot. but client needs to access functions in the bot class.
 
no the client doesn't the client can invoke the bot's listeners
treat the bot as your activity and the client as your fragment
 
@DaveS Yes. I agree. Except for the fact that the client needs return values from some of the bot functions and emitters can't do that.
For example
let sites = this.bot.loadData('sites', sites);
loadData changes per instance of bot
 
the bot can manipulate the client directly
by calling functions on it
 
8:03 PM
go on?
 
so when you invoke the interface the interface can say client.setSites(data)
 
which takes us back to the interfaces Dave mentioned, the bot shouldn't care what kind of client it uses, it just expects it to implement method 1, 2, 3. And the client should just provide mechanisms to implement the contract
 
so client says, "parent class that implements me, I need sites"
then bot looks them up and sets them on the client
 
but bot shouldn't need to know what Client needs.
 
that's what the interface tells the bot
or vice versa, however you write it
an interface like Mehdi says, explains what a class needs
 
8:05 PM
The idea is that Client should be interchangeable. new SOClient() or new DiscordClient() can be passed to the constructor of Bot and bot shouldn't need to know the difference.
 
then the bot has the interface
and your client implements it
 
wdym?
 
so whatever actions you need your clients to do with the bot, define as part of the bots interface
 
DiscordClient may need different things than SOClient
 
but if the bot says interface.getChatStream
 
8:06 PM
new private methods but only exposes the "shared" ones
 
the client can do whatever it wants and just needs to send the stream to the bot
then the bot can read and send from the stream
it doesn't care how you got it
and you avoid the circular reference
 
yes and yes
 
so your client would be the activity and your bot the fragment
 
exactly, that's how I designed it
but, the bot handles saving and loading data. The save and load locations may differ instances to instance
 
so what you're missing here is that you don't need client in your bot
the client can listen for NEW_MESSAGE
and when it has one, invoke process message directly
because it has the bot
this.on(ChatEvent.NEW_MESSAGE, this.bot.processMessage(event))
 
8:10 PM
Maybe, but how does Client "get the bot"?
 
the client constructs it
this.bot = new Bot()
 
Ok. I am following you I think. But what about the bot using client methods?
 
the bot creates an interface
that the client implements
 
bros you're describing zucc
 
9
Q: A running example or working demo of Interface pattern in JavaScript

Anmol SarafI am reading the "pro javascript design patterns" book and finding little difficulty in understanding the "Interface" pattern given in the book chapter 2 as there isn't a complete code example demonstrating the use of this pattern. I am looking for some help understanding this pattern with some ...

interfaces are tricky in JS
 
8:13 PM
wait, is your bot in JavaScript?
 
javascript isn't object orientated so OO design patterns probably aren't good for it
 
@MehdiB. yes
 
in React what you do is have client pass a function for bot to invoke through the props
 
@TimCastelijns wdym?
 
8:15 PM
I maybe banished from this room for saying this, but I hate java so I wasn't gonna use that.
 
@JBis it's a bot/client where one implements the interface of the other
 
JBis, you can have client send functions directly to your bot with the same name
that's basically how you might do an interface
 
@JBis why do you hate it?
 
it just won't be enforced like in Java
 
@DaveS what do you mean by "send functions"?
 
8:16 PM
so your client might say
this.bot = new Bot(saveData, loadData)
in JavaScript everything is fair game
you can pass functions directly to other objects
then the bot can save those functions and use them
because they aren't really objects
JavaScript is just a bunch of nicely bundled spaghetti code
 
@MehdiB. I don't want to get into a Java debate :)
 
You should read up on JavaScript design patterns and a solution should become clear ;)
I need to get back to work
 
@DaveS you have been very helpful thanks!
 
@JBis oh don't worry I don't plan on doing that, I know Java rocks, I was just wondering what was your reason :D
 
@MehdiB. We will fundamentally disagree on how things should or shouldn't work in a programming language
 
8:21 PM
but surely you also hate javascript?
 
No. I don't hate it. Typescript is better tho.
I like js a lot.
 
then indeed we will disagree on how things should or shouldn't work
 
^ agreed :D
 
Fine, I will bite. What do you hate about js?
 
lol
 
8:24 PM
I hate that Java can't infer shit. If I said it was a String in the beginning, than its still gonna be a string 5 characters later.
 
@JBis which means you're safe if you ever make a mistake, unless you lack inspiration in variables naming XD
 
Thats the other thing. Java needs to stop looking after shitty programmers. If your a shitty programmer than your a shitty programmer and the lang can't protect you from that.
public List<Rectangle> rectangles = new ArrayList<Rectangle>();
 
public List<Rectangle> rectangles = new ArrayList<>();
 
@MehdiB. that is new. Why wasn't it originally designed like that?
 
that is 5 years old
 
8:27 PM
Why do vars in lambda functions have to be final?
 
they introduced it in java 7
 
for (int rowLocation = 0; rowLocation < gridSize; rowLocation++) {
            for (int columnLocation = 0; columnLocation < gridSize; columnLocation++) {
                Rectangle rectangle = new Rectangle(85, 85);
                rectangles.add(rectangle);

                int finalRowLocation = rowLocation;
                int finalColumnLocation = columnLocation;

                rectangle.addEventHandler(MouseEvent.MOUSE_CLICKED, (event) -> {
                    game.handleClick(event, finalRowLocation, finalColumnLocation);
 
they don't but vars from an outer scope, referenced in a lambda, have to be
 
@TimCastelijns why?
And why do I need a million imports to do anything ever.
 
looks like you'll just like javascript in your life, every programming language needs imports
 
8:30 PM
you also need that in js, they just happen to all be bundled in 1 file
 
or multiple if you have muliple <script> tags
 
@MehdiB. Well I'm talking about node here.
You can't compare client side javascript with java
 
node is not a language is it?
 
And yes, it does have imports but it always feels like less.
 
because more stuff is put in the same file
java has a limit of 1 "root" class per file, so naturally you get a lot of files and thus imports
 
8:32 PM
Ok, I am unbiting as the bait is just too exhausting to get
 
I don't like that about java though
I haven't really used java in the past year
 
I also love the truthy and falsy values in js
but many hate them
 
I don't, but I also didn't like it in python. But that is just my personal preference I guess
 
@TimCastelijns actually you can put multiple classes in the same file, they just have to be package restricted
 
There are also many reasons to hate java (and javascript) that I am too inexperienced to bring up.
 
8:35 PM
sup
 
same, I just use big words so people think I know what I'm talking about
 
but every language is hated and loved by many its just preferences
 
except PHP, which is hated by everyone
...right JBis? ...right?
 
...
I like php but I am starting to not
The more I use node the more I dislike php
the more I use java the more I like node
 
8:38 PM
I do like enums in java tho
I half assed them in js
 
man you will love sealed classes in kotlin
 
ChatEvent.NEW_MESSAGE = 1;
ChatEvent.EDIT = 2;
ChatEvent.USER_JOIN = 3;
ChatEvent.USER_LEAVE = 4;
ChatEvent.ROOM_INFO_CHANGE = 5;
ChatEvent.STAR_CHANGE = 6;
ChatEvent.DEBUG = 7;
ChatEvent.MENTIONED = 8;
ChatEvent.FLAGGED = 9;
[...]
 
too much code
 
@TimCastelijns Everyone says to try Kotlin
 
@TimCastelijns :O they're called "sealed traits" in Scala
 
8:39 PM
@MehdiB. true
 
that didn't go unnoticed XD
 
trait lol I mean what is a trait? Give it a real name
 
goes onto SO to solve seemingly simple issue. finds answer after 2 hours. gets distracted for another 2 hours
 
I agree on that XD trait = interface :D
 
whats with protocols on swift?
what the hell are those?
 
8:40 PM
oh but sealed classes are not interfaces
 
I tried swift and gave up after <5 min. Not because I didn't like swift but because I just was too lazy to learn it.
I hate starting new langs
 
I liked swift, but in my defense I tried swift right after having done a project in obj-c
 
entire world calls them interfaces -> apple lets call them protocols
 
protocolâ„¢ you mean
 
8:42 PM
@TimCastelijns that will be 10$ for having said the name, thanks
 
if you want to use protocols in development you will have to buy a dongle
 
Also Oracle is a bitch.
 
> this year, we bring something revolutonary to the world of programming... we called them... protocols
> clap clap clap
 
😂😂😂😂
 
i was against kotlin when i started
but man, writing java now is like riding a bike
 
8:44 PM
@JBis lucky for you js seems pretty future proof
 
Except the bike is on fire and you're on fire and everything is on fire and you're in hell.
 
hahaha
I was pro python 1y ago, now I write in it just because i can do stuff super quickly
 
@TimCastelijns Webassembly
 
heh :)
 
8:46 PM
and React and Redux and babel and gulp and jasmine and grunt and etc...
 
What dumb fuck saw Assembly and thought, "let's put that on the web"
 
Probably some super smart autistic dude
 
In fairness it not a bad idea, but I wish it was more like js compiles to web assembly
 
@JBis "let's put the web*in it"
 
8:47 PM
thinking back mehdi, I think I only liked python because it was so much more convenient to write stuff with than java, but then came kotlin
 
like terry davis
 
pythons a good lang I just was too lazy to learn it
 
@IvanMilisavljevic will have to google
I love super smart autistic people.... well rather...I like to read about them
 
I completely relate Tim, have a requirement and just 2h to do it? python
 
I have an excuse tho. I don't want to program for a living so I don't need to know this stuff.
 
8:48 PM
but then it feels like you're not doing something serious at all
 
right
bla bla bla typing is it a string, is it an int? Idk we will find out runtime
 
hahaha
 
@JBis Why are you programming then
at all?
 
he had to get 80 rep to chat here with the cool gang
4
 
8:50 PM
Nice. Only good answer.
 
to get 80 rep he had to learn programming
 
Only two reasons to program: 1) Job and 2) R15
 
3) the illusion that you'll build the next multi-billion $ facebook as a side project
 
@ballBreaker 1. It will help with what I do want to do (Cyber Security, specifically Application Security), 2. Its a means to an end. Hence why I know more advanced programming concepts but if I can't do the absolute basics very well. I only know if I need to know. For example, the only reason I know node is cause I wanted to build a bot and the first bot I saw was built in js.
 
well that's just bad luck
 
8:52 PM
@TimCastelijns ?
 
you might as well have come across a bot written in a good language
 
Why on earth would you want to do cyber security
most boring job in the tech industry IMO
 
@ballBreaker I am pretty good at it and its interesting to me.
 
It's basically just checking against a list of compliances
 
Don't get me wrong, I don't want to be doing any of that cryptography shit
 
8:53 PM
are you on security.se?
 
Fair enough my dude
 
that's more boring than watching paint dry
@TimCastelijns yes, but not very active
 
ok cool, they have a lot of good reading material
I sometimes like to read stuff on there and pretend I know what it means
 
lol tim
 
hahaha
 
8:55 PM
did people managed to found out you were just pretending?
 
no, no, I say "mhm, aha" and nod now and then
 
hehe
 
I also am a very skeptical and cynical person which helps.
I don't trust anyone.
 
thats always good
 
do you trust yourself?
 
8:57 PM
no
 
good answer
 
especially when it comes to my job
either devops or android
 
I love this song lyric
> Changed my mind so much I can't even trust it
My mind changed me so much I can't even trust myself
 
reminds me of that famous line
 
@IvanMilisavljevic It causes problems in everyday life
 
8:59 PM
> Drop it like it's hot
 
"trust nobody, not even yourself" ?
LMFAO
got'em
 
nice mehdi. Are you also familiar with "Get my money, buy my medicine"?
it's one of his later works I believe
 
i like to double check everything
 
listening now :D
 
tims do you have any good kotlin materials?
 
9:00 PM
@MehdiB. I don't believe you
 
im planing to go over the basics soon
 
if you know java just read the kotlinlang.org docs and you will understand everything immediately
 
4 mins ago, by JBis
I don't trust anyone.
checks out ^
 
:D
ok gtg gonna finish my bot
o/
 
9:02 PM
i've been writing kotlin for a year and a half now, but i want to get deeper
 
btw Tim, my new friend is dutch, we became friend because we teamed up for 3h on a fussball table, and we won every single game... and because of the humour 😂
 
idk, do you use coroutines?
nice man, I play foosball every day with colleagues
 
not yet, im still on rx
im rewriting my core framework with new jetpack stuff
 
it's super fun, I hadn't played since graduation (~5.5y ago)
 
I will leave y'all with this great song
 
9:04 PM
and coroutines feel like a way to go
 
oh so it's "foosball" not "fussball", thanks
 
Note: Totally unrelated from the conversation
 
@IvanMilisavljevic ;)
 
@JBis foosball => perspectives, got the link ;)
 
9:06 PM
I miss foosball
and on that depressing note, I'm out, ciao for now fellas o/
 
what did you play? defense or attack?
Cya!
 
Always swapped
best at defense though
 
same and same
 
Nice, I suck at defense, but quite good at attack :D
 
@DaveS Ping me when you get back if you can, I got a couple questions.
 
 
1 hour later…
10:42 PM
@CarlAnderson @TimCastelijns did you see this? I tried adding that dependency to the gradle file and can't get the warning to trigger.
 
I don't even know what I'm looking at
 
My repo with a sample app in it
and a partially finished perl script to check a file for dependencies to check and add (one at a time) to the gradle build file
 
10:59 PM
...
 
11:12 PM
@TimCastelijns when I said this I actually started doing it, and that link to github is my repo with the app in it. But I can't reproduce the actual problem (warning about using deprecated Compile) and was hoping you could clone the repo and try yourself to repro it.
anyway I'm out for the day
 
god damn
updating glide from 3.7 to 4+ in a gallery app
 

« first day (3167 days earlier)      last day (1782 days later) »