« first day (2949 days earlier)      last day (2000 days later) » 

12:00 AM
"You can’t succeed coming to the potluck with only a fork." -Dave Liniger (source)
 
12:20 AM
Hi
 
@Hans Welcome to the Java Chat, the room for Java enthusiasts! Please use a code snippet tool when posting code snippets. If you have an Android question, you're in the wrong place! And remember: this is not tech support! Thanks for visiting and have fun! :D
 
Anyone home?
 
 
2 hours later…
2:40 AM
morn
 
morn
 
 
1 hour later…
4:09 AM
@payne So you need to stick with Socket because of the requirement/rules of homework. There is hundred of ways to transferring data through the Socket. You mentioned youre using the TCP connection, is was a duplex connection, you can sent and receiving datas asynchronously. With Socket, first you need to handle the bytes streaming by yourself, there is plenty of examples in google.
Second, you may creates your own 'parcel' or you may named it different way, the parcel is streamable, and data inside it shall be final before pass to Socket. So you put datas inside parcel and give it to your Socket, your Socket will only handles how to send adn receive the parcel.
You can using event-based interface to emit/fire to the listened event when parcel is fully received.
 
 
3 hours later…
7:26 AM
If someone could figure out why this doesn't work, that'd be great.
Because right now it doesn't do what I expected it to do, and it doesn't throw any errors or exceptions.
Here's the main method I used to test it: gist.github.com/Jenna3715/8b6efac16f9d68d13640c0c0568fb731
This is why I don't use sockets
 
7:45 AM
/javadoc WebSocket
 
