« first day (735 days earlier)      last day (3580 days later) » 

00:00
There are 1352 unanswered questions
Sometimes things just "catch hold".
@Duga :(
The graph for my blog looks like that. Turned around Dec.
Great answer: Guessing a number, but comments concerning http://codereview.stackexchange.com/a/90113?atw=1 #java
@rolfl ^^
comments concerning what?
I'm not sure how to read that title
00:03
Concerning as in are a concern...
When I edited the title I was not sure what to call it....
the original title was wrong, I tried for something intriguing.
Ah, that way
> comments make plain what the code does not tell us already
good code seldom needs comments
thus....

good code seldom needs comments
good code must make plain what the code does without the need for additional explanation.
Don't look at me, I'm fourth language English
me no good speak
2
Thnks santas ;-)
00:05
1
Q: Handling double click issue on Javascript

Robin Carlo CatacutanI've been doing a lot of form submission using Ajax now and being used to it than having a normal submission. What's been troubling me is that I always ran with a double submission issue when the user clicks twice the submit button to make sure hey hit it. One way I handle it is by using a flag ...

I haven't rep-capped since the beginning of March! :O
It's okay @JeroenVannevel neither do I.
@simon - my goal is legendary, not actually to get #1 on rep, but they seem to be linked.
@rolfl No shit, Sherlock!
It's been hard to find time for answering though, and that's making it hard to cap.
I really was not expecting it at all today
00:07
One is about reputation, the other is about reputation...
Patience grasshopper.
@SimonAndréForsberg it's ok, taaaaaake yooooour tiiiiiiime
So, Battleships... anyone started yet?
starting visual studio
@Mat'sMug So that you can catch up!? Pffft! I don't think so!
00:11
-1442
I think I will make a server for this challenge, so that all you others can challenge each others. I have a quite flexible server working already which I really should post for review, I will just need to add some Battleship-specific stuff to it, but that shouldn't be a problem.
Hmmm...
@SimonAndréForsberg That actually sounds really fun
And then, if I have time, I will make a client implementation in either Java, Groovy, or Brainfuck :) (likely Groovy, as I have never used that before)
one server setup which each client connects to and they can battle it out
though that should probably have been done beforehand so the server's interface was known already
00:13
@JeroenVannevel making a server? or connecting to it and beating the crap out of everyone else?
I don't do frontend
I'm talking backend
I can do the server..... I need an excuse to resurrect the Bluemix StackMonkey account
What am I, a 25y old coffee slurper on a mac?
4
@JeroenVannevel I can have the server up within 24 hours. (within 1 hour if I wasn't so freaking tired)
Oh, that would be far faster than I could ^^^
00:14
I'm not going to participate myself (front- or backend) so don't hurry for me
But if there's something similar another time where I do have time, I might chip in
I might write a version in C#, but not sure.
@Hosch250 Considering COBOL instead?
@SimonAndréForsberg No, considering not doing it.
yesterday, by rolfl
traitor.....
00:24
I want to get my app done, I want to get my calculator done better...
I want to write a tree in C++ to learn about memory management.
0
Q: Unity and an IoC for Settings

Hosch250After a somewhat lengthily discussion in the chat room, I have set up an IoC container with Unity to store my settings in. This is my static IoC class: public static class IoCContainer { public static IUnityContainer Container = new UnityContainer(); } In App.xaml.cs: IoCContainer.Contai...

Supper's on, see you.
Ah, you also feel that there's so many things to code, @Hosch250?
I am back. House is still on it's foundation. Watching people from the helicopter cam on the news drive into flooded intersections. Will never understand.
I've started my battleship game. Much more interesting than the first glance.
@jdphenix People will be people.
@RubberDuck That's the spirit!
For the next Community Challenge, we should do the multiplayer version of Minesweeper, "Minesweeper Flags". Anyone who manages to beat my AI gets a donut!
I'll go to bed now so that I can get a Battleship server up for you tomorrow. Nighty night!
2
Q: Unity and an IoC for Settings

Hosch250After a somewhat lengthily discussion in the chat room, I have set up an IoC container with Unity to store my settings in. This is my static IoC class: public static class IoCContainer { public static IUnityContainer Container = new UnityContainer(); } In App.xaml.cs: IoCContainer.Contai...

00:31
@jdphenix There's this Australian fire-truck......
It's noisy (siren).
It can be done ..... ^^^ ;-)
@SimonAndréForsberg Exactly.
@rolfl Wow.
You'd think their engine would shut down.
It shut down the siren, which was nice ....
But, trucks like that have a 'snorkel'. My dad has one on his 4x4 .... not that he ever used it, but it's there in case he ever does.
Just so long as the engine is running, and the snorkel is above the water line, they;ll be fine.
(but wet).
Oh.
Maybe they dried out by the heat of the fire they went to fight.
00:47
@SimonAndréForsberg I want a donut!
I almost always hit a mine inside the first couple turns.
0
Q: An Implementation of a Counting Bloom Filter

