« first day (347 days earlier)      last day (3662 days later) » 

Thanks for the +2 accept-edit
 
chris says hi ;)
 
123 Hi!
 
@Mat'sMug That's an edit. :-)
 
:)
 
12:16 AM
Now we just need more people to do that. I want that vacation in Hawaii. :-P
 
1
Q: Conditional statements relating to hospital management

LexieIt works just fine, but is there any other way to write this shorter? Nurses are only available to intensive care patients (room I) and TV's and telephones are only available to non intensive care patients (room D or room P). Also, X_COST has a value of 0. if (room.equals("I")) { // if (room.eq...

 
damn how come I couldn't find that close reason?!
> "Questions must include the code to be reviewed. Links to code hosted on third-party sites are permissible, but the most relevant excerpts must be embedded in the question itself." – ChrisW, Jamal
bleh
 
lol
2
 
hey @tinstaafl, welcome back!
 
thx, didn't realize I was logged off lol.
 
12:28 AM
> if (room.equals("I")) { // if (room.equals("I"))
comments FTW
 
>.<
 
Got logged off automatically for some reason.
 
// this is a comment
 
TTGGD (Go Get Dinner)
 
Later! I'm having fish now (sorry, 200).
 
12:32 AM
later!
 
12:53 AM
-1
A: Conditional statements relating to hospital management

Alvin Bunkthese are the suggested changes. Can you understand why I made the changes? // take these out of the if/elses roomCost = 395 * (double)days; if (room.equals("I")) { // if (room.equals("I")) TVCost = X_COST; phoneCost = X_COST; if (nurse.equals("X")) nurseCost = X_COST; ...

^ Shouldn't have been flagged as "not an answer".
13
Q: Short answers and code-only answers

ChrisWWhat should we do with: Short answers (for example, "I suggest you use [hyperlink to this standard API] instead.") Code-only answers (for example, an improved version of the code in the OP) Such answers could be improved (e.g. by adding an explanation of why the suggestion is helpful). Is it...

 
new user, poor guy was probably trying to be nice proposing some "fishing rod" answer...
 
Speaking of code dumps:
0
A: Reader Writer program in C using semaphore and pthread

user3438495nice question try to use this. It seems like u r confused with reader writer problem. void reader(){ while(1){ wait(x); readcount++; if (readcount==1) wait(wsem); signal(x); doReading(); wait(x); readcount--; if (readcount=...

 
It's a code-only answer but clearly derived from (and probably an improvement on) the OP's code.
 
Why can't you just give the OP an answer to his problem? I don't think code dumps were requested here. — Jamal 3 mins ago
 
Not one, but two. And even the OP wasn't satisfied.
-1
A: What is wrong with this mysql query?

user3538194CREATE TABLE 商品 ( 商品代號 INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, 商品名稱 VARCHAR(255) NULL , 定價 INTEGER UNSIGNED NULL , 總類 CHAR(15) NULL , PRIMARY KEY(商品代號)); CREATE TABLE 會員 ( 會員帳號 CHAR(15) NOT NULL AUTO_INCREMENT, 身分證字號 CHAR(15) NULL , 姓名 CHAR(15) NULL , 生日 TIME ...

O_O
 
12:58 AM
holy carp
how do you stumble on all these gems?
 
^ Maybe that's meant to be a new question?
 
@Mat'sMug I scan the front page and load posts by 1-rep users. The ones on high-view and high-answer posts usually have the best gems.
 
@ChrisW Umm, that was my bad :P
Accidental really.
I didn't look at all of the code...
 
Really?
 
Well, I didn't look at the comments I mean. I usually don't parse those.
But even with the comments, it's not that great of an answer.
 
1:03 AM
hrm, sucks being in a totally different timezone now. Go to sleep, wake up, new questions and everything is answered
 
hey @Yuushi!
 
hey @Mat'sMug
 
do your colleagues have a CR account? ;)
 
one does, but he's not very active
 
@syb0rg It's not a great answer, but downvote+criticism+flag is "an exploding bear trap" for a new user.
 
1:05 AM
@ChrisW Yeah, I need to curb my flagging a bit.
Sorry @all
 
oh wow, I didn't realise Bartosz Milewski had an account on CR
 
I applied a "sympathy upvote".
 
Like syb0rg said, it would be nicer to see the comments outside. Otherwise, it looks more like a code dump.
 
damn I hadn't even noticed them!
@Jamal I can't revoke a flag, can I?
 
@Jamal If only there were someone ... someone, not a million miles from here ... someone who knew how to edit it to make it look nicer ...
 
1:12 AM
0
Q: Transfer the format of an old string to a new string

StarkersFirst, I've extended the String class to detect uppercase and lowercase characters: class String def is_uppercase? self == self.upcase end def is_lowercase? self == self.downcase end end I then use these instance methods to fulfil my main goal of transfe...

 
@ChrisW Way ahead of you! Edited just now.
@Mat'sMug Unfortunately, you can't.
But, since you've flagged as VLQ, it was cleared with the edit.
 
cool
 
@Jamal Swell. Now I flagged syborg's comment as "obsolete".
 
lol
 
The answerer just revised it:
0
A: Conditional statements relating to hospital management

Alvin BunkroomCost is identical in all cases, so set it only once... Also, you should only check for room.equals("I"), because that is significantly different than the other rooms. Then is else another room, then you only need to check if TV.equals("V"). These changes will really make the resultant code m...

 
1:17 AM
post got my sympathy upvote
 
Flags cleared and comments purged (all were obsolete).
 
0
Q: Java pig game need to modify the input to be from txt file

user2815182i really need your help to modify this program to read the players names from TXT file than write names and scores to diferent txt file import javax.swing.JOptionPane; import java.util.Scanner; import java.io.*; public class CochonVer4 { static int joueur = 0; // identifie le jou...

 
^ off-topic (and not from SO)
 
1:42 AM
29
A: Conway's Game of Life in C++

KordalienTwo major suggestions: First, let's try speeding everything up by taking advantage of the nature of Conway's Game of Life and the way C++ handles pointers. When you evaluate Conway's Game of Life, it's a two part process. First you copy all of the entries into a new array, then you do your comp...

[badge:good-answer]!
 
pretty good for a first answer
 
0
A: Hi! What brings you here today?

ChrisW What ideas do you have to help turn one-time contributors into repeat customers? Post a comment to new users, like "Welcome to Code Review! Feel free to visit the chat room to meet some of the regulars, to chat, or to ask any questions you might have." Many of the regular users feel a sense...

 
@ChrisW One order of business might be to think about how to understand what kind of user is not being retained. What's the median or mean profile of an un-retained user? - that's a very good point to bring up.. are we losing the askers or the reviewers more?
 
I wonder if I can build an SEDE for that....
Something like .... Y-axis is avg frequency of posts, X-axis is week-user-joined
Break it down by tag .... ?
Skip people with just 1 post...?
 
Is there a stackexchange site for asking questions about marketing? :)
 
1:51 AM
Depends, could be GraphicDesign...
 
How to "know-your-customer", etc.
 
statistics?
 
must define "losing" (and consequently, "having") a user first I think
 
Web marketing, e.g. "the funnel": questions like, "why do people visit my site but then leave without buying?" Because, if so, might their expertise be relevant to understanding unretained users?
 
filter out single-posters and you weed out all drive-by's
 
1:54 AM
^^^ exactly
 
Didn't Grace define a minimum rep before someone is considered "avid" and therefore in need of being promoted/retained?
 
@ChrisW in retail the "target hit rate" is ~10% of clients that turn into a sale.
@ChrisW not sure if it was 150 or 250, but Area51 has it at 200
 
IIRC 10% is quite the ambitious target, according to advice to software startups given on discuss.joelonsoftware.com/?biz
 
god, it boggles my mind sometimes how people try to do complex things in C++ and seem to not even understand basic parts of the language...
1
A: Boost Function Pointer Multithreaded Mystery

YuushiThere are multiple issues here: asio::system_error e(); This isn't doing what you want. Because of the way C++ syntax works, this is actually declaring a function e that takes no parameters and returns an asio::system_error. If you add a void in the parenthesis, this becomes easier to see. It ...

 
TTGTB - 'night @all!
 
2:02 AM
night @Mat'sMug
 
Night!
 
2:34 AM
0
Q: Kings Cup drinking game

KimberlyI'm working on a card game in Java that simulates the drinking game Kings Cup for a school project. I'm having trouble putting the pieces together, and was wondering if someone could tell me what I could do to improve my code. @author :Kimberly IDE :NETBEANS publ...

0
Q: A source Code Counter

cluttonThis is from my project codecount I use personally that is very similar to cloc.exe or SLOCCount. The part that I am questioning is where I am calculating when I am in a comment block and have deep nesting, I basically am replacing the sections with blank. I would like to deal with fixed format...

0
Q: Simple SAT Solver In Python

SahandI am interested in improving my coding standards in Python so I decided to post one my more recent and smaller "for fun" projects here for review. The code below implements a rather simple backtracking algorithm to solve SAT, which is based on Knuth's SAT0W found here: http://www-cs-faculty.stanf...

 
2:50 AM
New Graph about user retention:
From that chart, it appears that about 10% of new users to the site have at least one non-deleted post.
For new users in the month, once they are out of their month, the % of users that still post drops off rapidly.
 
3:31 AM
Could you add a description to the query? I don't know how to interpret it.
 
3:43 AM
0
Q: Group By And Two Counts

user3538039I'd like to know if there's any better way to write this query: (from a in Context.Pages join b in Context.Visitors on a.PageID equals b.PageFK join c in Context.Visits on b.VisitorID equals c.VisitorFK join d in Context.Signups on c.VisitID equals d.VisitFK where d.DateOptinUtc.HasValue && a.Us...

 
3:54 AM
Incoming Meta post.
 
0
Q: Improving My Java Object Oriented Program

cbenn95I'm having issues with my code. I created a java class, "Date," in which I basically create date strings and set dates. Anything that I can do, besides adding comments to improve/shorten my code? Currently Testing My Date.java.class and Commenting My Code Tried changing the instantiated boolea...

0
Q: Should comparisons of code snippets be closed as "not seeking a code review"?

JamalI've been seeing some "A vs. B" questions for a while, and I'm not sure if they're considered on-topic for this site. Many of these questions are not asking for a review, but which code snippet is better. These, to me, sound primarily opinion-based. However, I've seen some that are asking abou...

 
 
3 hours later…
6:41 AM
0
Q: Captcha Maker program in python

Manan DhawanI have written a program to create an image consisting of randomly generated numbers using PIL. I have stored the numbers generated and compared it with user's input. import Image, ImageDraw , ImageFont import random n=4 size = (100,50) image = Image.new('RGB', size) draw = ImageDraw.Draw(ima...

0
Q: C# with Oracle ODP.NET

MikroDelThis is code: int number; DateTime dateTime; using (var oracleConnection = new OracleConnection(ConnectionString)) using (var oracleCommand = oracleConnection.CreateCommand()) { oracleConnection.Open(); oracleCommand.CommandText = "SELECT * FROM FROM MY_TABLE"; using (var rea...

0
Q: Using factories in testing for non-database objects

Dominik GoltermannI've got a bunch of classes with initializers that take rather complicated arguments. How can i test those while reducing the context as much as possible? For ORM classes there are factories like FactoryGirl. Is there something similiar for instantiating "normal" classes? An example of such an ...

0
Q: Sprite drawing class improvement

BenI have written a very Xna spritebatch like interface for drawing sprites in opengl. When begin is called the vertex data buffer is mapped to a float*. The index buffer and vertex buffer are bound in begin, and it's assumed no other drawing is done in this opengl context between begin and end. In ...

 
7:32 AM
0
Q: Find the value nearest to k in the sorted array

JavaDeveloperGiven a sorted array returns the 'closest' element to the input 'x'. Note, I do understand merits of unit testing in separate files. But deliberately added it to main method for personal convenience, so request you don’t consider that in your feedback. Looking for request code review, optimizati...

0
Q: provisionary polymorphism or cast?

ValI have interpreter, which passes the values through the stack. The procedure expects that value is of specific type. It looks something like Integer iv = (Integer) stack.pop(); Alternatively, I could create the dummy asXXX() for all possible XXX types, e.g. Integer iv = stack.pop().asInteger(...

 
7:46 AM
0
Q: Generate sequence in linq

MagnusI want to generate a sequence using linq that goes form 10 to 100 with a step size of 10. The sequence also must contain a custom value (in the correct order). This is what I have now, and Im wondering if there is a smarter way of doing it using Linq expressions. var pageSize = 25; //number that...

 
Hello there!
 
Bah... I need an anchor in sanity while plowing through this code... thought I might as well log in here. ;-)
Too early in the day, huh? Only two people east of the "first coffee terminus"?
 
I even walked a bit after I got my coffee.
 
8:02 AM
It's one thing if you're doing Code Review in a team, or even online. It's another thing entirely to be saddled with 600k lines of legacy code that originally looked like they were written as an implementation of the paper "How to write unmaintainable code".
Six years later I'm beginning to feel like I'm in control of the thing... sigh
 
That does not sound like a dream job...
 
It has its upsides. I basically have my back firmly against the wall: None of this is my fault, and they know it. I'm the only one with a hope to keep it working, and basically 50% of our software relies on this, so...
Did wonders to my standing here as well. ;-)
 
How many years do you have before the rewrite from scratch strategy is applied?
 
They won't. "That's too expensive, we cannot afford it." Despite my original estimate that I could do it in about a year. Six years later... you do the math. ;-)
 
Short-sighted vision...
 
8:08 AM
Yep.
The original coder estimated he'd need 9 months to turn his prototype into a product. He was given one, and actually did it - so-so. They're paying the legacy to this day.
 
That's harsh.
 
The "funny" thing, it's the third iteration of the product to begin with. :-D
 
Do they ever learn from their mistakes? o__o
 
Nope, never.
That's what keeps us in pay. ;)
 
That's why the World still needs so many programmers & computer scientists.
 
8:11 AM
When I started, I dreamed of doing system development. Operating system stuff. Developing the future. All I ever did was maintenance work on other people's code. It gives a standing of a different kind, but I like it somewhat. The combination of awe and comiseration when I say "maintenance coder, 15 years of C++..."
Besides, I got a very funny inside view of the banking crash of 2008. I could tell you about it, but I would have to kill you afterwards. ;-)
(Worked in Risk Control at the time, and boy didn't they have clue #1 what they were doing... :-D )
2
 
@DevSolar well I'm lurking around here and killing some Java-Zombies (concerning the first coffee terminus)
 
@Vogel612: Vogel! Altes Haus! :-D
 
Meh... for german, please join here instead

 deutschsprachiger Raum

General discussion for german.stackexchange.com. You may speak...
lurking around there, too ;)
 
Spoilsport. :-D
 
0
Q: Basic templating engine in F# using F# syntax

AndyBurshI've been working on a rough idea for a templating engine (mostly as a learning project) using the F# syntax. How "correct" is my code in terms of being idiomatic F#? Are there F# features which would make the code simpler? More easily understood? The template files are loaded at runtime using ...

 
8:34 AM
Yep, found it.... excuse me while I bang my head a bit.
objectVector[ activeObject ].... and eventually I find that activeObject can only be -1 (default) or 0 (after initialization), but can never be set to anything else. Sometimes I get this feeling the author did this stuff on purpose. :-D
 
oh well, who needs anything else than the first element or some IndexOutOfRange Exception either way ...
 
That's after several hours trying to figure out how additional objects would be initialized, because I'm trying to actually document it...
 
@Vogel612 I don't understand anything when I tried to read German, even though I had five years of German courses during middle/high school :/
 
@Morwenn: Don't worry, I feel the same about Latin (four years) and French (two years). English is the only language I ever mastered.
Aside from ARexx, C/C++, Java, Perl, Bash, PL/SQL, VB and a couple other programming languages, of course. Somehow, computer communication seems so much easier. :-D
 
Haha, nobody ever mastered C++.
 
8:46 AM
There's a passage in the fantasy novel "The Pool of Radiance" that applies there.
 
How so?
 
Can't quote literally, but it goes along these lines: Having "mastered" something doesn't mean you have learned everything there is to learn. It just means you have understood the nature of the thing, are able to use it confidently and efficiently, and are fully in control of what you are doing.
I freely admit that I haven't familiarized myself with C++11, though.
Yet.
One of the backlogs on my bookshelf. ;-)
 
I finally got the badge for C++11 BTW. Retagging the questions was worth it.
 
;-)
 
I went from 80 to 128 points for the tag :p
 
8:52 AM
I've been "blessed" that way. Worked with a committee member for eight years, and learned lots about templates. And the book "Programming C++11" I got from the author directly -- he's actually been the one whom's chair I'm sitting in right now. (Not the original author of this mess, but the one trying to make sense of it before.)
I call it "learning by osmosis". ;)
 
Which committee member? I don't know of the aforementioned book.
 
Dietmar Kühl. The book is German, "C++11 programmieren", by Torsten Will.
 
Ok :)
 
ISBN-13 978-3836217323. If you intend to brush up your German with a book on C++11. :-D
 
Not really. I fear that a general book about C++11 won't teach me much more than what I already know. Moreover, there is plenty of documentation on the internet :)
I would need a book about facets and std::valarray though...
 
9:04 AM
For me it was perfect -- being steeped in C++98 already, needing a book that told me "what's new" in detail instead of giving me another introduction on if() and while(). Now, if I only could find the time to actually read it... :-D
 
What kind of monster have I created:
 boolean persistenceDone = (Boolean) Whitebox.getInternalState(cut, "isPersistenceDone");
 
Errr... weird? :-D
 
yea...
 
Uh... state compared to a string?
 
The Whitebox accesses the private boolean field, to get it's value
Reflection
 
9:08 AM
Ah.
 
and later:
assertFalse(persistenceDone);
 
Hehehe...
 
The fun thing is, that there are Three types in this one line..
 
assert(true); // fails from time to time...
 
getInternalState returns Object. That is cast to Boolean and that again is implicitly cast to the primitive boolean on assignment
 
9:11 AM
Seen worse. ;)
 