@geisterfurz007 Sorry, I never heard of that class. :(
 
Huh, I was so certain :/
 
 
2 hours later…
Zoe
9:24 AM
/javadoc WebsocketContainer
 
Zoe
@geisterfurz007
 
10:19 AM
morn
 
morn
 
10:31 AM
why does it not return with the value itself? Seems a waste of some speed to get the value again after calling that method
 
@KarelG Meh, maybe you wanted to do something else with that value
but only if it wasn't was already added to the map
 
int id = ...;
Foo foo;
if (map.containsKey(id)) {
 foo = map.get(id);
}
else {
  foo = factory.buildFoo
  map.put(id, foo)
}
// use foo
 
I don't know, it's a rather specific method, isn't it?
 
i wanted to reduce that
 
foo = map.get(id);
if(foo == null) {
    foo = factory.buildFoo
    map.put(id, foo);
}
actually no
damn, would be nice if getOrDefault accepted lambdas
oh there is
computeIfAbsent
map.computeIfAbsent(id, k -> factory.buildFoo());
 
10:41 AM
hi guys some one use DEVOPS?
 
@Neil yeah, noticed that when I was going to write "wanted to reduce that to" but edited it eventually
 
I really should start using the java 8 methods
I still code like it has to be backwards compatible with java 7, even though through some feat of miracle, the bank has actually updated the minimal java version requirement
 
@Neil such a silly idea :D
I wish getOrDefault didnt exist
@Neil J11 is out, upgrade damnit!
:p
 
not my fault! *runs away crying*
 
gitflow is a tool for devops?
 
11:02 AM
@Wietlol why?
 
because get should return Optional<T>
and then you can use .orElse(t)
 
If there is a remove method that iterates over the whole data set twice in each call but it also looks for the element in O(n) time wouldn't it be inaccurate to call it O(n)? should it be O(3n) as the worst case and O(2n) as the best case? is this correct?
 
(compiler should optimize it... which it is good at)
@someone so you mean O(2.5n)?
so if n doubles, the amount of time it takes to do the operation doubles
that makes it O(n)
 
2.5n ? so the big O notation is about the average time not only the worse case?
 
big O notation is about complexity, not time
 
11:06 AM
complexity is defined by the number of iterations over the dataset?
 
complexity is neither best case, nor worst case
complexity in big O is defined by the growth of the number of operations
O(1) means it will never grow, it is always the same
there is no difference between O(1), O(2) or O(9999999999999999)
(i think)
 
In this case what is the big O for the remove method? If it first iterates to check the data set and then does it again and only after that it iterates to locate and remove the item. So the worst would be is to iterate over the data 3n times
 
@Wietlol seems a hassle if you want to interact with encapsulation
eg in code
 
what does encapsulation matter?
 
@Wietlol well technically O(2) are two operations of constant time
 
11:08 AM
class Foo {
   public Bar getBarBy(Key key) {
       return map.getOrDefault(key, defaultBar);
   }
}

// somewhere
Bar bar = foo.getBarBy(key)
// work with bar
keh fuck shift key
 
But you wouldn't ever refer to O(2), because that's not what you're measuring
 
@someone what is the difference between O(n) and O(3n)?
 
you're measuring growth, so the convention is to use the most significant growth factor in an equation.. if it grows by n^2 + 2n + 5, then it is only O(n^2)
 
@Wietlol I would assume that if there is a 1000 items the worse number of comparisons is 1000 if it's O(n). However, if O(3n) the worse possible number of comparisons is 3000
 
Same thing for O(3n) vs O(n).. the message from this is simply that it grows linearly
It's O(n)
 
11:10 AM
if you made the method optional, I have to check if it is present or not
 
@someone read what I just said carefully "defined by the growth of the number of operations"
 
I use the ~ notation instead of that big O notation
 
you are not measuring the number of computations
only how fast it grows
 
You wouldn't use Big O Notation to do benchmark checks
That's not what it's for..
It only tells you what to expect when you have 10 times the number of items
For linear growth, it'll be 10 times slower
 
if you used the ~ notation, you can write ~3N or ~N. With your example, the performance is then resp. 30 times slower and resp. 10 times slower
O(N) is just vague as hell
 
11:14 AM
but 30 times slower is not correct here
 
Oh. I still don't get what the growth means or how useful the big O notation is.
 
look at it this way,
if you have a testing environment with 1000 things in your database and run some operation on it, you want to know how that operation will be in the production database with 10 million things
if your operation is O(n), that means that your operation in production will be 10.000 times slower
if your operation is O(log n), that means that your operation is only... 13? times slower
if your operation is O(2^n), then you want to cry
 
If your operation is O(n!), forget about it!
incidentally in the realm of NP problems if that's as good as it gets
 
How do you define slower? like if takes 1 second to do the 1000 things it would take you 10000 seconds to do a 10000000 right?
for O(n)
 
yep
 
11:18 AM
got it
 
nested loops are O(n^2)
which is why it is generally best to avoid if you can do without
better to do several sequential single loops than one nested loop
 
So how do you measure O notation for a complex algorithm? by basically benchmarking it?
and seeing how it scales
 
no, Big O Notation is just an analysis on the algorithm. You don't really determine the Big O Notation of an algorihtm by performing benchmarks, though you could if you had no other way
You see how the algorithm is, and determine its Big O Notation. Then you perform benchmarks given data of a certain size, say 10,000
If it is O(n^2) and it performs 10,000 items in a second, then it will perform 50,000 items in 25 seconds
we're ignoring overhead of course..
if overhead is significant, then you should factor that in. Like if you determine it is O(n^2) and it performs 10,0000 items in a second, and then you test with 50,0000 items and it takes 12.5 seconds, how much time was the overhead?
(overhead is constant time taken by a program and doesn't vary)
 
7.5 seconds?
 
it can't be greater than any runtime, because it's always there
It'd be 0.5 seconds in this case, because the other 0.5 seconds is the time it takes to run the algorithm with 10,000 items
if you know Big O Notation is O(n^2), then 50,000 (5 times the number of items) corrisponds to 5*5 or 25 times the performance penalty
So 0.5*25 = 12.5 seconds
well technically 13 seconds.. 12.5 seconds + 0.5
 
12:00 PM
A $1 bill lasts 18 months; $5 bill, two years; $10 bill, three years; $20 bill, four years; and $50 and $100 bills, nine years. Coins can usually survive in circulation for about 30 years. (source)
 
12:41 PM
posted on November 18, 2018

archive - contact - sexy exciting merchandise - search - about ← previousNovember 18th, 2018nextNovember 18th, 2018: $90 seems like a lot for a game, but thanks to inflation, when you re-read this comic in several decades you'll be like "WOW WHAT A DEAL, THE FUTURE SURE HAS CHANGED IN THIS REGARD, AND PROBABLY MANY OTHERS TOO"– Ryan

 
 
2 hours later…
2:32 PM
HEEEEEEEEEEEEEEEELP
@Wietlol You there?
 
just use your nose.
 
Oh with that message you just volunteered to help me :)
 
sup
 
I have a JPA call:
entityManager.remove(read(id));

read reads the object with the given id, id is given as method parameter.
That method is called by a Webrequest through Jax-RS.
That element is not removed. And I have no idea why not.
Another guy here suggested entityManager.flush(); after that. Same result.
 
Am here, not there.
silly fart
 
2:37 PM
Easy. Now help pl0x c:
 
why are you removing records?
 
Assignment.
 
silly assignments
 
why do you use an entity manager?
also assignment?
 
2:38 PM
What alternatives are there?
 
Spring-Data repository?
 
Assignment.
 
-_-
 
JavaEE limited and that means JPA for that stuff.
 
it is JPA
;)
 