SuperJedi224Alright, I'm working on writing a java class library which includes the following implementation of a counting bloom filter: package sj224.lib.util; import java.util.function.Predicate; import java.util.Random; public class BloomFilter<V> implements Predicate<V>{ private final int size; ...

You know, I think I should register an instance of my MenuItemManager in my IoC, instead of using a static class.
01:18
@Hosch250 you need to register everything with your IoC container, and eliminate everything static.
especially that IoCContainer static class.
kill it with fire.
0
Q: How to expand a string to a certain length?

KeyBoredI wrote a function for repeating a string to a certian length. For example: ExpandString("Test", 11); // output: "TestTestTes" Are there any optimizations or fixes can be done to this function? private string ExpandString(string str, int length) { if (length <= str.Length) return str...

@Mat'sMug But @JeroenVannevel told me to make it static!
@JeroenVannevel????
There must be only one instance of the IoC container in an app
either you make it static or you store it in a single location (like the entry point)
I tried storing it in the entry point at first, but I couldn't access it.
01:29
making it static isn't a good option. it makes it way too easy to access it from just about anywhere. that's a service locator.
you don't. access it.
it accesses you.
the Hollywood Principle
OK, just reading your answer.
> Don't call them, they'll call you
OK, so I have my constructor like: Constructor(ApplicationSettingProvider<Theme>), and just call it like Constructor()?
And the IoC just sticks it in?
it's the container's job to resolve the dependencies. all of them.
01:34
you don't ever call a constructor yourself
Huh?
the container calls every constructor it knows about.
Oh, I see.
This is getting weirder and weirder!
it's inversion of control
It is living up to its name, alright!
01:35
you take the control you typically have on your dependencies, and give it to your IoC container
It is turning my world upsidedown!
you have no idea
That's for sure!
it's a completely different ball game
you'll never want to write tightly coupled code ever again.
01:36
and whenever you do, you'll feel like you're doing something dirty and wrong.
like this Rubberduck thing
Before, I used to keep track of every variable manually.
I could trace every variable throughout the entire app.
This is going to be weird.
you're going to be coding against interfaces
not a single concrete type is ever going to be instantiated
What about my abstract class?
For my settings, I am coding against an abstract class.
abstract classes can't be instantiated
01:39
abstract classes are an abstraction, just like interfaces. if your IoC container can deal with them, they're fine.
It appears it can.
BTW that's where ReSharper's Go to implementation navigation feature comes into play
I don't need that, VS has it built-in.
Go To Definition and Find All References both.
01:40
it used to only Go to definition
no. not definition. that will only ever take you to an interface
It takes me to my classes just fine.
you'll want to browse implementations of your interfaces
Oh, OK.
yes but the only place concrete types will ever be referenced, is in your composition root's setup code.
I keep the interface and implementations in a directory together.
01:43
if that helps...
Why wouldn't it?
That way, I know where they all are.
I'm just saying, if you do IoC right, vanilla VS is going to be frustrating.
at least with a medium-to-large size app
With ReSharper in, VS could hardly start.
It is fast enough without it, I don't know why.
come on. my laptop is 6 years old and runs VS2013 Community with R# 9.0
I don't know why, but it was so slow it took a minute to open.
01:45
R# caches a lot of stuff. startup does take a bit longer
More than a bit...
I'll put it back in if I have trouble.
in a DI project, when R# doesn't mark a concrete type as "never instantiated", I know I've fucked up somewhere.
don't mind me, I'm literally sold to R# - I've used it for so long VS without it feels as naked as the VBE without Rubberduck.
you'll be proud of what you end up with
I am proud of my service locator too.
It is 100 times better than before.
Before, I was manually passing everything in, and I couldn't always do it, so I would have different settings instances...
01:50
are you registering anything other than those 3 classes?
No.
You can see for yourself on GitHub:
I love it when a plan comes together.....
.... where's my cigar, though
@rolfl What plan came together now?
And don't smoke - it'll shorten your CR life.
01:51
Well.... I discovered a trick, that I think may impress a mod on the workplace..
Huh?
Well, there was this post earlier....
lol wrong site
4
Q: TDD svino Problem #4 - largest value from concatenated integers?