this is supposed to be a unit-test..
 
Ref. "assert( true )"... got something to share here that I found in production code...
#define TWO 3
2
No kidding.
 
I think that every programmer should have mandatory code review classes throughout their programming studies.
4
Death penalty for those who fail.
 
I think that Human Resource people should be taught that Computer Science and Programming are two rather distinct disciplines...
 
I think that the world should be a better place in general </nihilism>
3
 
9:17 AM
Computer scientists think a lot and produce poor code. Programmers code and lot and don't have time to think.
3
 
@Morwenn: LOL...
 
Calling upon the SpellCard Fusion
 
Gee, how many stars does one have?
 
lots. until you suddenly are out of stars.
but for exactly such situations, theoretical stars (TS) exist ;)
the limit is reset daily.
somewhat similar to votes.
 
D'oh. Be careful with that <Alt-F4>, young padawan...
 
9:39 AM
Programming is like sex: One mistake and you have to support it for life.
-- Michael Sinz, Commodore Engineering
 
Morning!
 
Err... Lunchtime? ;-)
 
Well... soon, I just woke up and got dressed, etc
 
Well, depending on occupation one doesn't exclude the other. However, I think a difference in time zone is more likely. ;_
 
I never had to experience this with Java... But is it a real thing on C++ for example? (Non-interpreted languages)
I'm your neighbour country-wise :) Just having a day off university and not being the fastest
 
