« first day (345 days earlier)      last day (3689 days later) » 

2:07 PM
0
Q: MVC 5 & EF 6 - Repository & Unit of Work Pattern

Matthew HudsonI have been looking through Code Review on the subject of Unit of Work and Repository patterns and realised that my implementation appears to provide very similar functionality but in reverse class order/hierarchy. (Couldn't think of a better way to describe it sorry) This is one of the question...

 
I'm declining flags on this:
0
A: Similar methods using loops

user40637If you always use both functions together it might be faster to run the code in one pass instead of two, but here it is perfectly fine to use two functions.

Expect a meta-post on it.
 
just so you all know. Ruby is Real Code.
 
wat
What about Ruby on Rails?
 
monking!
@rolfl careful not to learn too much of C# when you review C# code, ...you might like it ;)
 
0
Q: Should I differentiate object types by calling methods via variables?

k0pernikusI have three JavaScript objects. The first one serves merely as a prototype. The other two are implementation of a specific type. var MainPrototype = {}; var SpecificType = $.extend(Object.create(MainPrototype)); var OtherSpecificType = $.extend(Object.create(MainPrototype)); I am missing the...

 
2:22 PM
@Malachi Real, yes. Good...that's more controversial. e.g.: chat.stackoverflow.com/transcript/message/15834295#15834295
 
@JerryCoffin that happens with any code base... Microsoft does it all the time
 
poor ruby devs
 
people keep talking about Java 8 as well, and the bugs in there.
how are the bugs in Ruby's source code different than the bugs in these other languages???
 
0
Q: What are the correct action to take when there is a 'bad' answer?

rolflWhen there is an answer you feel is 'bad', what are the correct actions to take? For example, the question: Similar methods using loops has an answer: If you always use both functions together it might be faster to run the code in one pass instead of two, but here it is perfectly fine to...

 
@rolfl downvote
 
2:25 PM
There was more than one moderator-flag applied to that answer.
 
@rolfl why you ask a question... You answered it in question-body...
 
Because I am late for a meeting in a few minutes with a top-notch exec....
Feel free to edit/etc. so the format is better.
 
@Vogel612 Voted.
 
Gotta run.
 
good luck
 
2:26 PM
In fact, please make it nice and neat.
 
@Malachi, you know how to avoid that... instead of updating parts of your codebase, just add a new method with the same name with a new number next to it
 
@BenVlodgi lol
 
I used to have to work with the solidworks api
look
DeleteFactes5()
this was the IBody2 interface
 
@Ben ouch...
could someone slap the developers of that API?
 
@Malachi yah, what was worse is that some of the new methods didn't even work right, there were times where I had to go back to deprecated methods because they had the right functionality
 
2:28 PM
"obsolete. Superseded by IBody2::IMaterialPropertyValues2."
"not implemented"
 
@BenVlodgi lol, that makes it even better...
 
that API is a mess
 
@BenVlodgi we finally got a bunch of stuff on a Team Foundation Server. I like that idea. I want to do it with my code at home too.
 
Public Interfaces: IMaterialProperties, IMaterialProperties2, MaterialProperties, MaterialProperties2.
 
maybe not TFS but something where I can keep track of what I did.
 
2:30 PM
Looks like you've seen horrors
 
@Malachi nice, TFS is nice
@Vogel612 @skiwi it was a nightmare
 
except for I have never used it before so I am learning along the way...lol
GGFM - Gotta go for a meeting
2
 
@BenVlodgi reminds me of Ext.Net.
 
Also, everything in that API returns dynamic... giant pain
 
@Malachi Depending on how the code is used, yes, fixing almost any bug (for one obvious example) can break something that depends on it. It just happened that in this case I'd just read that no more than a minute before you posted, and found contrast...interesting, to say the least.
4
 
2:33 PM
@JerryCoffin That's horrifying
 
2
Q: What are the correct action to take when there is a 'bad' answer?

rolflWhen there is an answer you feel is 'bad', what are the correct actions to take? For example, the question: Similar methods using loops has an answer: If you always use both functions together it might be faster to run the code in one pass instead of two, but here it is perfectly fine to...

 
@Malachi There probably aren't a lot of fundamental differences. Based on observation, there do seem to be some practical differences though. For one thing, breakage in most languages seems to follow somewhat more predictable patterns.
 
2:52 PM
0
Q: Why "this" isn't my object anymore when called from callback

Anc AinuMy problem is simple, when I create my object, I do a request, then I want to fill data from a callback. But this isn't anymore my object. How to find this ? What's the way ? var ParentMissionsViewController = function() { console.log(this); session.requestChildrenMission( Mission.Status...

1
Q: Is the way I used threading in Python correct?

backwardmI'm learning how to use Python with the Raspberry Pi. I successfully followed the tutorial for how to have a Python script run on the Pi to check for new email and turn on a LED if any new messages are in an inbox, but I wanted to give myself a challenge by adding a feature to blink a secondary L...

 
I'll leave the chat for today. But tomorrow, when I come back, I better have reached the rep cap.
(still 100 more reputation to go...)
 
@Morwenn you better put out a few good answers then ;)
 
@Vogel612 That may be a problem. I won't be able to connect before tomorrow :/
 
well then you probably won't hit rep-cap ;)
 
That makes me sad :'(
Whatever, see you tomorrow^^
 
3:02 PM
cya tomorrow ;)
 
@Vogel612 but it looks so pretty
 
@Ben Ext.Net?
 
@Vogel612 the website does
 
don't be fooled..
it's a pure javascript framework
and these guys had the idea: "Why not have this as C# too?"
 
fantastic
=\
 
3:05 PM
and wrote some dll, that generates the corresponding javascript....
if you want to use it for the smallest feature you could think of, you get a 2Mio. lines Javascript..
that doesn't even produce meaningful error-messages.
you have to debug C#-Code in the Developer Console of your browser..
 
Sounds fun!
 
And if that weren't enough they also added the possibility to do the whole thing in XHTML.
 
Not
 
this results in 4 ways to do the exact same thing.
 
@Vogel612 hot dang.. that is an interesting idea, but it sounds incredibly bloated
 
3:07 PM
js, C# (code behind), XHTML, C#(razor)
I'm glad i don't have to work with it anymore.
I asked 22 Stackoverflow questions on that thing
some remain unanswered until today..
 
daaaang, that is indeed messed up
 
I really love how my two "nice answer"-badges were awarded to answers on the same question T.T
@BenVlodgi personally I love this one the most.
 
lol
 
When is it a nice answer? was it 10 votes?
 
yea.
you got one too.
17 hours ago ;)
 