2:39 PM
No extra dependencies.
Just what he gave us as pom and that's it.
 
Eck
 
ok...
1. make a new project and load the Spring-Data dependency
2. open the source code of that dependency
3. copy that source code to your silly project
4. build
there is a reason I am a bitch to teachers :D
 
May not do.
 
I've had some dumb-ass issues with JPA flushes and removes and what not
 
bitching teachers sometimes means that they give you a negative score
 
2:42 PM
@ballBreaker Motivating ._.
 
@geisterfurz007 what does read(id) return ?
 
hmm
Where is your code
show me your code
GIVE ME THE CODE GEIS
 
Might have gotten a little desperate with the flush there.
 
yeah but that remove only works with entity objects
I am expecting to have .find beforehand
 
@Override
	public Customer read(Integer id) {
		return em.createQuery("select c from Customer c WHERE c.id=:id", Customer.class).setParameter("id", id).getSingleResult();
	}
That is the implementation of the read method.
Customer is annotated with @Entity
 
2:45 PM
is the id correct? :P
 
lol
That code really doesn't give me anything
 
I can make a GET with the ID so I guess.
 
did you try to make "Hello World!" first?
 
We are in the third sprint of the project @Wietlol
 
If I'm remembering correctly, the flush won't do anything if the flushmode isn't set
 
2:46 PM
I mean
 
I seem to remember having to do something like this:
 
/javadoc EntityManager#flush
 
var x = em.createQuery(someEpicShit);
System.out.println(x);
delete(x);
 
getSession().setFlushMode(FlushMode.MANUAL);
remove(id);
getSession().flush();
but then again I wasn't using an entity manager
was session-based
 
2:47 PM
work out that method without using the read method
something like
 
Looks like entity manager has a flushmode as well
worth a try
 
Customer c = entityManager.find(Customer.class, id);
entityManager.remove(c);
but but ... I think that you should get an error
> "select c from Customer c WHERE c.id=:id" is not valid I think
 
@KarelG Oh! Mkay. Lemme see. What would the difference be though? Both should return an object in the persistence context.
@KarelG It is; I am very sure about that :)
As said: I can make a get request on the object and get the Customer in JSON in Postman.
 
SQL says no
 
Looks valid to me
 
2:50 PM
That's not SQL tho.
 
It's HQL
From what I can tell
 
/JPQL, yeah
 
try to change that SELECT c into SELECT c.*
 
OH FUCK ME
Sorry
Someone added some other code overwriting the implementation.
That's the good thing in my group. People are communicating :)
 
lols
 
2:54 PM
@geisterfurz007 I'd say the opposite is true if they overrode your implementation
 
Pardon. I was missing a /s
 
it's sort of hard to override someone's commit without pushing the "I don't give a rat's ass" button
 
In subversion you just commit and it's on the server.
 
@JennaSloan Welcome back!
 
@geisterfurz007 We use subversion though
 
2:57 PM
My condolences.
:44606314 Did you get your WebSocket done?
 
Usually it's met with red flags galore. I have to force it
 
@geisterfurz007 not yet
 
How unfortunate.
 
3:12 PM
Ew
French canadian currency format is gross
english: $1,999.99
french: 1 999,99$
 
@ballBreaker but a lot of currencies add the currency symbol to the right
because you say it that way.. Honestly not sure why you say "fifteen dollars" and write it as $15
 
I'm not a fan of the comma being the decimal point, also having a space for thousand separator
just all around yucky to my eyes
 
@Neil *cough* € 199
or 199 EUR
 
@KarelG I had to actually check ffs
Because I didn't remember
This shows euros on the right side
 
3:17 PM
@Neil It depends on the country :\
 
^
 
English - Irish (6153): €1,234.56
Spanish - International (3082): 1.234,56 €
 
that is why internationalization of currency sucks
the symbol placement is so random, even within countries that applies the same number display rules
 
true
I've seen it here written on the right
I guess I've gotten used to it
 
i just use EUR after digits
 
3:20 PM
So do I, mostly because I can't find a euro symbol on my keyboard anywhere...
 
Zoe
 
T_T
 
@Neil which keyboard language do you use? I use en_intl
if that is the case, alt+gr + 5 😉
or use the virtual keyboard. It will show you some symbols when holding shift / alt+gr
alt+gr is that right alt btw
 
or alt + 0128
 
