« first day (254 days earlier)      last day (2474 days later) » 

12:03 AM
0
Q: Assigning initial value via getter or viewDidLoad

Justin WI've been coding in a vacuum for several years and am trying to get up to speed on best practices, in anticipation of my eventual return to employment. I'm hoping this is the best forum in which to ask these types of questions. If not, please let me know. My first question regards assigning the ...

 
12:52 AM
0
Q: Better way to check Date obj exists

Steve GreenWhen a button is pressed an animation loop is triggered. At the start of the loop I create a new time object. I also have a pause button. A problem was created when paused and then started as the Date object would be recreated each time. The variable is global and not defined to be anything. ...

 
I'm wondering what policy for voting on questions. Vote on the question text, or vote on the code? Vote on the problem (to be coded), or vote on its implementation (the code)? Upvote especially good code, or especially bad code? What is a "good question"?
 
It's really up to you. No one has to vote a certain way, but there are certain exceptions (such as not upvoting spam). If you like something and thinks it helps the site, it may be worth an upvote. If it's crap, it may need a downvote. If you're uncertain, you don't have to vote.
 
 
5 hours later…
6:08 AM
0
Q: Is my code neat and how can I do better?

GingerbeerI'm moderately new to programming in C and I'm not sure about programming practices with code; suddenly I have had fears that my code is messy and disorganized. I can read it when I come back a month later yet I'm still nervous if I'm doing anything that's considered taboo. This isn't all the co...

0
Q: Efficiently way of having synrhconous and asynchronous behavior in an application

user2809564I am working on a project in which I am supposed to make synchronous and asynchronous behavior of my client. In general, how our client will work as below - Customer will call our client with a userId and we will construct a URL from that userId and make a HTTP call to that URL and we will get ...

 
6:51 AM
0
Q: Python: How can I make my ant simulation faster

kameI was not sure if I should post about 200 lines here. I want to make this ant simulation faster. The bottleneck is at Ant.checkdistancebetweenantsandfood(). It would be great if you have some hints for some cleaner or more efficient code. I hope this is the right place to show this code. import ...

 
 
1 hour later…
7:53 AM
0
Q: Defensive Programming Type Checking

OxinaboxI have issues with dynamically typed languages, and I tend to worry about type alot. Numpy has different behaviour depending on if something is a matrix or a plain ndarray, or a list. I didn't originally have all these asserts, but I inserted them while trying to debug a type error. from numpy...

 
 
3 hours later…
10:34 AM
0
Q: How to reduce total execution time for this function?

