« first day (2277 days earlier)      last day (2650 days later) » 

5:01 PM
@ColdFire TL;DR - In languages like C, the direction of dependencies was downwards, calling function depends on called function. In OO, the direction is reversed, the calling function depends on an interface and not a concrete implementation, and so you can have actual abstraction.
(He explains it much better than I do, but I'll be happy to answer questions if you have them)
 
ohh yeah that i know but still i like to listen to it
because he must be knowing much more than me
and i will learn something new
 
Both Uncle Bob's and Misko Hevery's lectures are much watch for anyone who knows OOP
Specifically, everything on that playlist ^
 
user6857832
I'm not gettin' how am I gonna code like "when he throws a ball and all that he knock down some pins"?
 
user6857832
I jus need a hint lol
 
user6857832
@MadaraUchiha
 
5:05 PM
@Hemlata "Please enter how many pins you've dropped: "
 
user6857832
Oh like using Scanner
 
For instance.
Or you could hard-code the input initially
The goal is the relatively complex calculation of score
Not the input method.
 
user6857832
@MadaraUchiha Like I already give the input instead by letting user enter it?
 
@Hemlata Yeah
That's also a possibility
 
user6857832
Cool, It sounds interesting. I'll code it tommorow, cuz I'm sleepy now lol.
 
5:08 PM
@Tavo I <3 TDD
 
user6857832
Gnight
 
user6857832
Plus ya gonna help me If I'll get stuck somewhere in the code?@MadaraUchiha @ItachiUchiha
 
@Hemlata Sure
 
user6857832
Thanks! :)
 
@Hemlata Sure thing
 
user6857832
5:09 PM
Yea, thanks! I appreciate it :)
 
user6857832
Anyway cya.
 
@motaa 1st of all, you yourself know the process PID you spawn, or at least you can get it with zt-process-killer PidUtil#getMyPid 2) You can save that PID to temporary pidfile or wherever 3) you 'reattach' PidProcess process = Processes.newPidProcess(pid); 4) you kill e.g. ProcessUtil.destroyGracefullyOrForcefullyAndWait(process, 30, TimeUnit.SECONDS, 10, TimeUnit.SECONDS);
@motaa I am fairly certain the Windows/Linux is not a question also, github.com/zeroturnaround/zt-process-killer/blob/master/src/… should take care of that.
 
@unserializable that I got :)
OS is an option because 3 fully dedicated servers are unix and another 3 are windows ^^
I was thinking about what you mentioned earlier about me knowing the Entryclass. So I came up with that crazy idea (since JPS outputs the PID + full classname e.g. com.subpack.Entryclass) that I could check every running jvm on vm1 startup whether there currently is one jvm running with that specific Entryclass :)
with the now mentioned crazy idea I was hoping of getting around the fact that I have to store the PID somewhere. So whenever vm1 starts up if any vm is running with the serverclass as entry class I would kill it (even forcibly)
but anyways it works putting the pid into a file :D and for that +2! :)
 
5:42 PM
aight everyone have a nice evening!
 
@motaa ... wait a bit
@motaa JPS can also work.
@motaa but still ... why don't you just do it the way the parent spawns child, child starts, gets its own PID, writes it to say $TMP/theChild.pid
@motaa when parent comes up it kills the child by the PID, if necessary.
@motaa everything for that is quite easy ^^ and available.
@motaa ... and, returning to your architecture and suicidal ideas, when your parent and child are communicating via RMI anyway, then child can perform either seppuku or harakiri when the parent goes away.
@motaa since it is all on the same physical machine both should be rather simple and reliable.
 
@unserializable you don't need to
@unserializable ping the person you're talking to
@unserializable on every message
@unserializable it's quite annoying
@unserializable as you can see.
😉
 
@MadaraUchiha I have no sound.
 
@unserializable We do.
 
@MadaraUchiha so it does not bother me at all :)
@MadaraUchiha you have sounds for @motaa :) ?
@MadaraUchiha so its your alter-ego :P ?
 
5:50 PM
@unserializable No, it's basic chatting etiquette.
 
@MadaraUchiha thanks for worrying about basic etiquette.
@MadaraUchiha if you notice, I do not normally ping people that much.
 
Also, I'm a room owner here and a moderator on Stack Overflow, so I'm fairly sure I know how users are expected to behave on chat.
 
@MadaraUchiha but I noticed mr motaa was going away
@MadaraUchiha so I pinged him.
 
@unserializable So pinging them 20 times would make them stay?
Also, please stop pinging me.
 
@MadaraUchiha not stay, but notice the message.
... yes :) I will
 
5:51 PM
@unserializable They'll notice even if you pinged them once.
The notification they get gives them a link to the transcript, which lists all the messages.
 
afterall there was a long chat.
aha, does it now?
 
That might not be a bad thing.
 