3:16 PM
Wow that doublequoting trick
I've got 8 nice answers on SO, and probably most on java 8
 
@skiwi that was in the XHTML approach. But hey the defaultValue attribute is supposed to be a JS-Variable.
 
Weird stuff going on I see ^^
I just noticed that I've always been using a blocking variant for Deques in Java
Now i see I need:
private final Deque<Card> deque = new LinkedList<>();
 
@JerryCoffin I see what you are saying and Nice XKCD reference
@JerryCoffin you forget that all applications were coded by humans, which means that all code was created by humans, and we are very prone to mistakes.
 
3:38 PM
has just been Malachi'd
0
A: Very basic calculator using methods

Malachiyour flow is a little clunky. if I were going to calculate something I would do it in this order Number1 then operator then Number2 This way I know what I am doing, especially when playing with Division I think you should ask for the first number then ask for the operation and then ask fo...

 
I just read that as your flow is a little drunky
2
 
@skiwi that works too...lol
@skiwi are you a little drunky?
 
Unfortunately not
I'm just a little bored
 
6 votes away from getting my C# badge!!
 
@Malachi I don't like that answer... you are suggesting to change the complete structure of the "project"...
 
3:45 PM
@Vogel612 the name of the project begs for the structure change.
 
What? An ingame knife in CS:GO sold for $23,850 appereantly...
 
@skiwi some people.... argh nevermind don't feed the trolls.
@Malachi I think the flow is fine that way...
 
it's a calculator, it should function like a calculator, and read in mathematical sentences.
 
@Mat'sMug Not that anyone cares ... still @0.
 
@Vogel612 the next step is going to be changing the flow of the application.
@rolfl what are you talking about?
 
3:47 PM
Then write that the name is not a good choice...
 
@rolfl And, was the top-notch exec also late, making you on time?
 
/wave
 
Nope.... I squeeked in .... meeting with a Fellow .... ( remember, that IBM employs 450K people .... )
 
