« first day (497 days earlier)      last day (3522 days later) » 

4:00 PM
@Mat'sMug I don't know. That's why I asked. I think that you can find an answer that turns out any way you want, depending on how you measure it.
Is the one with the most questions the best programmer? I doubt that (sorry, JDQs).
Is the one with the least amount of answers to his or her questions the best programmer? (assuming reviewers just don't have anything to say)
@janos I assume the same. I see no reason why it would collect.
Especially considering it's Javadoc: docs.oracle.com/javase/7/docs/api/java/util/…
> Returns a Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. (...) It does not support the add or addAll operations.
 
@skiwi I mean that this statement is wrong ....
A collection is a collection of values.
 
sometimes late good answers have a hard time outcompeting incumbent ones, like this one: codereview.stackexchange.com/a/62350/12390
 
There is no reason to believe that the collection returned by Map.values() does not have to go through each value in the source data before the collection is 'done'.
 
Knowing your algorithms (/problem-solving) and the tools/frameworks you're using, and when and how to apply that knowledge, makes you a good programmer I think. But I don't think it's measurable with a SEDE query. Hence, "Top Answerer" only means "Most Upvoted", whatever that means.
 
@janos Been there, voted on that
2
 
4:04 PM
Take an ArrayList, which is a collection, there's a real value behind each index.... etc.
 
@rolfl You mean that the collection returned by Map.values() would be something like new ArrayList<V>(allValues); ? That would go against the Javadoc.
 
@rolfl If it is a Collection<E>, it has a stream() method imposed by the interface, we agree on that part, right?
 
Which Javadoc?
 
3 mins ago, by Simon André Forsberg
Especially considering it's Javadoc: http://docs.oracle.com/javase/7/docs/api/java/util/Map.html#values%28%29
 
The stream() method on a collection is lazy, but is the values() call on a Map lazy?
 
4:05 PM
 
3 mins ago, by Simon André Forsberg
> Returns a Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. (...) It does not support the add or addAll operations.
The values() call on a map is only a view of the map. The collection is backed by the map
 
That does not make the values() call O(1)
 
@rolfl Ah correct, so indeed we need to look at how the contract of Map.values() is defined
 
@SimonAndréForsberg thanks for that! Left a comment for the user to change the accepted answer
 
I don't see any reason for how/why the values() call could be more than O(1) and still adhere to that.... ?
 
4:07 PM
@rolfl If it isn't O(1), then honestly the Map implementation is broken, even though it technically does adhere to the contract
 
If the values() call would be O(n) then the Collection view is likely not backed by the map anymore.
 
It is not reasonable if a Map would need o(n) every time it needed to build up its values() or entrySet()
 
Exactly.
I think @janos made a very reasonable assumption.
 
ConcurrentHashMap has a weakly-consistent values() call.
> The view's iterators and spliterators are weakly consistent.
> Most concurrent Collection implementations (including most Queues) also differ from the usual java.util conventions in that their Iterators and Spliterators provide weakly consistent rather than fast-fail traversal:
> they are guaranteed to traverse elements as they existed upon construction exactly once, and may (but are not guaranteed to) reflect any modifications subsequent to construction.
 
Isn't that the part where reasonable assumption stops? If you use a ConcurrentHashMap you are supposed to know what you are doing
 
4:17 PM
if you were to convert to a parallel stream, you are also likely to collect to a concurrenthashmap
 
It's not wrong to mention it as edgecase like this if you can clarify it, which you did here
 
I should not need to be defenfing myself here....
The onus is on you....
why do you have a collection when it is not necessary.
 
I agree that it is not necessary, but I still think that it's a reasonable assumption that was made by Janos.
Indeed it is "simpler" to iterate directly over the entrySet.
However, when using a ConcurrentHashMap, it seems like the entrySet is still weakly consistent: docs.oracle.com/javase/7/docs/api/java/util/concurrent/…
 
My point janos, is that your argument is that creating a:
stream -> foreach -> map -> collection-> stream -> filter -> foreach
is simpler than:
 
I don't like iterating over the entryset when you only need the values
 
4:23 PM
stream -> foreach -> map -> stream -> foreach (with 'if')
 
@SimonAndréForsberg Then there is no difference vs the values call
 
(which is why I only +1'd skiwi for the immutable side.... I disagree with the assertion that the Java8 usage is good).
 
and using filter seems more "idiomatic" than the if inside the foreach
 
0
Q: Is the SE voting system insufficient for CR answers?

svickThe question that prompted this is Add or view pattern with MVVM (but I think this situation is pretty common). There, you have two answers: one is long, thorough and overall great; the other is much shorter, but it still raises some good points (that are not in the long answer). In such cases,...

 
@janos 'idiomatic' is still being defined for Java8 .... and just because it uses a lambda does not make it good.
 
4:28 PM
@skiwi Exactly.
 
Anyway, @janos - I still disagree with your opening statement, and can't bring myself to +1 an answer that makes such a sweeping statement. I know the code you present works, and I know it will be very much the same results in terms of performance, etc, but, There cannot be a simpler solution: ... no.
there can be a simpler solution..... idiomatic, traditional, whatever.
I had this debate with @Simon recently, about why we were arguing about close reasons....
 
@StackExchange oh, the irony! Thanks @svick!
 
and I said we can only have the argument because we agree on so many other things that the smallest differences become significant.
2
I think this is one of those cases ... ;)
 
@rolfl simpler solution? close reasons? me? what?
 
I don't like the 'idiomatic' way for Java8 when it is the wrong solution....
 
4:33 PM
@rolfl Oh, that, yes :)
 