9:45 AM
@skiwi I remeber that one time when I compiled Qt...
 
@skiwi: Seriously depending on the code in question.
Template-rich code or some stupidity regarding the handling of headers can blow C++ compile times right through the roof. But it's not systematic, i.e. "clean" code can compile rather efficiently.
 
Okay, probably an old thing of Pentium 4 pc's?
 
Definitely.
I've worked with C++ code that took 2 hours for a clean compile on a 2.6 GHz Core Duo. After re-shuffling the #include's it did the same thing in 12 minutes.
 
There are some tricks to compile faster, but still, C++ compilation is generally slow. And the compiler vendors are making more and more effort to reduce compile and link time.
Apparently, GCC 4.9 link time for Firefox took 350s while it took 1700s with GCC 4.8.
And clang is said to compile faster, but I never had the opportunity to compile a big program with clang.
 
Sounds cool that they are making it faster
What about automated testing? I once was, with an university trip, at a company that creates drivers for industrial printers (Océ, I believe it was called), and they used the whole night for automated testing, looking at a good 8 hours there
Do your companies even do testing? :p
 
9:58 AM
@skiwi: Real-life example: I've got a C++ code base of ~600kloc here that's compiled nightly on three different architectures and compilers.
Windows 7 64bit, MSVC 10, Xeon E3-1230 @ 3.3 GHz, using 4 threads -- 3m 24s
Linux Mint 16 64bit, GCC 4.8.1, Xeon E5-1660 @ 3.3 GHz, using 8 threads -- 1m 42s
AIX 6.1 64bit, IBM XL 11.1, POWER @ 3.7 GHz, using 2 threads - 21m 18s
 