Klausos KlausosIs there any way to reduce total execution time for the function getSilhouetteIndex? P.S. I am using weka SimpleKMeans for getting kmeans and ceval. private double getSilhouetteIndex(List<ITSPoI> _POIs, SimpleKMeans kmeans, ClusterEvaluation ceval) { double si_index = 0; double[] ca = ce...

 
11:01 AM
Can someone offer another opinion about whether 2-stage construction is, for any reason, better, using Java? see this comment
 
11:22 AM
0
Q: Error in solving cubic equations using Newton's method

Satwik PasaniI am a complete beginner to programming, and have just started python a week ago. Using the newton-raphson method, and the quadratic formula, I devised a piece of code which solves cubic equations. Here is the source code:- def deg3(a,b,c,d,g): #using newton raphson method, I designed this to...

0
Q: Follow-up: C++ 'evolutionary AI' implemention

electroLuxBased on the advice provided in my previous question, I would like to post the other source file that actually implements all the combat mechanics and also the actual evolution process. As with the previous question, I am interested in all kinds of feedback — regarding design, implementation, a...

 
 
1 hour later…
12:47 PM
1
Q: Fragments of paper

Agustin TrecenoThe exercise is explained in the comments. Do you have any suggestion? package com.atreceno.it.javanese.attic; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.ut...

0
Q: Recursion or iteration?

cookiemonsterI am practicing my recursion skills as I think I am really weak in this area. I have written the following Java class, its purpose is to reverse a string but to do it 'in-place' - i.e. no additional arrays. I have two implementations - one iterative and one recursive. Why would I choose one impl...

0
Q: Value of (just created) [assert] tag

rolflThis question has been posted and tagged with assert. It is the first assert-tagged question, and the tag appears somewhat relevant, but I am not certain that it adds any significant value. Already there are edit-suggestions for a full wiki-text on this tag. Should the question simply be untagg...

 
1:04 PM
0
Q: Optimizing a vector loop

user34888Visual Studio somehow optimizes the below code to be 20 times faster (release with optimization vs. release with no optimization). What could it be doing? for (unsigned n = 1; n != units.size(); n++) for (unsigned j = 0; j != (units.size() - n); j++) { unsigned sizesM...

 
1:43 PM
0
Q: Why is this batch file crashing to desktop, and should/how can I make it in python 3?

Sean McLainI am attempting to code a program using batch script (I know no other programming language) which saves me time rolling on multiple tables to create a random encounter for a PnP RPG. The program simulates a d100 roll using set /a nsides=100 set /a d1=%random%%%nsides+1 then checks the value o...

 
@ChrisW I vote on whether it's a good question or not. usually if there are several answers that are upvoted I consider it a good enough question that it received good answers
 
2:08 PM
0
Q: Improve my code so he don't use >50% of the CPU anymore

Long JohnI've a application which runs with two threads. The main-Thread runs in one infinity-while-loop: while (true) { try { ArrayList<Info> infoList = zabbixHandler.APIRequest(); handleInfo.handleInformation(infoList); Thread.sleep(5000); } } The second Thread, which uses mor...

 
2:32 PM
0
Q: optimizing a rollercoaster queue

SimonI am working on a haskell exercise where I have to compute the amount of people riding a rollercoaster in a day. I have the following data: the number of rides in a day, the number of seats, and the composition of the queue. The queue is a list of groups. During each ride, the first few groups ...

 
3:22 PM
0
Q: Rounding with a variable

user3190739I want to round with a variable that will change everytime. String.format("%.(cuttOff)g%n", num) Is this possible?

 
3:50 PM
Boo @Jamal
 
4:08 PM
@rolfl is that a good answer to that question?
 
@Malachi - I have only just understood the problem.....
 
I am still all about making things simple, mostly by removing junk that doesn't need to be there. like that outer loop, the way that @ratchetfreak wrote it though you would almost need that outer loop. but without that outer loop I don't think you need to do what he is talking about, unless the finished variable is never set in the loop
 
posted on January 13, 2014 by dav_i

I'm trying to create an internationalized shop as an example. In order to expose Product which has different translations for each property. Here's my attempt, implementing only the R of CRUD at this stage. void Main() { var repo = new ProductRepository(); var enGb = repo.GetProduct(1, "en-GB"); Console.WriteLine("en-GB: {0} {1}", enGb.Name, enGb.Des

 
@Malachi - the outer loop is needed since the thread needs to hang around waiting for things to happen, and, when they do (finished is false), it needs to update the traffic-lights in a loop until the activity is complete (finished is true).... then wait again.
 
@rolfl From what I have seen there is actually 3 loops in the original code. I assumed that the Run() method is inside of the first code block somewhere.
 
4:20 PM
@Malachi - no, the run() method, with a lower-case r, is the entry-point for any thread called in Java... see java.lang.Runnable. Just like the entry point for a Program is the main method, the entry point for a Thread is the run method.
 
@rolfl I see. so we really need to see more of the code then huh?
 
0
Q: flagged post without flagging

MalachiThis Question has been closed by votes Rounding with a variable I was the last close vote on this question, does that automagically flag this post when there are no comments? will it count against me if the flag is disputed or declined?

 
4:42 PM
0
Q: testing of storing session in database by 'gc' method (garbage collector)

GAURAV MAHALEi wanted to test the following code of database session storage of gc method (garbage collector) but it is quite difficult; i want to check the following code works as the following condition. if 'remember me' is enabled by user then it should delete all rows which is not active within 2 weeks ...

 
5:01 PM
@Jamal you didn't like automagically?
 
5:14 PM
@Malachi: Oh, I thought it was a typo. :-)
Anyway, I have posted an answer.
 
0
Q: Javascript classical inheritance

Ian BrindleyI've been playing around with inheritance in javascript and I'm wondering if there are any drawbacks to this method which tries to emulate classical inheritance from C based languages. Function.prototype.extends = function (parentClass) { function temp () { this.constructor = this; }; te...

 
5:36 PM
it was a joke. it's a word that I like since I first heard it!
 
You could change it back if you really want to.
 
@Jamal - some c++ insight/review would be nice for my answer here:
0
A: Optimizing a vector loop

rolflEducated guesses are: in this case, loop unrolling will probably feature in a big way, and may account for most of the 20X improvement. Additionally, with the loop unroll it may make other things like instruction-level-parallelism more effective, and even cache-line management. There are essenti...

 
I wish I had done better in my computer architecture class...
 
better than stats, or better than what you actually did do?
 
5:51 PM
Yeah, it was better than stats. I did understand a few things well, such as branch prediction.
 
0
Q: loading a combobox with an enum and binding to it

kirsten gI have the following code to load an enumeration into a bound combo box, but am not quite happy with it. I would prefer to store the actual enum value in the combo box and bind directly to it. However I cant quite figure out how to. public enum HemEnum { HemNone = -1, Hems...

 
@Jamal it's all good.
 
My new classes have started today, so I can't spend too much time here. Right now, I still have several hours until my next class.
 
@rolfl my brain is fried on this question already, my one answer is almost null now, but the other is out in left field maybe, and I think the code is messy
1
Q: What is wrong with this MySQL Trigger?

PaulI am trying to write a trigger that ranks all the entries in a table from 1 to 10 (with the maximum value having rank 10, the minimum value having rank 1, and all others are assigned integer values in between). Here is the trigger code: DELIMITER $$ CREATE TRIGGER risks_before_insert BEFORE INSE...

 
6:29 PM
@Malachi - I was about to close vote it since it was not working .... I can't help.
 
@rolfl lol I Rick Rolled you with a StackOverflow Question!!
 
Now there's a Rick Roll for you.
 
0
Q: How to write save block code like this more elegant in Ruby?

toyI have a class Creator which will execute a block code for a number of times. I'm not sure how to write this in a more elegant way in Ruby. class Creator attr_accessor :block def self.create(&block) @block = block return self end def self.for(number) 0.up...

 
@Donald.McLean gotta pause my dubstep
kind of surprised that someone actually knows what a rick roll is....lol
 
I think the letter from the govt. workers during the shutdown was the best .... hang on....
 
6:37 PM
@Donald.McLean 72,765,049 views. that is sad
what are you talking about @rolfl?
I made it 2/3 of the way through the song.. back to dubstep
 
@Malachi I have kids. They're keeping me hip to the new grooves. :-)
 
I thought it was a rick-roll, but it was a different subliminal message.
 
@rolfl that is pretty funny
 
6:49 PM
keep an eye on my StackOverflow profile for me putting up new answers!!!
 
hi guys!
 
@retailcoder Hey what's up?
 
listening to dubstep
Looks like @Donald.McLean's dubstep link planted a seed eh?
I answered this one, got 2 more answers but the only votes on there are all mine:
0
A: loading a combobox with an enum and binding to it

retailcoderNaming HemEnum, or any enum name that ends with the word Enum, is a bad name for an enum. Enum types should not contain the word "enum" in their names. Similarly, HemEnum values should not contain "Hem" in their names either. Your HemEnum should therefore read something like this: public enum ...

@Malachi :)
2
 
This is looking like answer-invalidation:
 
@Jamal it is
I removed 3 seemingly use-less methods. The question has been updated, take a look if you like. — www.arcmarks.com 33 mins ago
 
6:59 PM
I'm not sure if I should take the time to determine where to rollback to. It may have to be determined by comparing the answer and revision timestamps.
 
0
Q: Is is appropriate to post a "Please review my entire application" question on Code Review?

darwishI have written a small application in Haskell and I wish to get a code review. Since I'm inexperienced, I cannot really write a bullet list of things I'm not satisfied with in my code. It would just be helpful for someone to review the entire application, as any kind advice is welcome. Is it ap...

0
Q: Game of Life implementation in Haskell

darwishI've written a small Game of Life module in Haskell, as well as a small testing application. I'm relativly new to the language so any kind of comment about the code is welcome. The most important comments for me are comments about efficiency of the code, and of course bugs. I would also be happy ...

 
ok back to work...
 
@retailcoder Hell no! I got home from work 2 hours ago!
 
lol. it's 2PM here!
 
@Jamal I don't think this and this needs to be FAQ-tagged. They're not asked a lot, and when they are they are probably more often asked on MSO/MSE.
 
7:09 PM
@SimonAndréForsberg I was going to second your close vote on the meta-question, but there's no accepted answer on the "dupe-of" candidate..
^^^ me agrees
 
@Jamal Perhaps make this or one of it's possible duplicates a FAQ post instead.
@retailcoder 8 pm here :) And dark and cold and snowy :(
@retailcoder I was originally looking for another dupe-of candidate, I think there are other possible duplicates out there. I used the first one I could find though. And it doesn't need to be an accepted answer to be marked as dupe :) 10 upvotes says enough I think (although there could be a better answer to that question)
 
@SimonAndréForsberg: Okay, I can untag them.
 
@Jamal Thanks. Good pet-monkey :) No wait, that's @rolfl...
 
@SimonAndréForsberg: The post you've used with your close as duplicate is already faq, so this one won't need it if it is closed.
 
0
Q: A package for basic utility functions - v2

www.arcmarks.comThis utility package is part of the arc library. I'm happy with my naming conventions as un-conventional as they may be. Looking for general balanced feedback. /*************************************************************************************************** **ARC Goal: - to create a small...

 
7:18 PM
But there's also this:
8
Q: What if we have an entire (small) application we want reviewed?

zeelI asked about this on Stack Overflow, and was referred here (to code review) though I still think it may be out of scope for CR. http://stackoverflow.com/questions/12749863/where-can-a-n00b-developer-go-to-get-feedback The question is: "I have written my first (complete) program, how can I (no...

 
@Jamal That one could also need a better answer. It depends on the size of the application I would say.
 
7:33 PM
Wow, I was about to say that 7 of my 10 meta-questions have been favorited, but none of my real Code Review questions has been favorited by anyone. But then I just noticed... five of my six CR questions has been favorited
 
@Malachi this one can be deleted:
please add your comment to your answer, makes for a better review. — Malachi 41 mins ago
 
@retailcoder done
 
7:49 PM
0
Q: UML diagram for an existing implementation

guitar_freakI have some code, which I want to present in UML, but I've stuck at one point. Let me tell you something about code's functionality. I have a workspace in which I can place some Components, select them, delete, add new, move etc. I can also connect them according to some rules (there are differ...

 
Ugh. I give up. Just stumbled upon this line of production C# code:
2
goto MoveOn;
Here be dragons
 
@retailcoder in C#?
 
I thought there wasn't even a goto statement in C#... apparently there is!!
"Don't change it" he says. "It's working" he says. (mind blows)
 
user image
4
 
^^ My exact thoughts @Jamal, you're reading my mind!!
 
8:02 PM
Gotta love xkcd!
4
 
8:27 PM
@retailcoder Wow, and I thought the Java code I am working with at work was bad!
 
@SimonAndréForsberg I was telling the monkey the other day, this is shit code. He said in a few years someone else is going to say the same about my code. Yeah, right.
5
 
Promise, it will be true.
 
A few examples what I have to suffer with at work:

`Log.error("This can not occur.");
code = -7;`

`Thread.sleep` in a synchronized method.

`while (comparing two ints that is never changed anywhere) { Thread.sleep(500); }`

An interface with **110 methods defined**, all but one are declared with `throws Exception;`
 
BUT THERE WILL NOT BE ANY FREAKIN' GOTO
3
@SimonAndréForsberg you're lucky. I have a method that's like 20 screens high, cyclomatic complexity through the roof and redundant like it was written by a 8 year-old.
 
I calculated today that what I work with is a system that consists of 6 projects, 25 packages, 198 classes. Unknown number of lines.
@retailcoder Bah! Trust me, I got that too! Remember that the interface needs to be implemented somewhere!
 
8:33 PM
My code the code I'm stuck with is worse than yours :p
@SimonAndréForsberg throw new NotImplementedException(); // here you go, method implemented!
 
My favourite by far is:

    private static final IllegalArgumentException IAE = new IllegalArgumentException("Invalid argument");

    public Something method(Argument1 something) {
        if (something.isBroken()) {
            throw IAE;
        }
    }
And this IAE was use in many, many methods in the class.
 
^^ throws NPE if something is null :p
 
@rolfl How do you format code multiline like that?
 
Ctrl+V
 
You type multiple
Lines, then hit the 'Fixed Font' to the right
 
8:36 PM
@retailcoder Can't, I'm writing directly here.
 
                DoorInfo = DoorInfo + " Type='S'";
                if (rdoM50.IsChecked == true)
                {
                    DoorInfo = DoorInfo + " SlabType='" + SlabType + "' ";
                }
                else if (rdoCLOR.IsChecked == true)
                {
                    DoorInfo = DoorInfo + " SlabType='" + SlabType + "' ";
                }
                else if (rdoCONE.IsChecked == true)
                {
                    DoorInfo = DoorInfo + " SlabType='" + SlabType + "' ";
 
(next to Send, and UpLoad)..... fixed-font only appears when you have multiple lines.
and then it shows up
 
Some of those implementations of that interface goes like this:

if (str.equals("something")) {
    try {
        foo.something(someargs);
    }
    catch (Exception e) {
         Log...
    }
}
else if (str.equals("someotherthing")) {
    try {
        foo.someotherthing(someotherargs);
    }
    catch (Exception e) {
        Log...
    }
}
(repeated 100+ times!!)
 
See, my text area looks like (with a shift-enter here->
You got it.
 
My instinct is just: use reflection damnit!
@retailcoder Repeat that on at least 4 places and then we can start talking.
 
8:38 PM
@SimonAndréForsberg noticed all cases do the same thing??
 
coding battle. like a rap battle only he who has to deal with the worst legacy code wins
3
 
lol the best part, is that it's WPF in C# 4.0 ...I wish it were VB6 code so they'd have that excuse...
@SimonAndréForsberg and it is repeated ...I haven't counted how many times though.
 
@retailcoder the only difference of the cases is that they call a different method, with the same name as the string value (REFLECTION, WHERE ARE YOU?), and convert an array of arguments to the correct types.
 
So you're scrapping 80% of your code base in 20 minutes?
 
@retailcoder Alright, I'll have to check for more code crap at work tomorrow.
 
8:41 PM
I somehow wish it would be on-topic to post someone else's code on CR. You'd cry.
2
 
@retailcoder No, the worst part is: I am not allowed to clean up the crap!
My job is just to fix some bugs and add some new features. I try to clean up the crap that is related to the thing I should work on.
@retailcoder I wish I was allowed to show you exactly the code I am working with. You would too.
And oh, did I mention abusing the singleton pattern like crazy?
 
Hey at least you've got patterns! I'd be happy with even an [anti-] one!
2
I've got concatenated inline SQL (and XML), running with a connection that's never closed, never disposed.
 
@retailcoder Alright alright, you win for now! But I will return!
I gotta sleep. New day tomorrow. Must - find - horrible - code...
6
 
9:00 PM
0
Q: best way to apply across an xts object

ricardoAs xts objects are arrays, getting apply functions to work is a little tricky if you want to preserve the dates. For example, take the xts object xx below: xx <- xts(replicate(6, sample(c(1:10), 10, rep = T)), order.by = Sys.Date() + 1:10) Say we wish to apply a function to each co...

 
9:11 PM
@rolfl my boss knows COBOL!!
7-hour dubstep mix finished => workday is almost over :)
5
 
9:29 PM
0
Q: Python converter: number-to-English

Jeff GohlkeSo I wrote this function to convert a given number to its interpretation in the English language as part of the Project Euler exercises. It works fine, but I sense that it's rather sloppy and inelegant, especially for Python where many things can be done quickly in a couple of lines. Any feedba...

 
9:44 PM
@retailcoder please share
what time zone are you in anyway @retailcoder ? Central?
 
0
Q: A Package for Basic Utility Functions v2

www.arcmarks.comThis is the next version of a utility library: Here are the changes I've made. When throwing an error I throw an error object instead of a string. I removed one utility function that seemed out of place. A more thorough explanation of how it all works together at the top. /*******************...

 
10:22 PM
0
Q: Pygame/Python Any tips on speeding up this sandbox game?

Sam TubbI am working on an app, a virtual sandbox of sorts. Alot like the powder game. The problem is, when working with an app, you must deal with hardware limitations. Don't get me wrong, the speed isn't like 2 fps or anything, but I would just like for someone to look over the code and point out any s...

 
10:54 PM
I'm surprised this answer didn't get more upvotes...
2
A: Fibonacci sequence in C

syb0rgWhat you did well on: Your program is easy to read. You are allocating memory. You prepare for some corner cases. Things you could improve: You are returning 0 when your program runs into a problem (except in one spot where there are too many parameters being entered). return 0; 0 is t...

 
pimp, @syb0rg, but your recursove fibonacchi is wrong ;-)
The rest scored +1 anyway.
 
@rolfl Wrong?
It compiled and worked properly though...
What do you mean?
 
Let me think..... it's just an odd algorithm....
 
The memoization part?
I had to research that and add it in after my initial solution was too slow.
 
No, it's OK,... sorry for the panic attack.
It is a different-than-normal approach.
(maybe different for C folk as opposed to the Java stuff I normally see).
 
11:05 PM
@rolfl Phew!
 
@syb0rg - part of the confusion was because you recommended recursion.... which is a very poor option, actually.....
It made me think 'factorial', not fibonacci
The whole thing with memoizaton is redundant given the output is supposed to be in an array.... which, in itself, is the memoization you need.
Dinner's up, gott a go.
 
@rolfl The reason I recommended it was for practice, not efficiency.
 
11:39 PM
0
Q: A custom Undo Manager

Phil ValloneI am working on building a UndoManager in c#. The concept is to store events and property changes in a Stack < Action < T > > instance. I believe it is working, but I am also looking for peer review. What can I improve, or do you see any bugs? Your feed back in appreciated. public abstract clas...

 
11:51 PM
0
Q: why c++ produce zero

Acess Denied#include<iostream> using namespace std; int main() { int Elder = 0, Young = 0; float shares = 0.0 , aMount = 0.0; cout << "Enter Amount: "; cin >> aMount; cout << "Enter Age Elder: "; cin >> Elder; cout << "Enter Age Younger: "; cin >> Young; cout << Elder <

 
@Jamal Isn't ^^^ off-topic?
 
Yup. Got it myself (I wanted to edit it anyway).
 
Every post is getting an answer from @ChrisW so far.
Well, almost every.
 
That is nice, except off-topic questions shouldn't get answers, especially if they're closed for not including code.
 
@Jamal You should migrate it to SO.
He had the right answer.
 
11:59 PM
It looks like the OP found it to work. I'll just keep it closed here. They probably wouldn't like it anyway.
 

« first day (254 days earlier)      last day (2474 days later) »