That's the kind of link they get.
It's like a pointer to chat in a given time. All messages are there, regardless of who sent them and to whom the were sent.
 
Ok, roger.
Hmm.. but that only works when they are away, no?
I have not received any of those.
So if currently motaa is in the chatroom, do they receive that link somehow?
 
5:54 PM
@unserializable By default, it happens if you haven't read the message in twenty minutes
"read" means either clicked the notification number, or posted a message on the same room
 
(though in the lower left chat window some notifications are visible of coruse)
 
Yeah, seems clear
 
You can, in your chat preferences, make the notifications instant
So if you're not in the room or was away for a while, you get the notification instantly.
 
6:08 PM
@MadaraUchiha There's chat preferences?
 
There's only 2 check boxes?
 
... only 2 checkboxes, but potential for ignoring large number of users :)
 
mad is right
 
I can't wait to go home today
I feel so hungover still from saturday night lol
 
6:14 PM
lol
 
This song is helping me get through it
Super super dope
 
6:32 PM
posted on January 16, 2017 by CommitStrip

 
@unserializable I am at home now :D
 
@motaa well, have a nice evening :)
 
nono its fine since i am a student i work 24/7 haha
but since i already was 10hours at work I could not work more since law says that we are not allowed to work more than 10hours a day :D
I'll check your messages in a bit but first of all I need a beer :)
@unserializable u are absolutely right with your idea and thats the way how I implemented it... without using zt-process (I found the Management stuff on another SO post)
Unfortunately JPS is only included in JDK and most of the computers that could run as a remote server only have JRE
I implemented it using a file and if my teamleader thinks that I should go with the DB stuff I will adapt it then :)
 
6:48 PM
@motaa great then :). This zt-process was using the ManagementFactory for process PID detection too, yes.
JDK 9 Process#getPid() #destroy and other stuff is welcome addition indeed
 
@unserializable absolutely... when J9 comes out I can adapt the whole thing again :D
 
how to create a daemon thread?
 
7:05 PM
java.lang.Thread t = new Thread(...); t.setDaemon(true); t.start();
 
7:20 PM
cmon at least google first :) @rbashish
I googled your question and got this: http://stackoverflow.com/questions/19421027/how-to-create-a-daemon-thread-and-what-for
first hit btw :)
 
@motaa we meet again
@Unihedron u here m8?
 
hey @Gilad
 
@motaa i'm close to the point where i kill my self unless u save me
 
dont kill yourself :D coding can sometimes be a bitch... but when you get your problem solved it just feels insanely good :D
 
@motaa true
@motaa are you familiar with MVC and Observer pattern?
 
7:25 PM
@Gilad yes
by mvc you mean model view control i guess :D
 
@motaa yes, sweet
a little background, i'm creating a sokoban game using this pattern
but i have 2 problems, 1 is that i don't know when to use notifyObservers and what this function really does.
the 2nd is that i want to create a thread that runs a loop that gets the user input until he exits, but not sure how to implement it as a thread
 
well
 
i can send my github so u can look at the code but its pretty big so i can tell you where im stuck
 
notifyObservers actually says it all :) which means notify observers :D
but I'll try to explain :P
 
github.com/gilad215/milestone2 if u wanna take a look, its not close yet to being finished but it's gettin there
w/e dont even try if u dont have the time, its a mess to understand, just try to explain the notifyObserver please!
 
7:32 PM
what you want to do is that if anything happens (on your game field or any new input comes in from the cmd f.ex) you want something specific to happen
 
and the 2nd question, ill be more on point, i want to create a blockingqueue, but how can i keep the app running if the queue is empty? i want him to wait for an element to be inserted to the queue on 1 thread and get the element from another thread
 
when does sth change in ur game and when does sth need to happen when a specific change happens?
 
the user can load a level, save a level, and move the character {up,down,left,right}
check MyController the in the controller package
it has a hashmap of all the commands,
 
or lets formulate it differently... you are talking about the "observer pattern". So you can observe data and data can be observed
 
ok, so mycontroller is the observer, and mymodel and myview are observable
 
7:39 PM
in java you have as observer the observer interface and as observable object the obserable class
 
MyController implements Controller which extends Observer, its what the dr asked for
does that sound fine?
 
that sounds fine
 
MyView extends Observable implements View(i created an interface for model aswell)
 
now look at the observer interface here docs.oracle.com/javase/7/docs/api/java/util/Observer.html
 
wow, so i dont need to call MyController.update never?
 
7:43 PM
and what you want is that a class that implemented the Observer interface gets notified if anything elsewhere gets changed
no
that is why you got the notifyObservers
 
thats amazing, so where do i call the notifyObservers? in the blocking queue loop?
wait that doesnt make sense, i need to pass args to the update() function so it can change the model
 