What is kloc?
 
The AIX is under load at that time, though, so results might be skewed.
kilo lines of code.
600.000
 
Ah, I need ot learn the abbrevations :p
With Java compile time can still go up to a minute if you decide to hang 10 dependant projects under one, that all get automatically recompiled
 
With regards to the XKCD cartoon, though -- you very rarely need to do a full build during development, unless your build system stinks, and partial recompiles are a matter of seconds.
 
I see
 
10:02 AM
Nothing keeps a dev from doing a clean, full build if he needs some time to think, though. ;)
 
What excuse can I make for programming in Java then?
 
There is no excuse for programming in Java. :-D
Sorry.
Couldn't help myself.
 
So that's why every seasoned programmer wants to program in C++, it has nothing to do with the language at all... (Compile times)
 
You should never need an excuse for taking a "think break". Ergonomics teach that you should take a 10-minute break from sitting every hour anyway. A good boss knows that, if you get up and take a stroll around the building, that it's actually increasing your productivity.
Especially when doing debugging, or figuring out how to tackle a problem -- when you're stuck, take a break.
 
I still have at least 3 years to go before I finish my Master's Degree, but I do hope I may experience the workplace of an open company one day
Like one that actually has relax seats and stuff, just to well... relax
 
10:07 AM
If you go somewhere for a job interview, and you're seeing cubicles, leave. :-D
3
We don't have relax seats here, but going over to the kiosk for a snack, or just the walk, counts as "good enough" for me.
It doesn't need to be a company policy, as long as your boss understands that 8 hours of non-stop typing isn't always the best approach. ;-)
And while we're at it, off for lunch. BBL.
 