enderlandFrom this blog post: Write a function that given a list of non negative integers, arranges them such that they form the largest possible number. For example, given [50, 2, 1, 9], the largest formed number is 95021. I did this in with two tests and using a TDD style. I am pretty unfamiliar ...

and, I essentially reduced:
@enderland!
01:53
    private List<Integer> sortIntegerList(List<Integer> input){

        for (int i = 0; i < input.size(); i++){

            for (int j = i + 1; j < input.size(); j++) {

                int a = input.get(i);
                int b = input.get(j);

                if (b == getLargestLexiographcal(a,b)){
                    input.set(i, b);
                    input.set(j, a);
                }
            }

        };

        return input;

    }

    int getLargestLexiographcal(int a, int b){
to just
got busy lately, but he used to hang out in our VBA chat :)
    private static final class LexiVal implements Comparable<LexiVal> {

        private final String value;

        public LexiVal(int value) {
            this.value = Integer.toString(value);
        }

        @Override
        public int compareTo(LexiVal o) {
            final String usthem = value + o.value;
            final String themus = o.value + value;
            return themus.compareTo(usthem);
        }

    }

    public String largestNumberFromList(List<Integer> input){
        return input.stream().map(i -> new LexiVal(i)).sorted().map(x -> x.value).collect(Collectors.jo
Java8?
Well, yeah, but, in reality, I reduced it to just:
    public int compareTo(LexiVal o) {
        final String usthem = value + o.value;
        final String themus = o.value + value;
        return themus.compareTo(usthem);
    }
Occasionally, I independently discover a neat trick. I am sure someone has already written a paper on this, but I don't search for those things, I just savour my ingenuity ;-)
so... you discovered string.compareTo?
ah, just noticed discovered it was a CR post...
> There's a typo in a method name... I know that's a silly thing to point out, but it is the first thing I saw. My spelling (actually, my typing) is often criticised, and as a result I am sensitive to these things.
is it convention to name a comparator in YELLCASE?
02:07
It's convention to name constants in YELLCASE, yes.
there's no const keyword in Java?
I mean, a static final is a "constant", but it's not a const... but I'm thinking in C#
interesting
64
A: Why is there no Constant keyword in Java?

Gunslinger47Every time I go from heavy C++ coding to Java, it takes me a little while to adapt to the lack of const-correctness in Java. This usage of const in C++ is much different than just declaring constant variables, if you didn't know. Essentially, it ensures that an object is immutable when accessed...

> Interestingly, the Java language specification regards const as a reserved keyword — i.e., one that cannot be used as variable identifier — but assigns no semantics to it.
02:23
@Mat'sMug So, thinking about your IoC thing, how would I handle the tree at the bottom of this page?
I keep thinking GitHub oneboxes.
Would it even be possible to give each one the right values and get it in the right place without ever calling the constructor like that?
@rolfl Hmm, isn't the word "lexicographic"?
@Hosch250 who needs to have an instance of this MenuItemManager class?
@Mat'sMug Everyone.
That is where I keep the menuitems ordered nicely, and retrieve them as needed.
not true. a bunch of viewmodel classes perhaps, but not everyone ;)
Each menu item also contains search keywords, if applicable, that the future Search page will use.
Well, yeah, most of my VM's.
Not even all my VM's, actually.
so, every VM that needs it, needs an instance passed through its constructor
02:32
OK, that isn't the issue.
It is the tree I build at the bottom.
Like this:
.AddBranch(0, new MenuItem(resourceFile.GetString("OneNote"), typeof(Tutorials.WindowsData.OneNote), Menus.WSOneNote, AppVersion.OneNoteWStore, resourceFile.GetString("SearchWSOneNote")), new Tree<MenuItem>()
    .AddItem(0, new MenuItem(resourceFile.GetString("WSNotebooks"), typeof(Tutorials.WindowsData.Submenus.Notebook), Menus.WSOneNote, AppVersion.OneNoteWStore, resourceFile.GetString("SearchWSNotebooks")))
    .AddItem(1, new MenuItem(resourceFile.GetString("WSSections"), typeof(Tutorials.WindowsData.Submenus.Section), Menus.WSOneNote, AppVersion.OneNoteWStore, resourceFile.GetString("
So, what about all those new MenuItem()s?
ah, I see.
How do I use IoC with them and make sure each instance goes in the right place and has the right values?
Or, is that one of the places where an IoC won't work?
your MenuItemManager apparently needs a MenuBuilder
With my limited experience, I am very happy with how that is now (especially after the N previous implementations).
OK, so what will the MenuBuilder do?
Build that tree?
02:35
OK, and how will it get the right values, and how will it know to insert each item in the right place?
And why didn't I learn about IoC until just now?
Why did it take 2+ rewrites for me to learn about this?
Not your fault, for all you knew, I already knew about it.
what happens if you call Fill() twice?
That is definitely an Uh-oh.
That is why I don't do it :)
you could check first and throw an exception, or clear the tree first to ensure it's empty
02:39
I should probably clear the tree.
depending on whatever makes more sense
No, I will do neither.
Fill() is void, so I will just return.
if (tree != null)
Or something.
private Tree<MenuItem> dataTree = new Tree<MenuItem>();
it's never null
Yeah, I'll have to check if it is empty.
Here, I know.
so yeah, I'd move that concern into its own class, perhaps a MenuTreeBuilder
02:42
Yeah, I see what you mean.
But I still don't see how the IoC will help.
I'm still calling constructors.
that'll cut about 200 lines from the class
IoC extracts the concern of creating objects into a single spot, right
but it's not always possible to do that
if(dataTree.GetChildren().Any())
{
    return;
}
That took care of it.
sometimes you don't have everything you need at startup to create an instance of something
I just put it right at the top.
that works
02:44
I see, thanks.
the solution is to extract the object creation into an object that's responsible for creating objects - a builder, or a factory - and you constructor-inject that as a dependency
I see.
one of the most useful patterns with IoC, is the Abstract Factory
So, now I need to learn what an Abstract Factory is.
I feel like when I was in chapter 6 of Bjarne Stroustrup's book - very small.
but correct me if I'm wrong, nothing in this tree depends on anything that's not known at startup. right?
02:46
Well, I don't know.
I don't have any data structures of it, but I definitely know what I need before startup...
My app doesn't know it, but I do.
put another way.. does the content of the tree depend on the state of the app?
Yes, definitely.
Wait, no, definitely no.
The tree is where I store all the data for the rest of my app.
I was going to say, I don't see where or how then ;)
02:48
It does not depend on the state of the app, and might as well be constant.
good.
then it can be part of the composition root
So, it doesn't need the IoC?
Or it does?
I should build it in the root, and I need to pass the MenuItemManager class into the VM's.
Oh, and I need to build some ICommands and get the button clicks out of code-behind.
when I said that the concern of creating objects is the concern of the IoC container, I was generalizing a little - it's really the job of the composition root
OK, so I don't use the IoC to build that tree, but rather build it from the App.xaml.cs?
well.. I'd extract that method into a MenuItemTreeBuilder : IMenuItemTreeBuilderclass, and inject an IMenuItemTreeBuilder into the MenuItemManager
02:52
That makes sense.
so that the MenuItemManager still controls when the tree gets built
Yeah.
it just doesn't build it itself
Now, I tried to make an interface to control a class of a bunch of fields for me.
It didn't work.
I suppose it is a bad idea to build a class with only fields?
indeed.
fields are data
02:53
Alright, I ended up not doing it anyway, sort of.
Now, MenuItem is a class of fields.
But the one I was thinking of I didn't do.
But, that data all resides together.
What about that?
MenuItem isn't made of fields, those are properties - it's essentially a POCO
Oh, OK.
Well, properties then.
The interface didn't like it.
Oh, and sorry, but I need to do the dishes.
BBL.
np
interface IMenuItem
{
    string Title { get; }
    Type Page { get; }
    Menus Menu { get; }
    AppVersion Version { get; }
    string SearchKeys { get; }
}
did your interface look like this? ^^
03:09
This appears to be off-topic because it's about making functional code better in some fashion. It would fit better on Code Review, so I've flagged for migration. — Nathan Tuggy 19 secs ago
03:47
0
Q: Guidance on a more elegant way to approach this userform than Do…While and Try…Catch? VB.net, userform that calculates gas mileage

DiogenesI created a project for a programming class that asks you to make a userform in Visual Studio that calculates mileage, given the user inputs of gallons of gas consumed and distance traveled. The code does its job fine, but I can't help but feel that my use of Do...While and Try...Catch statements...

04:01
You'll probably get a better response for code review on codereview.stackexchange.comuser2357112 35 secs ago
0
Q: count the number of even and odd numbers and display it in console.

Amy JaneI have to Create a program that will accept 5 input numbers from the use. The program will count the number of even and odd numbers and display it in console. help me please btw this is my work, but I dont know how the count the number of even and odd numbers will display in console. (this is ju...

Ahh, that is how you do that?
So, to what extent should I base everything on an interface?
Should my MenuItem have an interface? What about my Tree?
if you're only ever using concrete implementations, an interface is useless.
cough R# tells you that cough
use an interface when you're implementing a class that's a dependency of another
04:15
OK.
well, an interface or an abstract class, really.
One more question (I hope):
the idea is to code against abstractions - the core principle of DI is "depend on abstractions, not on concrete types"
What good does it do to do something like this:
Constructor (ApplicationSettingProvider<Theme> theme)
If the data provided is garbage if the ApplicationSettingProvider<Theme> isn't really a ThemeSettingProvider?
I didn't mention it in my answer, but I don't like that generic base class
I'd go with some ISettingsProvider
04:17
OK.
But still, it has the same problem.
I expect the data provided by a ThemeSettingProvider to set my theme, and if I don't pass one, but a different ApplicationSettingProvider<Theme> implementation, it will be garbage.
0
Q: Stuck framing validation condition in python

Siddharth DubeyI think this question can be answered by most python users and is quite general in terms of knowledge but for me I can't figure it out. This is the code: if ssid in net and p.addr2 not in clients: count +=1 get_oui(p.addr2) net.append(...

what's Constructor standing for?
That is basically MainPageVMs constructor, or something.
have you considered something like..
interface ISettingsProvider
{
Theme Theme { get; }
FontSize

..meh nevermind
not a good interface
Yes, I did.
04:24
you need to find an abstraction that doesn't need to change
rather, that resists to change
But, that is why I use enums.
I don't know what to do here.
that ISettingsProvider would be a bad one because it would need to change if a new setting type comes up
What I have doesn't need to change, everything is handled in the new implementations.
But, I was just thinking that if I ever have two implementations with the same type (Theme, for example) it would break.
until you realize you need a new setting for SomethingElseSetting
But, that would actually be doing it wrong - why would I ever want two implementations of Theme? I should have a new enum, unless it is doing the same thing, upon which I wouldn't want a new one.
And actually, because it would be using the same enum, it would actually not break.
04:27
the thing that sucks is that enums can't be used with generic type constraints
@Mat'sMug No, then I just write a new implementation.
And, I actually got around that by using ApplicationSettingProvider<T>, where T is the enum.
yes, but you can't enforce it, so ApplicationSettingProvider<int> is valid
Yeah, so what?
Just as long as I don't ever accept it in a constructor or something...
the idea of generics is to ensure type safety - ApplicationSettingProvider<T> where T : ISetting would be more like it
Well, I could just not base it off an abstraction, but that would be stupid too.
04:33
I'd try to come up with a design that allows me to easily extend the settings I can have
So would I, but I'm stumped.
I'm too tired to think about it right now ;)
Me too :)
05:01
TTGTB
Wow.
06:44
0
Q: A simple fork with an ugly waitpid

Cengiz CanThis is my first take on fork, exec and waitpid. I didn't quite understand why I had to use a while loop with waitpid. I discovered that waitpid sets errno to EINTR which is translated to #define EINTR 4 /* Interrupted system call */ And I saw a suggestion in comp.unix.programmer ar...

 
1 hour later…
07:46
Monking
0
Q: performance of summing one value from join of three tables

BrDaHaI have a table I want to get a sum of information on, but the value I need to query on is in two different tables. The one with values I need to sum is say, kudos, which has a value indicating +1 (1) or -1 (2) in the Action column, which is associated to the discussion it's on, or the comment i...

08:27
0
Q: Voxel Engine optimization

NeomexI am writing custom voxel engine in java with jme3, but it is very slow, for simplicity I am rendering cubes instead of faces, also border detection messes up output mesh (doesnt draw cubes on chunk edges). I would be very thankfull if someone with more skill looked into it. Main public class ...

0
Q: checkbox working only onchange, I want for working checkchange

user73226 <style> .tlusta {font-size: large; font-weight: bold;} .cervena {color: red;} .modra {color: blue; font-weight: bold;} </style> <form> <div id="pokus" class="cervena tlusta"> Text, slova, věty, souvětí, odstavce... </div> <input id="cudlik1" type="checkbox"...

08:42
0
Q: Find Row with Max zero

Mohan RajTo find the row with max zero Matrix will have either 0 or 1 in sorted manner. public static void main(String[] args) { // TODO Auto-generated method stub int[][] inp=new int[][]{ {0,0,0,1,1}, {0,1,1,1,1}, ...

 
2 hours later…
10:13
Monking
Monking all.
Monking @skiwi @Heslacher @rolfl
Anyone french-speaking in here?
hey @rolfl hey @skiwi hey @Mast
@rolfl I can only order beer using french. Does this help ?
Nahhh....
translate: le fichier contenant les parametres n'existe pas
(from French) the file containing the settings does not exist
10:23
looks fine to me
parametres is not necessarily settings though, it can be any input required
but it seems correct
What abour: je suis en train de développer une application web,j'ai un fichier File.xml contenant les parametres de connexion a la base de donnée postgre:,,,,,,le quel j'ai ajouté au dossier bin apache.jai une classe de connexion a la base de donné utilisant les données de fichier xml pour se connecter a la base.
@Hosch250 The nice thing about Minesweeper Flags is that you don't die when hitting a mine. In fact, hitting mines is the goal of the game!
And Monking
Hey Simon
I'm not sure, but I think this guy wants us to improve the tour...
@SimonAndréForsberg: short of advising an appropriate place for debug requests on CR home or the top of the tour, consider mentioning CR not being about debugging there (I did find it screens down the tour, which starts out pretty generic). — greybeard 4 hours ago
Breakfast now, then Battleship!
10:29
hey @SimonAndréForsberg
I need to post my "How to get the best out of Code Review" meta question to Stack Overflow.
-1
Q: Add XML file to Apache and connecting to PostgreSQL

Asma TouihriI am currently developing a web application, I have an xml file named File.xml containing PostgreSQL connection parameters: login, password, ip_address, pilote, port, bdd. . I added this file to the bin folder of apache. i have class.jav which use the parametrs of xml file to connect to data base...

@rolfl s/Stack Overflow/Meta Stack Overflow/
don't post a question, then disappear
ah, it used to be tagged with jdom, that's why you found it
@rolfl Is there any rule on SO about what language your code should be? The accompanying text should be in English of-course, but I'm not going to help someone who refuses to write his code in English.
10:48
12
Q: Why doesn't it say anything about English in the help center?

Simon André ForsbergI saw this French question today on Stack Overflow and I started thinking: Are non-English questions acceptable on Stack Overflow? After a few minutes of research I found this (from the StackOverflow FAQ), this and this. After having read those, I am under the impression that StackOverflow prefe...

Now: Battleship

« first day (735 days earlier)      last day (3580 days later) »