« first day (381 days earlier)      last day (3622 days later) » 

12:04 AM
Hi all. Quick question. Is the CR SE kind of for code that works, you're just more interested on how you could have coded it better?
 
@TaylorHuston Exactly
 
Huzzah! That's what I thought, just wanted to make sure. Isn't there a fear that people are going to abuse this to get free homework help?
 
That's a possibility, but of course the copy/paste questions will be trashed. Now, if we get some attempted code, and it's suggested that the OP hasn't tested the code at all, then it could still be closed.
 
12:35 AM
0
Q: Is this class too big already and can/should it be broken down?

SchongeI have recently undertaken a project for programming practice based on a simple text editor. Normally this kind of thing wouldn't bother me but ever since I completed a software architectures module in college I question everything about how my code is and should be formatted! (probably a good th...

 
 
2 hours later…
2:21 AM
Can I get some opinions on this site design?
 
3:15 AM
It looks about as white-efficient as google... which is a good thing, right?
 
@rolfl I see you haven't downvoted this answer yet.
7
A: Increment up the build number in AssemblyInfo.cs on every build

200_successDon't try to be a badass cowboy. ☺ Stuffing everything onto one line of code is trying to be badass. You could improve clarity simply by adding whitespace. Producing an incremented version number by careless string processing is trying to be a cowboy. I suggest introducing some kind of abstr...

 
Apparently I have double standards.
 
> +1 for "badass cowboy"
 
^^^^ that was my thinking at the time.
 
(seriously though, I know no C#)
 
3:25 AM
Also, the blurb before the code was more than relevant to any language, and you said it with absolute 'authority' (and I agreed with what you said ;-)
Now, you should dig up my COBOL answer ... ;-)
Actually, I don't claim to be ignorant on the cobol side of things.
 
Speaking of , the tag will die in two days unless it's tagged with another question.
 
I do remember recently claiming that mysql dialect was not something I am familiar with.
hmmm
 
@syb0rg The README is still sketchy. It refers me to the website, which isn't any more informative. I assume you're still working on that.
 
@200_success - did you perhaps see this query that came through: data.stackexchange.com/workplace/query/195762/…
^^^^ it exposes a new dimension for SEDE queries you may find interesting.
 
Awesome!
LOL Islam and Politics.
Surprised at TeX having an up:down ratio of 96.
 
3:33 AM
Yeah, there are some odd numbers in that lot.
Also, CR is in the middle of the pack on a lot of things.
Nothing really sticks out.
 
BRB moar downvoting
 
hehehe
Anyway, the point was that you can cross-reference to other stack* sites from a query.
And even loop through them all...
The stupid thing was that I got 'challenged' in to fixing the previous version of SQL, and I jumped at it... only a few minutes after telling people they can't motivate me by saying 'I bet you can't do .....'
I seem to be breaking alll my own rules recently.
I wonder if I can ask nicely and get special privileges to run long SQL queries on the databases....
I can imagine a time-based plot of site activity.... overlaying one site with another.... hmmmm
 