when I saw the question, I thought the collect due to the groupingby is ugly. I would prefer a solution that doesn't need to load the entire Person collection into memory. I assumed the OP was looking for something more elegant in this aspect. I like my answer mainly for the first part, which makes it clear that this just can't be done. The second part is about implementation, which indeed is arguable, but that's not my main point there
 
1
Q: JavaScript Validation

CalvinBit of a preface on my motive: I'm self taught and have never really worked in a collaborative environment. My only benchmark for quality is "does it work" and I've never been really subject to peer review. With that in mind I just thought I'd dump a small jQuery validation plugin I wrote here ...

 
There's a node package called node-sass. To my surprise, it only works with scss files. Interesting. =.=
 
different subject, interesting: the OP unaccepted my C# answer, and I only lost -5 rep. Is it because maybe I was rep capped on the day he originally accepted?
uhm, no that doesn't make sense
of course, -accept + upvote showed up as -5 in the notification box, nevermind
 
@Mat. Interesting review. Thank you. Kinda busy today, but I'll definitely give it another read and catch up with you later.
 
4:53 PM
@RubberDuck busy here too, later!
 
0
Q: Where is the possible memory leak?

MichaelWhere is the possible memory leak in my code? There is also supposed to be a programming error too in one the methods as well, that might cause problems if I create a subclass of this class. private static final int MAX_LIST = 3; protected Object []items; protected int numItems; public MyArra...

 
Whether or not this is homework is not really particularly relevant @raptortech97 — nhgrif 6 secs ago
 
@nhgrif true, the question is just as horrible either way.
Although I also think it smells like homework
 
> There is also supposed to be a programming error
not his code.
 
That's fine. I'm not saying the question needs to stay open.
 
5:24 PM
@nhgrif the thing about short answers, is that.. well, when I feeling like tackling a question, I like to review it inside out and lay down everything I can see that hasn't already been mentioned. I'll write a "short" answer when I don't feel like completely reviewing a post, and will walk away knowing (hoping) someone else addresses the other issues. I think both types of answers are acceptable. Depends on the question, but sometimes I just can't walk away with a "partial review"...
 
I'm not saying long answers are bad necessarily.
Questions should be answered completely, whether in one answer or in several.
Although with what you're talking about, I even think that several smaller answers all posted by you (2-4 depending on the scope of the question) would be better than 1 mega answer.
I do this all the time with Objective-C questions since there hasn't typically been someone to come in behind me and complete the answer.
 
Aargh... You've got to be kidding me
 
@nhgrif I implemented your suggestions and I am a lot happier with the result, thanks again
 
Can any kind soul help me?
I want to execute unexpand --tabs=4 (Linux command via GnuWin32) on every file recursively in a directory under Windows 8
Hmm and it should only be for *.java and *.xml files
I wish I was a Linux guru.
 
5:41 PM
find /path/to -name '*.java' -o -name '*.xml' -exec unexpand --tabs=4 {} \;
 
@janos But that is Linux syntax, isn't it?
The find
Or well actually
 
you're in Git Bash, right?
 
I don't have the find command
I do have a Git Bash yes
 