Does it mix well if the company also has lots of other jobs there?
 
10:27 AM
0
Q: Optimized Form fields generating class

pixelngrainI am building an application full of forms and so I thought it is good idea to create a class to populate form fields. Here is my class and I am sure it can be optimized more than now and could be better. class JS_Forms { public function __construct() { //$this->register_fields...

 
@skiwi the answer to such question is always: depends.
 
I've got one practical question about git, if anyone knows: Should I fix & commit one issue at a time, or is it fine to do multiple ones (in a single file) at once?
 
That's probably a matter of personal preference...
 
I guess for this it doesn't matter too much anyway
 
if you have small changes, I'd always put them together.
 
10:33 AM
1
A: Trading Card Game's Hand class and tests

VoiceOfUnreasonThere are two sharp code smells that suggest you are attacking this project the wrong way around. One is that your HandTest is primarily concerned with verifying that the Hand class produces the correct behavior when various pre-conditions are invalid. Unless you are expecting to write a lot of...

 
if you have a feature though, it's the policy in our company to create a new branch for the whole ticket.
 
I hope I wasn't too harsh there
But that's done to ensure that the current version can still receive bug fixes mainly, am I right?
If it was 100% sure that current branch (master) would get no single update anymore... Then it could've been worked on directly?
 
the master branch is supposed to always be a stable and functional state of the application
anything else should be done in development branch or even separate branches.
as soon as you have a bugfix ready to roll out, you usually merge to development
 
I see
 
run the tests there, and only if all tests are successful, you merge to master.
 
10:38 AM
And the development goes through a QA I suppose?
 
QA?
 
quality assurance
 
Re. @skiwi: Consider that a commit should have a commit comment attached to it. That comment should be a terse one-liner. If "a couple of small fixes" is good enough, fine. But as soon as you touch functionality, I tend to advocate seperate commits.
 
Qualitätssicherung
 
yea I got that ;)
yes, actually the development is the dedicated place for QA.
even though my company (among many others) promotes QA before merging tickets.
 
10:40 AM
Interesting
 
Disclaimer: I never touched git even with a ten-foot pole. RCS, VSS, CVS, SVN, ClearCase, but never git. ;-)
 