I have a bunch of those memorized
Like this symbol `
 
3:28 PM
lol yeah I used to
 
I gotta do alt + 096 for that
 
huh, weird, I have one above my tilde key
 
 
Upper left has | or \
I think it is a traditional italian keyboard layout
 
Ahh
I used a spanish keyboard for a few months, it took me a while to get used to that
 
3:29 PM
Go figure.. I've got ç and §, but I don't have a freakin' tilde
Took me forever to find the curly brackets
They're not visible on the keyboard
 
lol D:
not a very coding friendly keyboard I see
 
nope :(
I even have a pound symbol
like wtf.. an italian keyboard..
£££
I don't need this shit
 
lmao
get rekt
 
already rekt
 
Zoe
@Feeds In 3.141592653 <arbitrary time unit>
 
3:32 PM
ragequit.jpg
 
lols ^_^
I have a date with a lawyer tonight
Wonder how that will go..
 
Zoe
@ballBreaker Remember, you have the right to remain silent... about the details of it
 
I definitely have the right
I had to fight for my right
to parttaay
You're under arrest. For being too sexy!
rips rip-away pants off
 
Hello! Can anyone suggest me books on Java which is easier and simpler for beginners as Complete Reference by Herbert Schildt on C? Anyone...
 
@NehalSamee Welcome to the Java Chat, the room for Java enthusiasts! Please use a code snippet tool when posting code snippets. If you have an Android question, you're in the wrong place! And remember: this is not tech support! Thanks for visiting and have fun! :D
 
3:36 PM
@ballBreaker If you're going to do that, I hope it's not the first date...
 
Zoe
^
 
@JennaSloan Isn't that how everyone starts all of their first dates?
No wonder I'm not getting any second dates lately!
 
...
@Neil switch to INTL keyboard lol. Coding friendly
my keyboard layout is that stupid belgian (point) one but the system keyboard is set as INTL.
that annoys some of my colleagues though. They thought that it is an azerty but it is qwerty. I see them mistyping a lot :P
 
lol
I think all keyboards should conform to my standards and expectations with no exception.
Maybe I'll dominate the world just to impose this
 
they just don't hear me when I say "it is a qwerty btw".
sometimes I press quickly on ctrl+left shift to change the keyboard language to BE (point) before they touch it
 
3:43 PM
Anyone here have any specific opinions on buying a used BMW ?
I'm looking at one right now that I'm thinking I might buy
 
I have a project with almost 9k lines and just now go the idea of making some java docs.
My question is should I push the html pages generated by javadoc to github?
Or would it make more sense just to have the comments, and let the person decide which doc builder to use?
 
@ballBreaker depends of the state of the vehicle.
 
Just anything against buying old BMW in general
I heard can be kind of shitty since the parts are expensive
a 2005 BMW 330xi AWD
 
it is a brand with expensive parts yes.
but you can find good replacements at the regular market
manufacturers sell these outside the regular distribution line too.
 
@AfonsoMatos You could push the HTML to another branch and use that as your base for a github.io page for your project. That way you don't have the HTML on the master branch and people can still decide what doc builder to use and you still have an online documentation.
 
3:54 PM
@KarelG hmm interesting
 
like at my car. The air intake filter costs 150 EUR when bringing it at our brand mechanic. And I did not count in the work hour he needs. But I could find a same product for 50 EUR. Just without an Audi stamp. Bought it and placed it myself.
 
Woah, why would the filter be so expensive?!
 
you pay for the brand.
 
They're like $20CAD at the store lol
That's insane
That's the car I wanna get. Guy is upping price to $3.5k because it needs all new brakes and 2 rotors to be road-worthy and certified ..
I'll try to drop him to $3.5k including tax and licensing and see if he goes for it
 
@geisterfurz007 But if I have it on another branch, how can I update my java docs with what I have on master?
I'm missing something.
Because let's say I have src on master, how to apply javadocs so that the result will go to the branch docs?
 
3:59 PM
Oh! Pfair point.
 
That's actually what I thought first time it seems a nice idea
But I see no way to make it happen
I wonder how pros do it
 
lmao I just realized that I have tabs in a screenshot of a project with the names "Trump" (don't ask) and "Test" in a documentation I was about to hand in tomorrow.
@AfonsoMatos No clue, sorry :/
 
 
5 hours later…
Zoe
9:30 PM
@Michael XD
 
10:19 PM
Heyyo
So quick question, if anyone happens to be here:
When is it worth extending a class, and when is it worth just declaring it as class variables?
oh wait nvm im stupid, cant expand into multiple classes <.<
 
Zoe
10:32 PM
@Xariez Depends on your use
Aside multiple inheritance not being possible, there are interfaces
But if you're talking about fields vs extending, that depends on your use
If your class needs a CoreClass instance, use a field. If your class adds functionality/is an implementation of ICore, implement (/extend if it is a class)
 

« first day (2949 days earlier)      last day (2000 days later) »