@JeffGohlke what do you think about my review of that java code???
 
@Malachi Which one?
 
3:50 PM
0
Q: AnySetValue - a set of with mulitple types of values

KlaimI would like a review for this code which is used apaprently successfully in my current project. More info are available in this gist but I'm pasting here the main info: The project use C++11/14 as provided by VS2013 (no CTP) and Boost. I didn't try to compile it in other compilers yet (lac...

 
@rolfl Sounds like an interesting system.
 
11 mins ago, by Malachi
0
A: Very basic calculator using methods

Malachiyour flow is a little clunky. if I were going to calculate something I would do it in this order Number1 then operator then Number2 This way I know what I am doing, especially when playing with Division I think you should ask for the first number then ask for the operation and then ask fo...

@rolfl good meeting????
 
@skiwi It is .... Fellows get to do what they want to do ... and this one is particularly interesting, and thus I get to do interesting things ...
 
@rolfl which name is yours?
 
@Malachi Nice! Good tips for expanding the project in the future.
 
3:52 PM
@Malachi if you had looked at the JDOM code, you'd know that he's named Rolf Lear
 
^^^^ that
 
@rolfl So working for a fellow, allows you to do whatever you want, as long as it's the same as what the fellow wants you to do?
 
@rolfl are you sure it isn't Rolf Landauer (1969)
 
Heh, I imagine he's dead.... ;-)
 
@rolfl I figured that your name would be up there.
 
3:53 PM
He is:
Rolf William Landauer (February 4, 1927 – April 28, 1999) was a German-American physicist who made important contributions in diverse areas of the thermodynamics of information processing, condensed matter physics, and the conductivity of disordered media. In 1961 he discovered Landauer's principle, that in any logically irreversible operation that manipulates information, such as erasing a bit of memory, entropy increases and an associated amount of energy is dissipated as heat. This principle is relevant to reversible computing, quantum information and quantum computing. He also is re...
 
so we have been talking to a ghost all this time!!! JK
I knew there was life after death...JK
 
Hm. I always read "rolfl" as "rofl". Haha
4
 
@JeffGohlke me too
 
Are you trying to suggest that after death we reïncarnate with the same first name and same first letter of our last name?
 
@rolfl reading your name again I can't help but wonder, are you in cahoots with Anna Lear?
@skiwi good luck finding my previous incarnations then.....
 
3:56 PM
Nope, I have e-mailed her and we have determined we have no common ancestry
 
This answer deserves more upvotes than mine on there. Can someone go show it some love?

http://codereview.stackexchange.com/a/46817/20523
No, no, not MY answer. Josay's answer. Haha. His is the actually informative and thorough one.
 
@Jeff your's is good too... couldn't help but also upvote it ;)
I didn't know people actually recommend writing all into main...
0
A: Very basic calculator using methods