I work once a week at a company as some kind of internship, and even though the company is small (~20 people), with 3 developers, there is still a QA team of I think 1-2 people depending on needs
I should be careful with doing commits without unit tests though. Because if I first commit, then test, then I am urged to make actual bug reports for failures in code. Which I wouldn't need to do if I also unit tested before making the commit
 
@skiwi well it's handled differently per company I think...
 
@skiwi One issue at a time
 
but with larger teams nobody is (supposed to be) working on master or development.
 
10:44 AM
Especially with Git.
One of the features of Git is that you can cherry-pick commits and apply them to other branches.
 
which is actually extremely awesome, given your commits are relatively small..
 
You have to take the changes one commit at a time, so you want your commits to be discreet.
 
as soon as you have large changes (renames and such) this cherry-picking gets hard.
 
Monking @All CRitters
 
Monking @rolfl
Well, I guess I'll remember that for the upcoming changes then
 
10:46 AM
0
Q: Hackerrank - Sherlock and the Beast

millenseedI am trying to solve the Sherlock and The Beast' HackerRank challenge. Most tests timeout, however when i try a custom stretch test case (T=20 and all N = 100000) it returns successfully, so I'm not sure what the problem is. The idea of the algorithm is that I find the number of possible combinat...

 
Now only If I could force netbeans to stop removing my unused static imports
or find an easy way to reimport them if they got removed after fixing imports
 