use it!
 
Oh, it has all Linux stuffs inside it? ;)
 
5:42 PM
yes, but probably not unexpand
 
Okay, time to wreck this repo or perhaps just succeed in doing what I want to do
I've got unexpand somewhere on my disk
This one I found on SO: find . -name '*.java' ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
 
@skiwi - you have Eclipse?
 
Key point here if you want to try it yourself is that you need a temp file
 
no need for the bash thre
 
@rolfl Somewhere stashed far far away
 
5:44 PM
I don't have unexpand here: it cannot update in-place?
 
Nope it cannot
 
I see, yes, the SO solution is good
the ! -type d is unnecessary (paranoia?)
 
find . -name '*.java' ! -type d -exec bash -c 'C:/Program Files (x86)/GnuWin32/bin/unexpand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
works?
 
and you will need expand on PATH, or else use the absolute path
 
Or do I need to quote the path somehow
 
5:47 PM
no, not good quoting
 
Will regular " around it work?
 
find . -name '*.java' ! -type d -exec bash -c '"/c/Program Files (x86)/GnuWin32/bin/unexpand" -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
 
find . -name '*.java' -o -name '*.xml' ! -type d -exec bash -c '"/c/Program Files (x86)/GnuWin32/bin/unexpand" -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
Then for both java and xml?
 
or edit ~/.profile and add a line: PATH=$PATH:"/c/Program Files (x86)/GnuWin32/bin/unexpand" and then you can just use unexpand in the find command
the command already includes java and xml
well?
 
Testing it now
It didn't show any output and finished in 0.3 seconds approx
Wondering whether that is a good thing
 
5:52 PM
you could stick in a -v for the mv, like this: mv -v /tmp/e "$0" to see the files getting processed
 
It modified a bunch of pom.xml
 
are your files under Git?
 
Yes
didn't seem to touch the java files
 
so it's easy to check what changed :)
 
Didn't modify java for whatever reason
 
5:54 PM
ah yes
remove the -o -name '*.xml'
it didn't include the *.java, we should have enclosed the two sides of the -o inside \( .. \)
so just run again now with only -name '*.java', no more xml
 
Okay, one day I'll be a guru
2
And I saw it printing things, good good
 
this would have done both at the same time: find . \( -name '*.java' -o -name '*.xml' \) -exec bash -c 'unexpand -t 4 "$0" > /tmp/e && mv -v /tmp/e "$0"' {} \;
 
Okay :)
 
@nhgrif I see what you're saying, but in the tag I'd feel like I'm whoring votes if I split an answer in 3-4 smaller ones. Like that one ref'd on meta, could have been a "view" answer and a separate "model/viewmodel" answer perhaps... but I'd feel somewhat dirty doing that :/
 
If you are ding a straight \t to 4-space translation you can do it easier with sed.
in-place s/\t/ /g
 
6:00 PM
sed is evil, I found out on SO
It will also translate intentional spaces in code for example
 
whaaat?
 
DO NOT USE SED! If there's an embedded tab in a string, you may end up mangling your code. This is what expand command was meant to handle. Use expand. — David W. Nov 12 '13 at 17:11
 
that doesn't make sed evil. at all.
 
For this purpose maybe?
What did it exactly change in this file?
 
sed is a general purpose text processing tool, you can't expect it to know that your files are source code and it should not replace tabs within quoted strings
 
6:02 PM
I find it curious that the modified marks are at the end of the lines
 
It has converted \n to \r\n
 
Oh... not again!
2
 
yup. unfortunately.
 
and, also, the expenad option will expand all tabs in the document, unless you specify the -i argument.
 
So current setup is that Windows uses \r\n obviously, git does nothing and in Netbeans I configured it to convert/leave everything in \n
@rolfl Correct, but the unexpand works in reverse
 
6:04 PM
hang tight, we can fix this up for you
 
>DESCRIPTION
> Convert tabs in each FILE to spaces, writing to standard output. With no FILE, or when FILE is -, read standard input.
 
you'll need to revert changes and we go again
 
Now, if you were using eclipse.....
2
 
ok try this:
 
I'll add --first-only just to be sure
 
6:05 PM
0
Q: Design of Colour Fading for WinForms Controls Effect - Open for any kind of Suggestion