so lets say you game has a button and whenever a user clicks on that button a specific observer should be notified and that Observer for example invokes a method that could access and/or change your View
 
if the update() function starts automaticly it doesnt get args
man i wish we could skype and i can "pay" u through paypal chatting is slow
 
of course it gets args
 
@Gilad Observer/Observable seem to be exchanged in your description.
 
7:47 PM
no need for pay here :) By explaining you I refresh it myself :D
 
Sokoban game field is static, unless the Player makes a move (so Model/View) remain static during the time move is awaited.
 
@unserializable i guess thats true
@unserializable @motaa i still didnt write the .start() function yet, i'm suppose to get commands from the blockingqueue, but what if no command has been inserted yet? like when launching the game? i dont know how to implement the thread/runnable here
 
and now @Gilad take a good look at this docs.oracle.com/javase/7/docs/api/java/util/Observable.html (first paragraph)
we'll get there soon :D
 
@motaa ok i think i understand it better now
so i can control the order of notifications
 
and in the notifyObservers you put the changed data in
 
7:52 PM
inside the function?
 
let me give you a very simple example
class JokeTeller extends Observable
{
private static final List<String> jokes = Arrays.asList(
"Joke 1",
"Joke 2",
"Joke 3"
);

public void tellJoke()
{
setChanged();
Collections.shuffle( jokes );
notifyObservers( jokes.get(0) );
}
}
I never get it right with code pasting....
class JokeListener implements Observer
{
final private String name;

JokeListener( String name )
{
this.name = name;
}

@Override public void update( Observable o, Object arg )
{
System.out.println( name + " laughs about: \"" + arg + "\"" );
}
}
and now the last part
public class Party
{
public static void main( String[] args )
{
Observer o1 = new JokeListener( "o1" );
Observer o2 = new JokeListener( "o2" );
JokeTeller dude = new JokeTeller();

dude.addObserver( o1 );

dude.tellJoke();
dude.tellJoke();
dude.tellJoke();

dude.deleteObserver( o1 );
dude.tellJoke();
}
}
@Gilad what happens here? well you got a JokeTeller called "dude" that got 3 jokes up in his sleeve
whenever he tellJoke's, his Observers listen and laugh about it :)
 
MyView ui=new MyView();
        MyModel model=new MyModel();
        MyController controller=new MyController(ui,model);
        ui.addObserver(controller);
        model.addObserver(controller);
 
note that the jokeTeller is the Observable object and not the Listener
 
so the update needs to know if he got a model or a view, if its a view he just needs to display the level, if its a model, he needs to update his level so the view can display the updated one, i just dont understand how all of this happens automaticly
let me read it again
my story is different than the joke teller, i have 1 oberver which is the control, and 2 observables(view,model)
 
8:08 PM
the setChanged() method sets a flag internally so that the notifyObservers method sends new data
I know that your story is different but it works the same way :)
why do you need an observable in vew?
 
not sure
i think i need to achieve a decoupling code
where view and model doesnt care about each other, and tomorrow i can give the controller a new view and it wil still work
 
gimme a sec I got interrupted :D
 
8:25 PM
@Gilad View is actually what renders Model, so they care about each other. Even when they are logically decoupled and you can switch Views easily.
For Sokoban, most natural seems the following arrangement: Model is Observable and notifiews View (Observer) whenever it is changed.
Whereas Controller would probably 'own' the Model (composition) and change it (which triggers the View update too).
 
@unserializable well it could be a way but my university project tells me to do it like i said, controller updates both, model and view have 0 communication with each other
could you guys help me with implementing the blockingqueue?
 
@Gilad better don't implement BlockingQueue. They are hard. Use one. E.g. java.util.concurrent.LinkedBlockingQueue
 
@unserializable i thought to use this BlockingQueue<Command> queue= new LinkedBlockingQueue();
 
.. but as for model and view having 0 communication... that sounds very wrong. For View to actually render the state it must have (immutable) access to Model state.
At least in that direction the data must flow, or you end up implementing not MVC, but something else.
 
@unserializable my controller has an instance of model and view, he can send view the models.getboard "ui.displayData(model.getLevel());"
ui is the view
 
8:41 PM
Yeah, one can compose Model and View into Controller... ^^ like you mention. But then doing the little ui.displayData(little bit of Model) etc calls where Controller modifies the View in little bits is IMHO not MVC anymore.
 
@unserializable why?
why do u need a controller if the view and model can interact with each other
 
@Gilad they don't 'interact' as in 'interact'. But View is based on Model state. That's the idea. One has abstraction of game state (Model, Sokoban field). And View presents that state (Model) to end-user in understandable form.
Controller is usually there to a) let end-user interact with it b) let Model know what input comes from the outside (e.g. end-user).
 

« first day (2277 days earlier)      last day (2650 days later) »