DrWestyou could write your all methode in the main, like this: public static void main(String[] args) { .... Integer numberOne = 0; Integer numberTwo = 0; System.out.print("\nFirst Number: ") numberOne = scanner.nextInt(); System.out.print("\nSecond Number: "); numberTwo = ...

 
Yeah. I think that guy's point was just that the program is so simple that there's not really much need to separate out functionality into different methods.
Not really conducive to learning, but... shrug
 
the problem is OP is here specifically to learn best practices of OOP... and separation of functionality is one of the main points of OOP.
 
Yeah, I agree that it's not a great answer, even though it's technically "correct".
 
4:02 PM
0
Q: Installing Mods With Python (v 2.0)

KnightOfNiFirst of all, thanks so much for helping me out with my original code (Installing "mods" with Python). I made some changes to it based on your suggestions, but then I lost my flash drive and had to redo it. I have a suspicion that my second version was better than this one, so could you all help ...

 
I just found a bug in a procedure that ends like this:
                                                                                End If
                                                                            End If
                                                                        End If
                                                                    End If
                                                                End If
                                                            End If
                                                        End If
4
kills me everytime.
 
I love it.
This is why I encourage my contractors to return early and return often.
 
can someone slap the guy that wrote this? Has he heard of Guard-Clauses?
 
20 levels of indentation, concatenated SQL strings, one bug in one of the SQL strings, and at least 2 bugs in the looping logic. And they call me a "perfectionnist". I hate this job.
 
@Mat'sMug Would you be allowed to show the full procedure?
 
4:05 PM
heck, why not
    Dim rs As ADODB.Recordset
    Dim rsEDI As ADODB.Recordset
    Dim rsBar As ADODB.Recordset
    Dim rsBar2 As ADODB.Recordset
    Dim rsGlassId   As ADODB.Recordset
    Dim rsOpening   As ADODB.Recordset
    Dim rsSDLGlassID       As ADODB.Recordset

    Dim FlgBarF1S    As Boolean
    Dim qry          As String
    Dim strGlassID   As String

    qry = "Select Concepto from ContenidoPaf with (NoLock) where  Numero= " & numero & " and version=" & Version & " and orden=" & Position
    Set rs = GetAdoRecordset(qry)
 
What on earth...
 
That's actually physically painful.
 
Glad I'm not alone
 
that isn't the worst VB I have seen. I maintain one that is worse at least in my opinion
 
Could someone tell my boss that it's not NORMAL to have such shitty NEW CODE?!!
7
 
4:07 PM
Anything above two levels of indentation gets on my nerves.
 
and it has to do with reading an XML file
 
@skiwi I saw 10 levels one time.
 
rewritten (not yet refactored):
    Dim cmd As New SqlCommand

    Dim sql As String
    sql = "SELECT Concepto FROM dbo.ContenidoPAF WITH (NOLOCK) WHERE Numero = ? AND Version = ? AND Orden = ? AND Concepto LIKE '%' + ? + '%'"

    Dim models As SqlResult
    Set models = cmd.QuickExecute(sql, numero, Version, Position, "F1S")

    Dim modelRow As SqlResultRow
    For Each modelRow In models

        Dim modelCode As String
        modelCode = modelRow("Concepto")

        Dim bars As SqlResult
        Set bars = cmd.QuickExecuteStoredProc("dbo.USR_Production_GetTypeBarreXML", numero, Version, Position, "HYBDIDE")
 
Sadly, I see this kind of thing in my production code sometimes. -____-
 
I don't think this code has that many ifs though
 
4:08 PM
Three of them were case statements (yes, case inside case inside case, with a couple of for loops and some if statements just to confuse things).
 
@Mat'sMug thank you
At least there are people off worse than me..
 
@Vogel612 that's the response I was hoping to get over here. Didn't happen.
 
@Mat'sMug so much wat
 
so much management incompetence.
 
WTF's/minute: (OverflowException)
8
 
4:10 PM
In contrary, my production code ends up with hundreds of different files, while they only have to maintain a handful.
 
definitely more.
 
I keep telling my boss that any real programmer wouldn't want to come and work with such code.
 
So switching the workplace didn't work out?
 
I have a question :o consider this code (assume it could be part of a library)
public void add(final Card card) {
    Objects.requireNonNull(card);
    ExceptionUtils.throwOnFail(this::isFull, IllegalArgumentException::new, "hand is full");
    list.add(card);
}
Now Java 8's compiler offers me the option to catch possible NPE's if I annotate it as final @NonNull Card card
Would it then be ok to remove the explicit check if a NPE can be generated by the using code?
ArrayList allows null values, so removing it here might be a no-go? As I do not want null values propagating into the list.
 
so instead you'd have: (?)
public void add(@NotNull final Card card){
      ExceptionUtils.throwOnFail(this::isFull, IllegalArgumentException::new, "hand is full");
      list.add(card);
}
 
4:16 PM
Yeah.. but here the crux is that it will not throw a NPE even if null is implicitely being passed in..
 
@MattS. Welcome to Code Review.
 
well then your code would be broken.
 
I'm still trying to figure out if type annotations are useful or not
 
0
Q: Single Rotate Method

akinuriI just started coding a simulation-like application. It's about our solar system. Right now, I'm working on rotating the moon. I have this constructor function Mass(elm) { if (typeof elm == "string") { this.elm = document.getElementById(elm); } else { this.elm = elm; ...

0
Q: Define relation parent \child

user2350469I have the following table ParentId id operator 12 13 * 12 14 * 12 15 * 12 1 - 12 2 - 13 21 / 13 20 / I define the following class Node class Node { p...

 
@200_success Thanks.
 
4:19 PM
^ Define relation parent \child seems off-topic.
 
@200_success is off-topic
 
Thanks for those who helped me improve and perfect my Python port scanner, by the way. Believe it or not, it actually helped me find a suspicious process running on port 62522 on my work computer.
 
burried in a code block: "How can I modify the code above in order to take in consideration the value of Operator(group by Operator in sql) ?"
 
This question seems to be off-topic, as it is asking about "How do I implement [...]". For this kind of question, please refer to Stack Overflow. As soon as you made your code work to your satisfaction, you are welcome to edit your question, to include your working code. We'd be happy to review it then ;) For more information, please refer to the help centerVogel612 47 secs ago
 
@Vogel612 thanks! however I'd consider it more of a "gimme teh codez" question, which would still get hammered on SO
 
4:23 PM
hum.. yea...
Added a little sentence: "You should reformulate your question to meet the guidelines there. Include attempted solutions and you should recieve a good answer."
 
well done!
 
Feeling great.
*successfully improved communication in writing by 1 level*
 
@Malachi I'm ok with the ifs, to an extent - what I can't stand is opening a recordset and/or reassigning the recordset reference while you're looping in that recordset, and opening new connections that never get closed all the while. And the concatenated params in a query that's running in a loop. I mean, come on!
2
 
I love traversing our product to get to the sourcecode

\<Public Product Name>\source\<Sub Product Name>\03-Development\Code\Source
 
wut?!
 
4:29 PM
and their build paths are crazy too
 
0
Q: Tic-Tac-Toe implementation and computer should not lose

yangthemanI have implemented Tic-Tac-Toe so that human can play with the computer, where the computer should never lose. I did a simple analysis before implementing, and I found out that there are certain cells you want to occupy (I named it BEST_CELLS). Here is the link to the implementation: https://gi...

 
this stuff is some serious frankenstine software
written in multiple languages
 
@StackExchange code-in-a-link
 
most logic happening in the database
 
@Mat'sMug wow..
simultaneously almost exactly the same...
 
4:31 PM
@Vogel612 beat me by a splitsecond, but.. typo here: [help/on-topci]
 
no more ;)
TTQW
cya later guys ;)
 
and ..Jamalized. Off-topic, but pretty ;)
later @Vogel612!
 
peace out @Vogel612
 
Could somebody with ammunition take a look at this answer?
0
A: QuickSort C# Implementation

rolflWith QuickSort, the complexity always comes down to two things: how you deal with equal numbers (duplicates) which index you use to return from the partition (left or right) You need to decide up-front whether the pivot value is going to be in the left partition, or the right partition. If th...

(and downvote as needed ;)
2
 
4:53 PM
@Malachi this isn't the worst code in that 180K LoC project... (which I suspect could very well be refactored/rewritten in less than 60K LoC)
 
@Mat'sMug i just got done trying to write some C# into a VB project I am trying to add some things too....
it was giving me all sorts of weird errors, I didn't understand at first
 
Wow Jon Skeet has 666K rep on SO.
3
 
5:19 PM
Migrated zombie down! (and ..back to [monkey-coder] work now)
(nothing against monkeys)
 
@Mat'sMug do you have any good sites to show me how to set the Debug/Release on VS so that I can have one connection string in the App.Config (among other variables) so when I need to test I don't have to search my code?
I might have found what I was looking for
maybe not....
 
@Malachi what?
@Malachi you have certian code that conditionally compiles in Debug or Release
 
@BenVlodgi I want all my connection strings to change when I set it to Debug or Release
 
re
 
@Mat'sMug probably will say that tomorrow too
 
5:31 PM
@BenVlodgi ummm........Y...e....s...?
 
@Malachi yes, you can do that
 
@BenVlodgi how do I add it to an application already built? I have a configuration file. but I don't know how to make it so that microsoft knows what I am tlaking about
 
@Malachi is this for an application of yours?
you either built it in debug or release
 
@BenVlodgi it's a work application, semi-legacy code. I have made some changes. but I don't know which is which. the drop down says debug right now
 
@Malachi okay, so now inside this code, you want something to change depending on how you build it
 
5:35 PM
I think that is a yes
lol
2
 
@Malachi (Assuming C#)
        string Foo()
        {
            string connection = "boo";
#if DEBUG
            connection += "debug";
#elif RELEASE
            connection += "release";
#endif
            return connection;
        }
 
no, it's VB.
 
works in VB
Private Function Foo() As String
	Dim connection As String = "boo"
#If DEBUG Then
	connection += "debug"
#Elif RELEASE Then
	connection += "release"
#End If
	Return connection
End Function
 
where do I add this? inline? or ...
 
# means compiler directive, so it is something that the compiler takes as a special command, which is removed durring compilation
 
5:40 PM
hey you learn something new every day. what language is it written in? VB?
 
only one of those lines of code will be compiled in, and the difference depends on which release mode is chosen
first one is C#... second one is VB
 
I mean the # delimited code.
the #Elif had to be #ElseIf
 
anyone know c++?
 
@Malachi strange... I was lied to then
@Hellovart most of us do
 
@Hellovart: sort of
 
5:47 PM
what would happen if I tried to call a constructor without storing it in an object
Contructor();
s
 
what do you understand under (not) storing a constructor in an object?
 
@Hellovart then the object would be constructed, the constructor would run, and then you would lose your pointer to it
 
So, lets say the constructor had some simple assignments being done, it will do those and it also prints something to screen
it will do that but lose scope immediately
and call deconstructor>
?
 
yes
 
then i passed that question on the exam
haha!
 
5:50 PM
You can even run a whole program in the constructor
 
lol
2
 
@Hellovart you should just call a method to do those things though
 
It's not uncommon to see that in Java's main method
 
(btw you can edit your posts for 2min)
 
@BenVlodgi not quite – there are no pointers involved here without the new operator
 
5:50 PM
@BenVlodgi it was a trick on a programming walkthrough in my exam
 
@Hellovart Yep
 
@amon yes, my bad... I just assumed he would be using new
 
@Malachi check this out:
8
Q: Visual Studio: differentiate app.config for debug and release mode

KoreyIs there a way to automatically use a separate app.config when building in release mode? In other words, I want to test with one app.config, and release with another. Currently, I keep a separate copy called app.config.production, and manually overwrite bin\Release\Application.exe.config after ...

 
@BenVlodgi other than that it seems to work. I haven't tested it yet I have some other functions that I want to build the same way for other variables. this is an email sending application
 
(sorry for delay)
 
5:52 PM
@Hellovart: You can't call a constructor directly. You can call it with new or by creating a local object (which then calls in indirectly for you in both cases). In both cases an object is created.
 
@Mat'sMug it's all good
 
@LokiAstari so if i called it, it would give me an error?
 
It will not compile.
 
then why was it written in the exam
 
I think Loki is nitpicking the language a bit here :)
 
5:54 PM
To see if you knew that you could not call it?
Am I missing something.
 
clearly i wouldnt know if my professor never taught us that
 
@Nobody: That seem a very fundamental thing.
 
Yes but I think by calling a constructor he actually means allocating a temporary object:
std::list();
 
no i dont
 
e.g.
 
5:55 PM
i just meant directly calling it without it being assigned
 
@Nobody I would like to confirm that.
 
@Hellovart: which creates an temporary object
 
11
Q: C++ Object without new

PintSizedCatthis is a really simple question but I havn't done c++ properly for years and so I'm a little baffled by this. Also, it's not the easiest thing (for me at least) to look up on the internet, not for trying. Why doesn't this use the new keyword and how does it work? Basically, what's going on he...

Second answer
 
CPlayer(position, attacker); <--- for example was all that was called
 
@Hellovart: class S {}; You can not call S::S() directly. That is a compiler error.
 
5:56 PM
damnit
 
OK. That creates a temporay object.
 
so i am right
 
sort of
we need more details
the temporary object is created and is alive as long as it is needed
 
just calling the constructor like a normal function
well it wont live long because isnt being stored
 
it is stored but not in a named variable
 
5:58 PM
exactly
so the destructor calls imediately after
after the ;
 
The temporary object will be detroyed at the end of the statement. Both its constructor and destructor will be called so any side affects from these (like print statements) will take affect. But because the object is destroyed at the end of the statement then it will not exist after that.
 
@Mat'sMug sounds like the same thing that @BenVlodgi said, except instead a single variable it's the whole config file
 
Okay, that all i needed to know, so i did it right
 
@Malachi my way is just a code way, hardcoded changes... there are other ways to specify files that get built into your project depending on the build mode, also build paths and stuff.
 

« first day (345 days earlier)      last day (3689 days later) »