4:05 AM
0
Q: Exposing a web API wrapper library to consumers (C#)

BrettI'm writing a C# library that's a wrapper around the Yahoo Finance YQL API. I'm stuck on how I want to expose my API to consumers. My design thus far consists of separate interfaces for the different parts of the Yahoo Finance API: public interface IYahooFinanceCharts { Task<Image> GetChartA...

 
4:46 AM
0
Q: Keyfile Generator

Simon KuangThis is a Java program that generates a random keyfile (for OTP, for example). package kfgen; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.security.SecureRandom; import java.util.Random; import java.util.Scanner; public class Kfgen { ...

 
5:44 AM
monking all
 
morning
 
al well?
 
0
Q: My abs function Template

Chen OTBecause std doesn't provide std::abs for std::size_t overload version, I built a my version to calculate distance between unsigned numbers. Choose the bigger one to minus the smaller one. To make sure not to get negative result, in unsigned integer it would wrap around. std::size_t size_type_ab...

 
@syb0rg Would probably be good to point out that it's for Windows up-front instead of requiring clicking through to github to find that out.
 
0
Q: Filter a collection

Chen OTIn my project, there are some methods which filter some items from collection. I was told that use C++ STL whatever I can. But when I use std::copy_if, I feel the code using simple if-condition looks more clean. I wanna ask whether implementation you like more. Which one is more readable? std:...

 
6:06 AM
0
Q: Bulk upload code desgin and implementation

VIckybI have recently designed a module which will do bulk upload for different contents.Basically user will upload an excel , i have will have to read and validate headers of excel then each value of cell for all columns. I have designed a framework please validate. Below are the vo. Template Header...

0
Q: Reverse linkedlist at interval

JavaDeveloperReverse linkedlist at interval, and for spare nodes, leave them as they are. Eg: Linkedlist 1->2->3->4->5->6->7 for interval of 3 should result in 3->2->1->6->5->4->7. Note 7 is left as it is as its spare. Looking for code review, optimization and best practices. public class ReverseAtInterval

 
6:28 AM
0
Q: SalesTax problem

AlexThe same problem, but I decided to do it using F#: namespace SalexTaxes module Product = type ProductType = |food = 1 |book = 2 |medical = 3 |other = 4 type Product = {Name : string; Type : ProductType; Price : decimal;...

 
Thanks Santa!
 
6:47 AM
0
Q: Occurrence of a word in a String in JAVA

user42803Hi I have the following code. public class SimpleWordCounter { public static void main(String[] args) { try { File f = new File("hi.txt"); Scanner sc = new Scanner(f); // sc.useDelimiter("[^a-zA-Z']+"); Map<String, Integer> wordCount ...

 
7:18 AM
0
Q: Python Sieve of Eratosthenes Algorithm (Beginner Code)

maythesource.comI ama java developer who is taking python for the first time. I'm sure this is not at all elegant since I am thinking more in c syntax. """ This module contains two implementations of the algorithm Sieve of Eratosthenes. """ # import ###########################################################...

 
7:31 AM
0
Q: Extract all related class type aliasing and enum into one file or not

Chen OTI have many models in my project, and some other classes just need the class declaration and pointer type aliasing. It does not need to know the class definition, so I don't want to include the model header file. I extract all the model's declaration into one file to let every classes reference o...

 
Monking (quick dropby)
@SimonAndréForsberg You cannot genericify an EventBus if it allows to register callback objects with @Event annotation on methods, as you cannot dynamically check the types as they are erased
 
Monking ;)
 
Monking @Vogel612
 
I just created a tag for
 
Hmm just 50 minutes of batter left and 45 min class + 20 min waiting
hehe
 
7:45 AM
well you better find a power outlet then ;)
 
btw I pinged you with the unit tests I already made
 
Yes I saw. I am sure I can take a look on wednesday (???) ;)
 
Sure ^^
I'll work today again on bringing my github up to date
It is slacking behind for like 2 weeks :p
Mainly due to that I don't commit experimental code and in order for it to be non-experimental I usually want to use it somewhere in practice and have unit tests
 
well... You'd need to write em then...
 
following class again ;) might be back in 45
 
8:12 AM
@skiwi You could if you keep the passing of the class as a constructor argument. class EventBus<T> { public EventBus(Class<T> eventClazz) }
Monking to all
 
8:36 AM
@SimonAndréForsberg Well it might be reasonable, and monking
Though then it's really time to start using EventBusFactory
With:
public <T> EventBus<T> newEventBus(final Class<T> eventClass);
Which will then create one using EventBus<T> eventBus = new SimpleEventBus(eventClass);
Also getVoidEventBus() should be typed instead of typed as Object, like public <T> EventBus<T> getVoidEventBus() I believe
I see they already precooled the public rooms for the heat that is coming this afternoon.
 
0
Q: Need an advice for making my code faster for compilation

user3446659As part of an Academic project I wrote a code about dynamic programming that solves the "Three-machine proportionate flow shop problem with unequal machine". my major problem is that the code takes a lot of time to calculate big values(bigger then 10) if any one can tell me what is the code eff...

 
8:52 AM
Yaay, going home
 
0
Q: Java: already existed interfaces for my needs

Volodymyr BakhmatiukI have: the next interfaces and default implmentation of it: /** * Checks whether to generic elements belongs to the same distinct */ public interface DistinctPredicate<T> { boolean belongsToTheSameDistinct(T o1, T o2); } But: I'm sure that the similar interface (that takes two objects and...

 
9:06 AM
0
Q: Text-Based Simulator in C++/Qt with many commands

mmphilipsThe following is an excerpt of a mostly text-based simulator of the iRobot Roomba robot vacuum. I made a class called Roomba that handles everything the roomba does. For those familiar with QT; There is also a class called MainWindow that handles the GUI. This is not that class. The roomba has s...

 
So it appears that Andrew Koenig did not create the Koenig lookup.
 
@Morwenn nice new Icon, and monking ;)
 