AeolusI wrote this little piece of code to linearly interpolate between a winforms control's background colour and any arbirtrarly chosen colour. I don't like the way I wrote this piece and I was wondering if any of you would be interested in suggesting improvements. Some improvements/thoughts from...

 
try this: find . -name '*.java' -exec vi +'set ff=unix' +wq {} \;
and check the diff again in any java file
this is after unexpand, to fix the \r\n
 
let me see
 
so: 1. revert; 2. run unexpand again, add the -i flag; 3. run the vi
 
I don't think we have any tabs other than at start
so reverting should not be neccessary
I think that's more of an issue to Python ;)
 
not at all
well
you'll see in the diff at the end
 
6:09 PM
That command crashed my shell
I saw it like 'flickering' a lot of times, presumably for every file it encountered
 
I got a Necromancer badge on CR meta... lol.
And... Monkernoon!
 
Monkerevening @Phrancis
@janos Is there a way to combine this into the unexpand?
 
it doesn't have an option to save in-place
so, no
 
problem is that it crashes when doing it in the shell
 
the flicker suggests it could update at least some of the files
if you do the diff again, do you still see the ^M ?
 
6:15 PM
I'll run it again now
 
I don't see why it would crash anything
 
Might be too many focus/defocussing of the Git Bash in too short period
 
what focus/defocus ?
 
The 'flickering' I said a few lines earlier, I suspect it's focussing/defocussing the shell window
 
there's no reason to do that
 
6:18 PM
mutter mutter mutter .... hmmm
2
 
This time it didn't crash
And changed way less
 
how's git diff looking now?
 
Something with newline at end of line
but only 3-4 of a lot of files are like that
It worked either way :)
 
the 3-4 files are *.java ?
 
yes
 
6:21 PM
weird
run it again
well
no
run it again only for those files
instead of find ., use something more specific to avoid running for all files
or better: vi +'set ff=unix' +wq path1 path2 path3
 
It seems like those files themselves were at error
So nothing to worry about
 
0
Q: BFS and DFS tree traversal Scala

toto2I posted some code as part of an answer to another question and I thought it would be a good idea to get that code reviewed also. Any comments are welcome, but I am mostly annoyed by terminalNode. It is basically a slightly convenient factory method, but I think it should either be renamed to s...

 
Thanks a lot either way @janos
 
anytime @skiwi
 
6:40 PM
0
Q: Determining vehicle jump landing quality

Nick UdellI am writing a game where a car drives and makes jumps. When a jump is landed, the player is rewarded if they land all four wheels either at the same time, or near to the same time. If they don't, they are penalised. I am concerned my solution is not well abstracted (although I am open to all to...

0
Q: LinkedVector : a vector of elements with links to other elements

NelxiostSo I wanted to have a vector with usual values and with some sort of indexing : an element can have links to other elements (via indices). Something like the following, where V::size_type is the type of the vector's indices. vector<pair<T, vector<V::size_type>>> Obviously, this does not work b...

 
lol, I just thought: "Hey, why haven't I created this method?", and so I implemented that method, and when I had done so I thought "Hmm... this name isn't quite right". So I renamed it, and then I got a compiler method because I had already implemented that exact method!!
3
 
You're too smart for your own good lol
 
Your code, @Simon compiles, and runs all tests pass in Java8
 
In the end, both answers were good. 200_success helped me realize I needed a sanity check, and I found out the schema design I was looking at was my old version rather than my final version. @PavelStehule recommended passing parameters explicitly (which I will start doing going forward) and ways to make error handling easier. I accepted Pavel's for spending the time to explain all that. — Phrancis 39 secs ago
I had no idea you could do all that in Postgres, it is way more flexible than I imagined
@Mat'sMug have you considered switching from MySQL to PostgreSQL instead of M$ SQL?
 
6:57 PM
@rolfl what code? The code I am working on right now, or the Minesweeper analyze stuff?
 
Minesweeper Analyze
Crap, hate computers with caps lock
 
LOL lol
5
 
I know that it compiles and works on Java 8, I've started using Travis CI for it (thanks @skiwi)
But it's nice to hear that it :)
@SimonAndréForsberg Compiler method? Wtf? Compiler error of course...
 
@SimonAndréForsberg You've made an error?! Here, have another method!
4
 
7:06 PM
@Simon - anything special about RootAnalyzeImpl ...?
 
@Phrancis nope. Getting my SQL Server instance over this weekend anyway ;)
 