@skiwi well...
my eclipse currently does the same..
I really don't like it, that i can't wildcard-import the Mockito/Junit stuff..
 
I usually end up calling methods from static blocks
 
I have taken to disowning the management of Imports..... and let the IDE rule my import style.....
If it means doing slightly longer autocompletes/code, then so be it.
Assert.assertEquals(....) works for me.
Just spend a lot of time typing Ass<tab>
2
 
I might need a better name as ExceptionUtils then..
Checker might do
 
10:52 AM
0
Q: Classic ADO.NET and Repository Pattern?

user960567Is it fine to use Classic ADO.NET(Data-reader, etc) with a repository pattern?

 
Validate .... ?
 
It's more characters... and most methods start with check*** either way
 
`Validate.isNotNull(....)`
`Validate.isInRange(...)`
 
Checker.checkArgument vs Validate.?
What might be good for that... Thinking...
 
Mockito.verify(serviceMock, Mockito.never())
 
10:57 AM
NB 8.0, it would be nice if you could stop failing on refactoring class names:
public int decreaseHitpoints(final int decrement) {
    ExceptionUtilsCheckerecrement <= 0, IllegalArgumentException::new, "decrement cannot be positive");
    int oldHitpoints = hitpoints;
    hitpoints = (hitpoints - decrement <= 0) ? 0 : hitpoints - decrement;
    return hitpoints - oldHitpoints;
}
I renamed Exceptionutils to Checker there and I believe the method was something like: ExceptionUtils.throwOnFail(decrement <= 0, ...
 
Checkerecrement... I've got to remember that. :-D
 
hehe
public final class Checker {
    private Checker() {
        throw new UnsupportedOperationException();
    }
}
Any ideas how to unit test that?
 
Does Java toss a compile-time error on this if you attempt to instantiate Checker like C++ would? If yes, you can't IMHO...
...aside from writing a special compilation unit including wrapper that expects the failure.
Sorry, not my type of fish. I should shut up.
 
That's the idea, yep
 
@skiwi Typically by removing the 'private' from the constructor, and putting your unit-test class in the same package.
 
11:09 AM
@rolfl That looks ugly though...
 
I'm really taking stabs in the dark here as my Java is old and rusty, and I never worked with the advanced stuff like Reflection, but... can't you invoke the Checker constructor at runtime, through some indirection, to avoid the compile-time error and check for the runtime failure instead?
 
Surely yes, but would've been nicer to do not that ;)
(Untested)
@Test(expected = UnsupportedOperationException.class)
public void testPrivateConstructor() throws NoSuchMethodException, InstantiationException, InvocationTargetException, IllegalAccessException {
    Constructor<Checker> constructor = Checker.class.getConstructor();
    constructor.setAccessible(true);
    constructor.newInstance();
}
 
Ah screw it, I'm a C++ coder, I don't do "nice". :-D
2
 
Still, I wouldn't advice reflection or testing private methods, but hey I need to get my 100% coverage!
 
You *need* 100% coverage? As, say, company policy? Or is this a personal goal?
The best policy regarding converage I've seen so far is that a commit must not make coverage percentage *worse* than the previous one. 100% can be *very* tricky to achieve.
As in, say, testing private constructors in a language that doesn't have Reflection. ;)
 
11:28 AM
@skiwi - this is how I tested it:
(i.e. I did not)
 
If you were to create a tool that can automatically create correct unit tests, would you still need to manually test it?
@DevSolar Personal goal here
@rolfl I should learn about github.io
Is there a simple way to publish coverage reports there?
 
@skiwi: Then I'd go with "improve, or at least stay the same." Some things simply cannot be properly tested without making either the test or the implementation really ugly. Stuff like an ShouldNotHappenException in the default part of a switch: A good thing to have, but a nasty thing to write a test case for without putting testing-only code in the implementation (which should never happen).
 
@DevSolar That's a good call there
Actually enough reason to remove the private constructor test as 100% coverage is simply not possible
 
Another thing I never found a way to test is read errors. Not file-not-found, no-permission, or end-of-file, but a geniune read error. This can happen in the wild (like, someone pulls the memory stick, the NFS mount goes dead, or the hard drive crashes), but how should you ever trigger something like that in a unit test?
 
Can't you mount a robot that pulls out the memory stick (or disconnect/connect an USB drive, you are using C++ after all!) to test that?
 
11:42 AM
Yea... I'll try to talk Controlling into buying an ASIMO for that. :-D
 
It's all for tests... Gotta believe in them!
 
Did I mention that, when I took over this project, the amount of automatted testing was actually ZERO? :-D
 
ouch
Is it something critical?
 
And no-one thought that was a reason to worry too much. After all, they've been using this software for ages, surely they had discovered all the problems already?
 
That sentiment..
 
11:45 AM
Address processing and comparison. Whether H.P. Brewer and Hans-Peter Brower are the same person.
 
Could be useful to actually unit test that
 
Sounds innocent enough until you realize this is being used to determine your credit rating, for example.
 
Great, I just realised I forgot a null check on the String errorMessage argument
More unit tests!
 
Each bug you find in the code is a bug report against your testing. Each question the customer has is a bug report against your documentation.
However, some of the latter can be closed as "INVALID, RTFM". :D (Usually by politely pointing to chapter and verse of the doc answering the question.)
3
 
Wish I could tell that to my testcode
RTFI (I = Implementation)
I bet the person who created the Heartbleed bug wished that he did unit-testing and coverage-testing... Not sure if it would've helped though
Let's say you have a program processing a bounded integer, what makes more sense?
- Testing a few static values
- Testing a few random values in range
- Testing all values in range
 
11:53 AM
Testing border cases
 
What if all integers were allowed?
 
You know "domain testing"? Testing all is a waste of resources. Testing randoms is not useful. Test the values that are most likely to be border cases: INT_MAX, 1, 0, -1, INT_MIN.
 
I know about it, though don't think I've used it myself yet though
 
Then look at your coverage and see if you forgot some. ;-)
 
Does having a hypothetical 100% coverage mean that your unit tests are correct though?
 
11:56 AM
No.
 
Bugs can always slip through if there's some hidden changes
 
There's line coverage, branch coverage and path coverage.
And you really don't want to do 100% path coverage...
And even if your test code is "correct" and achieves 100% whatever-coverage, that still doesn't mean your code works as intended in all circumstances, because reality can still be surprising.
 

« first day (347 days earlier)      last day (3662 days later) »