@Vogel612 Monking :) New icon?
 
9:21 AM
Profile Pic
 
Oh, thanks :)
 
Also I retagged your question on the parallel Sieve of eratosthenes with my awesome new Tag ;)
 
Cool. You missed the follow-up question though, so I just added it.
 
lol
4
 
9:35 AM
0
Q: Neo4J Rest Javascript wrapper

mnhgAs a toy project, I started evaluating the Neo4J graph database and its Rest interface. I'm drying to write a simple graph visualization in Javascript. In daily business I'm a Java developer and maybe that's the reason why I'm not that happy with my current approach. In Java I would have written ...

 
10:05 AM
You shouldn't modify the code in the question on Code Review. Since you improved it, it will be even harder to review. I suggest that you rollback your edit, add again the "ADDITIONAL" which is fine, and answer your own question, describing what you changed and why (from your edit, you can make a significant answer). — Morwenn 18 secs ago
Could anybody help me take a course of action here?
 
10:18 AM
@Morwenn As the question doesn't have any answers yet, it might be OK.
But I'm not sure.
 
I thought that a self-answer would have been better: many of the things changed were worth reviewing.
 
If he would self-answer, then there'd be a zombie less, and he'd probably gain some reputation, but he probably wants comments from other people as well...
Indeed a self-answer could be better, but then he'd probably want a follow-up question too.
Perhaps point him to the meta post....
 
Monking again
 
16
Q: Can I edit my own question to include revised code? Also, how to handle iterative reviews?

JoelIs it okay to edit the question to include the improved code? I would like to do so for the following reasons: To share the improved code with others To show the answering persons that I take their feedback seriously To make sure that I understood (and implement) the feedback in the right mann...

 
One of my default tabs is making sound... But I have no clue which one and none look like they would produce sound
 
10:21 AM
Monking again @skiwi, there is the meta post @Morwenn ^^
 
Oh irght, thanks :)
 
Should I start my TCG submission, once finished, with "Simple TCG game implemention"?
 
Is it simple?
 
It could be much more complicated
 
It could always be more complicated.
 
10:26 AM
Perhaps it's not simple if it doesn't fit in the character limit for questions?
 
0
Q: C++: How to add exceptions in a class that reads a config file

thedarkside ofthemoonI am using Boost for reading a config file that is in the .json format. I am using a class to do this and I am calling exit(message) in case of bad values or default value gotten by Boost get function. The class is here: class ConfigFile { private: PTree m_ptConfig; void failedGetValue(c...

 
10:38 AM
@Morwenn Thanks for patrolling, but I think it doesn't make sense to enforce the no-editing rule on a zombie.
Normally, editing the code in the question is disallowed. However, since this question is old and has no answers, I don't see any harm. — 200_success ♦ 8 mins ago
Also, I've posted a bounty since it looks difficult to review.
 
Nice to see a bounty on the question, nice work @200_success
 
Monking all!
 
I have just remembered that there's one important tool I should use when writing my HStone testing code: CODE COVERAGE!
Monking @rolfl
 
@Vogel612 seems overkill, when the question didn't even have a tag yet.
In my opinion, is specific enough already.
 
@200_success you can get primes by other algorithms...
trial division for example.
 
10:48 AM
Would anyone agree with this?
0
Q: New flag options to aid faster nonsense answer removal

skiwiAs there have been a lot of "Not An Answer" flag discussions lately, and I have hit that same issue aswell, I propose a fix to the issue. My proposal is to split the "Not An Answer" flag, splitting its intended use and its perceived use, into the following: Does not remotely look like an answe...

(It's meta SO I know)
Monking @rolfl
 
And the sieve is a very fixed algorithm, where the algo itself can seldom be reviewed other than: it is (or not) a sieve of eratosthenes..
 
@skiwi Not me. That's what down-votes are for.
People use NAA instead of down-votes all the time,
 
@rolfl Downvotes won't cut it on a very old question which is nowhere near the recent questions list
 
Also, it is "as well" as well.
@skiwi That may be true, but, NAA won't cut it for those answers either (who's going to see them to flag them...?)
Also, there's always edit, and comment.
 
@rolfl That's why a specific queue will help, as that makes them visible.
 
10:58 AM
@200_success I think that is the same category (of tag) as
 
@rolfl It's similar to how the VLQ works in my opinion. You can either give a -1 to an obviously low quality answer, or flag it into the VLQ, where it will be cleaned up as multiple users see it. (You should still also act upon it yourself)
 
@skiwi - in general, NAA is horribly abused by people... you are working on the assumption that NAA is appropriate when the answer is a bad answer.
If you were to suggest that NAA is abolished entirely, I would agree with you more.
VLQ and NAA has a lot of overlap.
 
The problem isn't that people do not have options to deal with it, the problem is that people have issues giving an incorrect answer the attentin to get it handled.
@rolfl You must be mistaken... Then my post isn't clear
 
DownVote is the most appropriate response almost always, but people don't like sacrificing their rep.
 
@Vogel612 Complete the analogy… is to as is to …?
 
11:02 AM
Edit would be the best response .... fix answers that are broken.
 
My whole point is to save the current NAA from abuse and leverage the moderators, and introduce a new custom per tag incorrect answer flag such that gold-badge users can handle them (and not the moderators)
 
vote-to-delete answers that cannot be salvaged.
(and vote-to-delete adds to VLQ queue).
 
@200_success sieve-of-eratosthenes is an implementation detail of (searching for) primes, similarly as linked-list is an implementation detail to a list
 
works as well..
 
We created a [list] tag, which was rejected after further consultation.
 
11:04 AM
because it is way too generic...
as well as primes is IMO bordering on being too generic
 
FYI, I had on my list of tags to ignore for some time.
5
 
I guess I'll never understand codegolf... I think challenges are fun, but purposefully obscuring code seems beyond me.
 
11:29 AM
0
Q: Client-side validator for contact information form (name, phone, e-mail)

Salatafrom my recent post it had some negatives to fix hehe :P I think this should be well structured and written for you JavaScript heroes ;) How does this code look to you? If something needs to be changed please tell me :) // Gets all elements by ID's function elem(id) { return document.getEle...