@rolfl what should be special about it? Nothing special about it IIRC. It's the implementation for the RootAnalyze interface.
 
Except it is not, right? It implements nothing....
public class RootAnalyzeImpl<T> {
	private final List<FieldRule<T>> rules = new ArrayList<FieldRule<T>>();
 
hmm... lol. you are right
It was the implementation for the interface
I refactored it
Based on suggestions from my first Minesweeper question
 
I presume the interface had the JavaDoc as well.
 
7:11 PM
What interface? The non-existing RootAnalyze ?
 
yeah... that one... I'm looking through git to see if it exists there.
 
Nope, it doesn't exist
it got converted into AnalyzeResult
RootAnalyzeImpl used to be the state of the analyze both before and after it was performed (i.e. it contained the results as well)
now it is just the class responsible for creating the AnalyzeResult
 
OK, your longest-running Unit test solves the 'bastard board', and launches from that point... RootAnaluzeImpl.
Is that a good place to start in to your code, or should I go from the DetailAnalyze method like your question suggests... ;-) ?
 
To understand the first steps as well, starting in RootAnalyzeImpl is a good choice.
 
I was thinking I would sort out some of the JIT issues with the methods, and then run it through some profilers.
 
7:16 PM
Ah, cool
 
See where the time is actually spent.
Running that test seems like a good place to start.
 
OK, note for you .... your entry point has no documentation, comments, and the name is misleading ;-) (but it is not part of the code review).
3
 
I think that you could actually run the detailed analyze on that 'bastard board' as well, but it will probably take about 40 minutes or so :)
@rolfl Noted. I will create an issue for that in github and will work on that :)
 
Let me do that for you ... ;-)
 
7:18 PM
Thanks :)
I tend to be focused on just making it do it's job, which it does :)
 
@Simon, you may also want to give it a completely different name.....
3
 
AnalyzeResultFactory ?
Haha, lol
2
it's not my fault you got too many tabs open so it cuts off the name :)
 
How did you mess up my bot?
@SimonAndréForsberg If I open it, it wouldn't even show a name.
Did you possibly enter a blank after the title?
 
String.trim()
 
Well figuring out if that's the issue, but it seems to be by the looks of it?
 
7:29 PM
there's an additional space at the end
Javadoc/comments **
 
Well, sorry, I do that sort of thing (identify odd test cases).
 
And this time you probably didn't even try
 
8:10 PM
So that is why I am getting old versions of files, I am first copying the files and then rebuilding them
 
maven?
 
Yes, what else?
(I feel a hate train incoming)
 
@skiwi seems like you have talked with monkeys before :)
 
Yeah I got a real interesting build sequence now...
 
@skiwi No, no hate train, you didn't really need the new versions of the file anyway,
 
8:15 PM
You start off with a dirty build
Then you build the parent project (delete old versions, copy over new artifacts in there)
Then you build the children projects after that (delete old versions, copy over real new artifacts in there)
 
Ever heard of mvn clean package ?
i.e. clean first, package later
 
It should ideally integrate in mvn clean build
 
does mvn clean build even work for you?
my maven tends to say that build is not a valid phase
 
Hmm
how does an IDE call it then on clean build?
 
I think you might be able to specify that in the IDE
 
8:22 PM
But it has a default
what is the normal way to use it, mvn clean package?
 
that's what I use on the command line
 
ah yes
Point is that I need to bind to the point where submodules are build
like post-package, which isn't there
 
8:42 PM
clean build: mvn clean compile
this compiles submodules as well
test includes compile
package includes test
so mvn package is the same as mvn compile test package
^^^ for example
 
Ah okay @janos I just read up a bit about lifecycles
 
lifecycles, yes! that's what they are called!
 
@rolfl @SimonAndréForsberg a lot of us seem to have too many tabs open...
 
> Show all 138 tabs
 
8:57 PM
Ouch
 
I was under 100 a bit ago, but then started opening more as closing again
 
@skiwi how in the world does your computer not die?
 
@Phrancis I've got a good pc ;-)
 
shameless pimping:
1
A: Converting the first and last name to pig latin

janosAll those static variables are pointless: first, last, newName. And your non-static methods don't use these variables. Only capitalizeFirstLetter needs newName, and it really shouldn't. And the constructor setting static variables... is a very bad sign. Don't do that. You could rewrite this prog...

 

« first day (497 days earlier)      last day (3522 days later) »