2 Answers, 0 votes overall..
@skiwi codegolf != obfuscation
while they are largely related by the fact that golfed code is so darn hard to read, codegolf just is "how to accomplish xy with the smallest amount of sourcecode characters"
while obfuscation is: "how to make code so extremely unreadable, that absolutely nobody can decrypt what it does, without losing speed and functionality"
 
@skiwi - I put together a matrix of what I feel should be the appropriate responses for the respective users.
@200_success - I think I will take some time and make it part of CR's meta too... I have been trying to get a handle on the NAA/VLQ flags anyway.
0
A: New flag options to aid faster nonsense answer removal

rolflPosted as CW to encourage people to extend/complete this. There is a matrix of answer quality, and user reputation, and what are appropriate responses for non-moderators Key: +1 => upvote -1 => downvote - => do nothing Edit => Improve the answer (and then perh...

 
1
Q: my arcBall rotation code

ratchet freakI am trying to visualize a pointcloud centered around the origin. I also want to have a user controlled rotation for which I found the arcball. Below is my implementation. rMat is the model matrix, passed into the shader. inline QVector3D getArcballVector(const QPoint& pt, int width, int height...

 
@rolfl The matrix has the right suggestions, but is presented in a complicated way.
It doesn't appear to take into account the ability for moderators to convert an non-answer into a comment.
 
11:44 AM
@200_success that is out of the problem scope IMO, but it's CW for a reason ;)
 
@Vogel612 Which I think is an useless metric as it introduces unreadability
 
@skiwi while that may be correct, that's what codegolf is...
the cool thing is, with codegolf you might have to follow a completely different approach to save chars...
 
I must say, depending on the question, I am still fascinated with the solutions that can emerge from it, but it isn't something I would do myself and I'd be useless at it with Java
 
And that's what makes it interesting.
 
@200_success Ok, I wasn't sure. Thanks for handling this.
 
11:47 AM
@Vogel612 Why would it be out of scope? That's one of the main uses of the NAA flag.
 
I always treated them separately..
But you are right :)
 
@rolfl I'm missing the "incorrect" answer quality in the matrix though... Perhaps an oversight?
 
@skiwi that would probably be crap / bad....
 
I interpreted "crap" as "sdfdsf;dsio;fisifsdofsd"
 
I think the flowchart is much simpler than that. If you see a poor answer, ask "What would I like to see happen to this answer?" Can you do it yourself, or collaborate to make it happen? If so, do that. If not, flag it.
 
11:54 AM
@200_success But there's no appropiate flag for incorrect answers as they require domain knowledge and you cannot put it into a queue with a specific domain knowledge currently.
 
@skiwi True, but an incorrect answer can be edited to make it correct.
 
@skiwi In that case ususally downvote + Comment should be enough IMO.
 
Or just downvoted.
 
@Donald.McLean I usually prefer having OP edit his post over editing it myself. But that may be only my preference..
 
11:55 AM
@Donald.McLean But you're not allowed to do that as it would violate the editing privilege
(If it changes meaning)
And in my experience it is very hard to edit an incorrect answer, without changing the meaning, to a correct one.
 
@skiwi Ahhh. I didn't actually know that. Though I've never tried to edit an incorrect answer.
 
Now you're around anyway... I'd like to ask a question about scala (as I'm posting something else)
I have this code:
    public class MyJavaClass {
        private final Object myField;

        public void doSomething() { }
    }
And translates it to:
    class MyScalaClass {
        var myField: AnyRef

        def doSomething(): { }
    }
It's probably gibberish, isn't it?
 
lol I just right now got the notification for the message from 5 minutes ago..
 
Holy cow this tutorial is big: scala-lang.org/docu/files/ScalaByExample.pdf
 
@skiwi Again, that's overcomplicating it. Inaccuracy doesn't need flagging, because it doesn't require moderator attention. However, flagging it for attention wouldn't hurt. Same principle applies: either make it happen, or get a moderator to make it happen.
 
12:05 PM
@skiwi That looks about right.
What did you think was wrong with it?
 
monking fellow reviewers
 
@Donald.McLean I didn't know if AnyRef was allowed like that, if fields are implicitely private and how "void"s work exactly...
 
@skiwi Since when did you start using Scala?
 
Though I'm not entirely sure about the def line. I would have expected either def doSomething(){} or def doSomething():Unit ={}
 
@SimonAndréForsberg Since I needed to write a feature request involving an example of same code in java and scala
Btw, the whole point of tail recursion annotation is to transform it from ""real recursion" to a sort of while-loop-like recursion?
 
12:08 PM
@skiwi AnyRef is a Scala type for real objects, as opposed to Any which is pretty much just for primitive objects like Int.
 
I'm tempted to also write the TCG in Scala, but I have totally no experience nor time for that...
 
Functions that return "void" in Java can be defined without a return type in Scala. Though if you're writing an API it is generally better to explicitly declare them as returning Unit (the Scala equivalent of void) so as to make it absolutely clear.
 
I see
I would still personally opt in for having Scala-features available in Java as I'm not particularly a fan of the way Scala is written, though I do think the features Scala offers are great
 
Thus def doSomething(){} - no return type declared.
def doSomething(): Unit = {} still returns nothing, just explicit about it
@skiwi Just out of curiosity, what about Scala don't you like?
 
@Donald.McLean A lot... we can start off with the semicolons on the end of sentence
And in my opinion it appears that lots of things are happening within a few lines of code, which is not what I feel iin Java
 
12:17 PM
When I started using the language, it was mainly to use actors, but as I learn more about how it works, I love it even more.
@skiwi That is entirely deliberate. There is some evidence that reducing line count can make code more readable/understandable.
 
I suppose it's mainly a matter of style... One which I don't like (yet)
 
@skiwi I have no opinion on semicolons. You can use them though, if you want to.
And there are some conditions where they are actually necessary.
 
Also one thing that might be problematic in Scala is that types are not explicit most of the time, just saying it because Java relies a lot on the right hand side for type interference, I don't know how that works in Scala
 
Yes, implicit types can sometimes be confusing, and some of the invisible type conversions can make it even more confusing.
I'm not a fan of the invisible type conversions.
 
I may in the future at one point start on creation a new programming language... a very optimistic thought
All I want is Java minus the bad stuff (finalizers, broken serialization, old legacy API's) plus the good stuff (lots of them will most likely be from Scala) in a Java syntax
 
12:22 PM
@skiwi I would love to do something like that, but I'm already busy with too many other projects to actually have that much time.
 
I'm afraid that Java will die if they don't change... They are changing very slowly, but I don't see their current pace keeping up with new (currently non-existing) languages.
The downside, which I very much understand, is that they don't want to break compatability... Yet I see no way to get rid of the legacy and introduce type reification for example on generics
 
Between reinventing how we store and use information, a new card game, and a dozen or so novels, I just have too much I want to do.
 
@Donald.McLean like hanging around here in CR-Chat?
 
@Vogel612 He has two screens and can write by merely thinking about whatever he wants to write.
 
Damn I want that too...
But that probably would spark a few flamewars in comments I shouldn't write, but submit before rethinking it....
 
12:39 PM
0
Q: C++ Exception handeling optimisation

thedarkside ofthemoonI have posed another question here And I am writing this one for some code review: I have done like this: class ConfigFile { private: PTree m_ptConfig; public: ConfigFile(const std::string& name) { json::read_json(name, m_ptConfig); } ~ConfigFile(); double getVal1() { ...

0
Q: How to chain functions using reactor in python?

PatrickMy code: class Server(DatagramProtocol): SSDP_ADDR = "239.255.255.250" SSDP_PORT = 1900 MS = "M-SEARCH * HTTP/1.1\r\nHOST: {}:{}\r\nMAN: 'ssdp:discover'\r\nMX: 2\r\nST: ssdp:all\r\n\r\n".format(SSDP_ADDR, SSDP_PORT) def __init__(self, iface): self.iface = iface ...

 
12:59 PM
Does this class seem correct? (I don't think it warrants full code review question)
public class DrawCardAction implements PlayerAction {
    @Override
    public boolean isActionAllowed(final Player player) {
        Graveyard graveyard = player.getGraveyard();
        Hand hand = player.getHand();
        return (!graveyard.isEmpty() && hand.size() + 1 <= hand.getCapacity());
    }

    @Override
    public void performAction(final Player player) {
        Objects.requireNonNull(player);
        Deck deck = player.getDeck();
        Hand hand = player.getHand();
        Graveyard graveyard = player.getGraveyard();
And would a hand.hasCapacityFor(int amount) convienience method be nicer?
 
@skiwi I'd rather go with the C#-like attempt...
public boolean tryPerformAction(final Player player) {
     try {
        performAction();
        return true;
     } catch (IllegalActionException e){
        return false;
     }
}
or rather do it with a standard If-else statement..
 
@Vogel612 I forgot to check the condition inside performAction again I see
The problem is that it can throw any exception, even ClassCastException could occur (though not in this particular code), and catching all exceptions is a bad idea
 
in fact the isActionAllowed() is utterly useless, when you don't require calling it before performAction()
You might consider throwing an IllegalStateException or something along these lines..
 
It isn't useless if I call it inside performAction though
 
@skiwi if you check in perform action either way, why is it public then??
 
1:09 PM
Because it will throw an exception on error, and you do not want to resort to exception-checking when calling performAction, but rather check if the premises are correct before executing
 
1:23 PM
@skiwi and if now someone comes, and just ignores isActionAllowed()and just calls performAction()with an invalid action, without checking for exceptions?
 
@Override
public void performAction(final Player player) {
    Objects.requireNonNull(player);
    if (!isActionAllowed(player)){
        throw new IllegalStateException("action is not allowed");
    }
Means the code won't run and you'll get an exception so you can fix it as programmer
Optionally a GUI can catch the IllegalStateException (not really recommended though) and throw a nicely looking message withotu crashing the application
 
@skiwi I was also tempted to use TCG for Scala, but after realizing I could at least use lambdas and default methods in Java 8, I'm sticking to Java for now :)
 
I would throw a checked Exception for that, but that may be only my preference..
 
A checked exception would be killing...
 
@Vogel612 I know a bunch of reasons for why isActionAllowed is not useless. GameView should know which buttons are clickable, and AIs should know which actions can be performed. I personally do not call performAction from other code than the TCGGame, which is why I have an abstract class instead of interface, so that I can use protected
 
1:34 PM
PlayerAction action = new DrawCardAction();
if (!action.isActionAllowed(player)) {
    //show error on console or GUI
}
else {
    try {
        action.performAction(player);
    } catch (ActionFailedException ex) {
        //never happens, suppress
    }
}
 
apparently my answer isn't any good
0
A: Simplifying a repetitive event handler

Malachiwhat you should really do here is turn this part into a function with a parameter for your keyCode $(document).keyup(function (e) { if (e.which == 113) { $.ajax({ type: "POST", url: "/submit/role/", data: {}, ...

 
@SimonAndréForsberg Do you have a particular opinion about using Player as argument in isActionAllowed and performAction? My idea was that a single action could be called on multiple players.
 
@skiwi Consider a TCGGame.performAction(PlayerAction) method
 
@mat'smug @Morwenn - @all ... about the blog ....
 
Yes?
 
1:40 PM
@skiwi I personally pass the Player to the constructor of the Action class instead.
 
I have been in communication with the SE devs/CM's, and there will be an official statement made about things 'soon', but, the head's up unofficial version, is:
> Blogs are being revamped site-wide (SE-site, not just individual stacks).
> Code Review has been a big part in motivating this revamp, because a number of issues/inconveniences have existed in other sites and processes.
> Code Review will have to wait for the revamp to happen......
 
I know of some of these issues.
 
> which will be sometime in the next 6-8 weeks.
 
What issues?
 
For example, the Arqade blog is not a BlogOverflow blog. It is a mess to synchronize it with the rest of the network.
And I think that one of the aims is to have the blog posts appear in the Community Bulletin.
When I wrote an article for the Arqade blog, some regulars discovered that they had a blog.
 
1:44 PM
There are a number of things that have been thrown around, and I am not sure which ones will 'stick'.
I'm not about to speculate on that ;-)
 
And Programmers.SE had to use a community ad to promote its blog in its own community.
 
But, I expect there to be an official answer on our CR meta shortly ...... and I don't know what it will say.... but, expect it to be along the lines of "You're doing the right thing, be patient, we're working on it, it will be great...." ;-)
 
@SimonAndréForsberg One last thingie, do you think adding hand.hasCapacityFor(int amount) opens up the way to putting tons of utility methods in the class, or is it okay to add one if deemed neccessary by the implementation?
 
What do you mean "will we ever graduate"?
2
 
0
Q: How can I module this node.js express server code?

diegoaguilarI got below express node.js server code using Passport. It receives a user to authenticate it and send him to some data registration form. So far is relevant: My whole routes definition depends upon a MongoDB connection using mongo-db , but model used by Passport is done through another connec...

 
1:51 PM
@Morwenn I can't find what you are quoting there?
 
@rolfl That was an hypothetical answer by the mods to an hypothetical question about the never happenning CR graduation :p
At least, these weeks will let us the time to review and improve the first blog articles.
 
Ahh ... I just happened to be having a 'can we graduate, please' discussion with some 'officials' .....
You seemed to be listening in ... ;-)
spooky
(and, as always, there's no answer .... yet).
 
I don't listen to anything (besides great music), I try to read the atmosphere.
 
Is there any consensus about adding methods to classes for convienience? (Meaning that the operation could also have been performed via two method invocations for example)
 
@skiwi I'm not sure I understand the question?
@skiwi Now I understand the question a bit better. I think adding convenience-methods is a good thing.
 
2:02 PM
@SimonAndréForsberg The only place to avoid mindlessly adding convienience methods is in interfaces I suppose?
 
0
Q: Check for correct number of elements in exploded string

kasimirLet's say I've got this string: $str = '1-2-3'; and I explode this like so: $strSplit = explode('-', $str); what would be the best way to check if I've got the correct number of elements and whether they are numeric (because the input can vary)? Straightforward, I would say something like ...

0
Q: Beautify/compact this vb code

John DenverI have 3 combo boxes with the same 3 selections in each. If the user picks the same selection a 2nd time, the first combo box resets. I have 3 other sections that will do the same with about 15 combo boxes. I was wondering if there is a shorter/compact way to code what I'm doing? Protected Sub...

 
@skiwi I think that as of Java 8, interfaces makes a great point at adding convenience methods, they can be called default methods
 
@SimonAndréForsberg But I bet there could be a dozen on the List interface for example and I call it a good thing that they are not on that place
 
@skiwi Wouldn't you consider isEmpty a convenience method already? As it can be replaced by size() > 0
Of course you shouldn't have too many convenience methods though
 
0
Q: Shell Script Image Replication

JoshpbarronI have a shell script which is being used on an embedded human machine interface (HMI). This script is used to copy a few files from a USB stick to a different place on the device, but with multiple instances of the same file under different names. If it helps: OS is Unix-like (BusyBox v1.11.2...

 
2:13 PM
@SimonAndréForsberg stuff like:
public class Example {
    private SomeObject thingy;
    public SomeObject getThingy(){
        return thingy;
    }
    public Object getThingyProperty(){
        return thingy.getProperty();
    }
}
right @skiwi?
 
@Vogel612 Where such methods makes sense, I think they're OK. Especially if you include a null-check in getThingyProperty. However, in the List interface, such a method wouldn't make sense.
 
Even though a method to get an index starting from the end of a list, would make sense
@Vogel612 I suppose yes, but depending on usecase
 
@skiwi I wouldn't be so sure about that...
If you want to iterate your list from bottom up, I suggest you .reverse() it and then go about it the usual way...
 
I don't have a concrete example, but it is very annoying when working with streams and wanting to get the last element
Perhaps I know one
Function<List<String>, String> getLastElement = list -> list.???
Still the wrong example I'm afraid
As you can do it with list -> list.get(list.size() - 1)
 
@skiwi If you just want to get the last element, then you should reconsider using streams at all.
@skiwi I don't think such a method would make sense, as a list is always indexed from the start. I don't think indexOfFromEnd(Object obj) { return size() - 1 - indexOf(obj); } would be useful.
 
2:28 PM
There were good reasons to it... Unfortuantely I forgot most of it
 
I love the Roslyn implementation inside Visual Studio. Code Analysis tells you your type has a Disposable field and the automatic fix provider gives you the option to generate the Dispose() method with all disposable fields getting called
 
can I get some SO Love?
1
A: Sqlite database does not store previous data inserted

MalachiLike @CL was saying you can't have 2 records with the same PRIMARY KEY this Table should be built with 3 columns. A_ID PRIMARY KEY AUTO INCREMENT NOT NULL time DATETIME (probably NOT NULL as well data REAL in other words, Never set the Primary key in your code, let the database auto increm...

 
Hmm perhaps getRemainingCapacity() is more useful as hasCapacityFor(amount)
 
monking
 
@Mat'sMug There you are!!
 
2:34 PM
@Jamal I made the rollback
yeah
 
@Mat'sMug You following me? ;-)
 
Monking @Mat'sMug
 
> I'm declaring everyone that contributed a positively scored entry as a winner, you'll all receive an email from me in the next few days to collect your size, prize preference and shipping information.

That means if you entered, and didn't delete your submission, you're going to get something.
^^ I'm getting a 2nd mug!!
 
@Mat'sMug What, you're getting another mug?
 
and tee!
 
2:36 PM
Why / How / When?
 
82
Q: What happens when you plug a UPS into itself?

Tim PostUPSey daisy; so we had a little ... incident ... Pretty sure that has power. We're past that now, and things are returning to normal. It's only appropriate that we take a moment to think about the folks that got pulled out of bed and worked their knuckles to the bone to get things back up and...

 
@Mat'sMug Hi you :)
 
new avatar @Morwenn?
 
@Mat'sMug Yes. I like to change from time to time.
 
2:38 PM
 
@Mat'sMug Phew. My crappy drawings wouldn't get a positive score anyway. But someday I'll get SE swag... someday...
 
 
wtf
 
That's some kind of molten iron ^^
 
@Jamal if @Doorknob's crappy drawings got a positive score, I don't see why yours wouldn't :/
3
 
2:41 PM
@Mat'sMug The one with all the site logos? That's way too much Paint for me.
 
Ok... Last one for now:
 
How come @Doorknob's image isn't golfed?
 
@Jamal he made 2
 
@Mat'sMug Oh yeah
 
@FrancisVeilleux-Gaboury hello!
 
2:49 PM
:o I didn't know something happened
32
Q: Offensive, inappropriate, and un-professional chat room names

CupcakeI was browsing the front-page of Meta, and I noticed off to the right a very strange and kind of inappropriate name for a chat room: However, when I look at the chat room info directly, the name of the room appears as Lounge<C++> Questions Are chat rooms allowed to be named after genit...

 
@Malachi Good point !
 
sometimes I read the code......LOL JK
 
@Malachi you're getting a SE mug & tee!!
 
@skiwi Usual lounge.
 
@Mat'sMug Really? how?
 
2:53 PM
17 mins ago, by Mat's Mug
> I'm declaring everyone that contributed a positively scored entry as a winner, you'll all receive an email from me in the next few days to collect your size, prize preference and shipping information.

That means if you entered, and didn't delete your submission, you're going to get something.
 
YES!!!!
going to check all my E-mails right now
Break time
 
@Morwenn I guess I'm glad I don't go there then, wouldn't be the most appropiate environment for me
 
no Email yet
 
lol could be a couple days
 
Clearly its a hamster. Though, I suppose larger deployments might use capybara — Journeyman Geek May 17 at 3:31
lol
This. Seriously, imagine the impact if it happens to Facebook. Or Twitter. Or both. — Frédéric Hamidi May 16 at 21:47
ROFLMAO
that could be bad or good for the economy, depending on what people do with the down time I guess
 
2:58 PM
and/or birth rate
 

« first day (381 days earlier)      last day (3622 days later) »