« first day (872 days earlier)      last day (3163 days later) » 

3:00 PM
3
Q: Python OOP shopping cart

burce panI am a new Pythoner, and don't have good knowledge of OOP. I completed the following task, but I feel the code is not good. I welcome recommendations to improve the code. You need to create the foundations of an e-commerce engine for a B2C (business-to-consumer) retailer. You need to have a c...

 
3:15 PM
incoming question with a title that will probably come up in Google searches :)
googles up ...or not.
 
Just when you think you've seen it all: codereview.stackexchange.com/review/first-posts/45368
 
0
Q: Working Days DateDiff function

Mat's MugI have a calendar table with a record for every date I need to care about (i.e. 365 records per year), with various meta-information about each date, including the weekday, the fiscal calendar week, month, quarter and year it's under, whether there's a Holiday on that date, etc. The table has th...

 
Technically it's a valid review, but still.
 
0
A: Python OOP shopping cart

Ethan BierleinThere is no need to create a specialized implementation of a dictionary, as you've done here: class Cart(dict): #cart dict format: {itemname:[price,number]} def ShowCart(self): return self This, literally does, nothing. The method ShowCart essentially just returns the diction...

 
Zak
@Mast If you hadn't beaten me to it, I was about to write one of my comments explaining that the point of CR is to educate through explanation and example.
 
3:20 PM
@Zak Feel free to comment.
I assume you put the downvote on it?
 
Expanding on what Mast and Zak said, we'd love if you'd add a more detailed explanation, along with some example code to demonstrate what you've said. Welcome to Code Review! :-) — Ethan Bierlein 5 secs ago
 
Zak
@Mast nope, not me
 
Nothing says 'Welcome to the community' like a downvote.
2
 
Zak
I never downvote first posts
@Mast Because that ^^
 
Put a +1 on it to cancel. We're not that harsh.
 
3:24 PM
Same here
I think it's a perfectly valid answer
It just needs a little cleaning up
 
It's valid. Not necessarily a good answer, but still valid.
 
Zak
@EthanBierlein True, yes, a valid CR answer, I'm not sure. Maybe, technically, but it's not the kind of answer I think we want to encourage.
In its current form anyway
 
I tend to skip voting in these cases
 
It's a comment as it stands. But my contribution will only be to upvote the comments which say so.
 
that said, I need to share this:
> HoaxWagen. Das Auto.
4
 
3:26 PM
^^
 
Zak
@Mat'sMug I remember seeing that and thinking 'Really, you really thought you could get away with that?
 
0
Q: Counting sort in python

hjpotter92I wrote the following function to implement counting sort. def CountSort( Arr, Max ): counter, retVal = [0] * (Max + 1), [] for _ in Arr: counter[_] += 1 for i in xrange( Max + 1 ): retVal += [i] * counter[i] return retVal NOTE The function takes the arr...

 
I'm sure with sufficient thought I could come up with many ways to do the same thing. Is it running too slow? If nothing is wrong with it and all you want ins for someone to look over your code, you are on the wrong site. It might be better on Code Review but I can't be sure because I'm not very familiar with their rules over there. You would have to check the rules and make sure your question is a good fit before asking over there. — Becuzz 5 secs ago
 
Zak
It was quite amusing to read how it came about. Essentially, the regulator had discrepancies when testing some vehicles. VW said it was down to a combination of conditions/variability/other source of randomness. Regulator continued to find discrepancies, told VW "Either you figure out why this is happening, or we won't let you sell any of your new models. At which point they could either face financial oblivion or fess up, and face only a lesser form of financial oblivion :)
 
It's given the British something else to talk about apart from pigs.
 
3:43 PM
0
Q: Code for a past job assessment assignment

FoxOkay, so I wrote a small program to address some assignment tasks related to making a game called 'Dice on a Yacht'. I sent the code to be reviewed by a company I was applying for, and I have not gotten the job (as I had expected shortly after submitting code and thinking over it further). I real...

 
i think, better place for your question is codereview.stackexchange.comBacks 18 secs ago
It's better to post your question at codereview hub. Don't forget to include actual code you've written. — Andy Korneyev 6 secs ago
 
Monking
 
monking
 
Zak
Right, TTQWAGTB. See you all tomorrow.
 
thank you very much for your professional advice, and i will improve the code. — burce pan 2 mins ago
I think professional is a stretch...
 
3:52 PM
1
Q: MSSQL query with join and where clause

Jonah PereiraI've the following tables Candidates Id Name PicId 1 Tom NULL 2 James 1 3 Bob NULL 4 Manny 2 Attachments Id Name 1 One.jpg 2 Two.doc 3 Three.rtf The join table AttachmentCandidate CandidateId AttachmentId 3 1 3 2 4 3 So fr...

0
Q: Pattern matching in generic lists in Java using naive and Knuth-Morris-Pratt algorithms

coderoddeGiven a sequence of objects \$\langle x_1, x_2, \dots, x_n \rangle\$ and a pattern sequence \$\langle y_1, y_2, \dots, y_m\rangle\$, the pattern matching problem asks, whether there exists an non-negative index \$i\$ such that \$i \leq n - m\$ and for each \$j \in \{1, \dots, m\}\$ \$x_{i + j} = ...

0
Q: write data from object to file

Redaslet's say I have a class class Data { public string Name { get; set; } public string LastName { get; set; } public int Age { get; set; } public Data(string name, string lastname, int age) { Name = name; LastName = name; Age = age; } } I want to ...

 
Hrm, what's the consensus on edits where you apply the markdown formatting to make it display properly as code? It is technically a code edit, but blanket indentation across the post
 
that's fine
not everyone knows (/bothers to read) what the markdown formatting is for a code block
 
Aye. It's just a formatting change and so legit
 
it maintains the original indentation
 
@Mat'sMug The problem is that it changes based on what you are doing in the document.
 
3:55 PM
Cool thanks. I'll know for next time now.
 
I.e for a block-quote, the first line should be > then five spaces, rather than four.
 
Had somebody add a whole extra suggestion to one of my answers, once. He wouldn't accept that it was wrong but gave up the edit war. That behaviour I hate.
 
Then each subsequent line can either be four spaces, or > followed by five spaces again.
(I use markdown on another site of mine.)
Bitbucket is so handy.
I can finally add all my projects to a private, stable source control.
 
NAA:
-1
A: write data from object to file

George FindulovExample code: private void Main() { var data = this.GetPersonData();| this.SaveToFile(data); } private List<Data> GetPersonsData() { List<Data> data = new List<Data>(); data.Add(new Data("A", "B", 15)); data.Add(new Data("C", "D", 20)); return data; } private void Sav...

 
@Mast I think that question needs improvement (or VTC) as well.
 
4:08 PM
Code dumps are only helpful on Code Review if they indicate why the code is better than the original code. In this case, while it may seem you are being helpful (and in a sense, you are), you are also contributing to a scope problem on Code Review, where people are asking for others to just solve their problems, and not review their solutions. Code Review is about improving solutions, not providing solutions. — rolfl 13 secs ago
 
Also, to anyone, I accidentally hit "Approve" on this edit
 
@EBrown Well, that's a Fubar.
Why did you make people go in there now and reject a good edit?
 
@rolfl Yeah, that one is my bad.
@rolfl It really wasn't a good edit in my opinion.
 
I am confused..... what edit did you accept tha tyou should not have?
 
@rolfl The one where only the title and a (very) small bit of the post were edited.
 
4:11 PM
it hasn't gone through yet
 
I have no idea on that new edit, though.
 
oh
 
Hmmm... @Mat'sMug - it's the same user... accounts need merging
I approved the edit
but it needs more.
 
@rolfl Ah, that makes sense.
I didn't realize it was the same user.
 
Finally, this is not a place for code review (there are other sites for that) — KevinDTimm 1 min ago
 
4:13 PM
@EBrown You're not supposed to
.... the system is supposed to figure that out, and, as an ex-mod, I can tell when it fails.
But regular users would normally be unaware.
 
Alternatively try be clued in by the fact that they both have fox in their name.
 
And almost-consecutive user-id's
85205 & 85207
 
0
Q: Best practices for managing multiple forms with individual updates and batch delete with checkboxes

morbidCodeI have a JSP page with a table containing data from java.util.List. The items from the list are taken from the database. Each row has an edit button that will get all the values from that specific row to be edited on another page Each row has a checkbox where if selected means it will be delete...

 
@rolfl pending. thanks
 
4:35 PM
Man, GitHub integration in C# is such a cluster.
At least, for a webhook.
 
@EBrown Not content with Visual SourceSafe? ;)
 
@itsbruce With what?
 
That's exactly what Microsoft's own engineers say when you ask them about it
 
@itsbruce Oh I wasn't talking about the Source Control part.
I was talking about integrating a webhook.
 
It's an old joke, anyway. Almost nobody at MS ever used it and it was their own product. TDF sucks less.
While still being a sucky, centralised waterfall
 
4:47 PM
gotta love sucky centralized waterfalls
 
-1
Q: Program needed for homework please

Ahmed MohamedI'm really getting frustrating writing this program that is due for tomorrow. here it is: The program: You are to write a program called MinilabLoopLogic which does the following: • Asks the user to enter 2 integers (can be one prompt or two) • Gets and stores the ints • Explains that ...

 
@CaptainObvious please
 
There is no Stack Exchange site that can help you. Do your homework yourself, you're not helping yourself at all and not learning anything by trying to take credit for someone else's work. — Mat's Mug ♦ 6 secs ago
and gone
 
Why do so many CS courses start by asking beginners to write code that asks for input and prints to the screen? So much more important for them to just learn how to make it function.
 
Hello, DROP TABLE Students;--
5
 
4:59 PM
@Mat'sMug There's an XKCD for that.
 
0
Q: Trying to use global variables for referencing directories in Python 2.5

DazI am writing a small utility that reads a number of print files to extract out financial data, and then build a spreadsheet populating the data in specific cells. I have it working, but it's not elegant and certainly not what you would call pythonic, so I am rewriting to make it more efficient a...

-1
Q: two intersecting cirlces in java

Ahmed MohamedI have an extra credit project and I was hoping someone could help me with it is to write a two intersecting circles in java. I really need this project to get the extra credit. I would really appreciate the help. Thank you so much. Email: ahmedtoon@gmail.com

 
@Mat'sMug Congrats, students are no longer asking questions now
2
The persons however still are :D
 
@CaptainObvious and banned.
I think that was the fastest Q-ban witnessed
 
@Mat'sMug BOOM!
 
expects new account created shortly
@skiwi I didn't do anything. OP Q-banned himself all alone.
 
5:03 PM
@Mat'sMug So we do have a bot that bans users? ;)
 
Since you've got working code and are asking about performance, the Code Review Stack Exchange should be a more appropriate place for this question. — Trobbins 25 secs ago
 
@skiwi the system works that way
 
How many questions did he get deleted in a row?
 
I've already disclosed more than I should have :/
 
Just those two I see up there ^?
 
5:05 PM
whistles
I think there's a time factor involved, too
 
And a quality factor
 
@Mat'sMug So I have about 10 models and about 9 events to handle GitHub webhook stuff.
 
@rolfl I can't believe I haven't thought of adding that column in my FiscalCalendars table. That should considerably speed up the index seek (I'll probably just need one on that single DateType column, if at all).
context:
1
A: Working Days DateDiff function

rolflYou have a physical table that has been established for the purpose of managing calendar dates. This is great, but with just a little more work it can be extended to do so much more. Consider adding a column "DayType", with values like: 0 -> Normal 1 -> Weekend 2 -> Holiday You could add this ...

 
Yeah, well, sometimes it is hard to see the forest for the trees ;-)
 
other than that, CTE isn't overkill?
wait, yes it is
 
5:15 PM
I think, if you get the column right, a standard inner join would be all that's needed.
No function at all
 
well.. I have an OrderDate and an InvoiceDate, and I need to compute the number of workdays between the two. no function at all??
I see the function as a custom little DATEDIFF that works off this calendar table
 
OK, you need a count... hmm... A function may be nice
A function reduces the problem to a somewhat linear one, though, not a set-based one.
This can be OK, but I would perhaps try with a different approach..... let me think more
 
want to see the actual query that's using that function?
 
No.... cat on keyboard.... no need for that. I think you're right that the function would be useful. A CTE with a range-based process would be about the same.
 
and the function is reusable. it's settled :)
 
5:28 PM
this question would be better suited for codereview.stackexchange.com/ — 3dd 47 secs ago
This belongs on code review — Smac89 53 secs ago
 
0
Q: Making choices in a text adventure game using Processing

CristhianI'm new to programming and I want to make a text adventure game using Processing but can't figure out how to create choices that the player can make. I want to have the player make several choices throughout the game and have the story change based on each decision made. I was thinking of using t...

 
possible answer invalidation by Programmer 400 on question by Programmer 400: codereview.stackexchange.com/posts/105231/revisions
 
@CaptainObvious That definitely needs work.
 
@Mat'sMug - another merge misfire?
 
possible answer invalidation by Redas on question by Redas: codereview.stackexchange.com/posts/105499/revisions
 
5:40 PM
-3
Q: write data from object to file

Redaslet's say I have a class class Data { public string Name { get; set; } public string LastName { get; set; } public int Age { get; set; } public Data(string name, string lastname, int age) { Name = name; LastName = name; Age = age; } } I want to ...

All together now.... You have a class
 
-1
Q: More optimal way to write below code

Guruprasad RaoI am having below code which actually checks whether an image whose parent is .papers.left has completely loaded into DOM and if yes then the background of its right content's height has to be same as the background of this images parent. So below is html to understand the structure <div class="...

 
http://www.commitstrip.com/en/2015/09/23/going-to-war/
CommitStrip - Blog relating the daily life of web agencies developers
Going to war
CommitStrip
1443029841
3
 
@rolfl Why did that question get so many downvotes? It looks OK to me?
 
@Phrancis Only after the edits.
 
> "Let's say I have a class" - no, no, not hypothetical code.
 
5:48 PM
Oh, right. Is it OK to reopen?
 
@Mat'sMug At it doesn't start with "I'm in a (CS) class"
 
@Mat'sMug - thoughts ... I would suggest reopen, but there's an existing answer too.
the existing answer is a gave-you-the-code one, and not a review.
 
there's no delete vote on it
 
Look again ;-)
 
was there a closed question?
 
5:52 PM
@Mat'sMug This is about as close as I can get to finding one:
3
Q: Check if the shop is open or closed

user22818The working hours are saved in Database like {"1" : "11:00 - 14:30", "2" : "17:30 - 23:00"} Now i wrote a function like, which test is the shop is opened or close at the moment. Can someone please suggest if there is a better way to do this? And how i can check if the timing are like {"1" : "...

There is a closed question ^^^ '-)
 
ha, ha, ha
and lol
OK, you've convinced me that NoSQL is a really bad idea. — symcbean Mar 5 '13 at 21:07
 
inb4 question where OP doesn't even know the language...
wtf. has become of Programming classes?
 
This should be on Code Reviewdurron597 27 secs ago
 
@Mat'sMug Stargreed.
 
@Duga Do you agree?
 
6:06 PM
@durron597 my custom flag says "This is a textbook Code Review question" ;-)
except for the "please rate" part, but we'll handle it
actually, I just edited it out
 
@Mat'sMug Custom flagged.
 
clear to migrate, take off in 3.. 2... 1..
 
@Mat'sMug I wish there were a better system for moderators to ask other moderators to migrate stuff to their own site
 
cough migration path cough
 
0
Q: Rails: Trying to filter results by a string attribute

jammerI am relatively new to Rails, I am trying to create a cookbook app/site from scratch, I'm not following any tutorials or anything like that. Anyway... I am still in the early stages of the site but I am now to the part where I am wanting to display a index list of all the different kinds of recip...

 
6:13 PM
and migrated
 
@Mat'sMug oh man... forgot to check if he cross posted
dangit
 
ah crap
@rolfl closing as dupe isn't going to reject the migration will it?
 
No, it won't.
Dupe is special.
 
done
thanks
 
Also, a closed as dupe question can be used to merge the two questions as well (all comments and answers migrate to the open one.
 
6:16 PM
done
@rolfl you need an "A" on your shirt ;-)
 
0
A: Check if the shop is open or closed

EBrownEasiest solution (to the time problem) is to change your logic (just a tiny bit). if ($time >= $from && $time <= $to) To: if (($to > $from && ($time >= $from && $time <= $to)) || ($to < $from && ($time >= $from || $time <= $to))) You just change whether to restrict the time to be bet...

I fixed his problem.
 
BTW the new execution plan is 100% Clustered Index Scan, without any additional index needed
 
@Mat'sMug Interesting, the migration stub says "migrated to Code Review by Mat's Mug, Martijn Pieters"; I guess you do have the ability to do a special vote, then?
 
possible answer invalidation by Guruprasad Rao on question by Guruprasad Rao: codereview.stackexchange.com/posts/105509/revisions
 
@durron597 nope. I voted to close as "too broad"
 
6:29 PM
-2
Q: Similar for in a loop

PseudocodeFollowerWhich option do you think is more readable and why? ObjA a; ObjB b; for(El el:someElements) { if(el.getC!=null){ if(cond1 && el.getD!=null && el.getE!=null){ a=el.getA b=el.getB break; }else ...

 
@CaptainObvious nothing personal, @pseudocode... but pseudocode is off-topic
@rolfl oh wow, usages of the function show up as Constant Scan in the execution plan. lovely!
select dbo.WorkWeekDateDiff('2014-09-26','2015-09-26')
SELECT (Cost: 0%) <---- Compute Scalar (Cost: 8%) <---- Constant Scan (Cost: 92%)
0ms. the beauty is that it's exactly the same if I change the from date to 2004 instead of 2014
 
6:45 PM
So. Much. JSON.
 
@Mat'sMug Clustered index scan is a possible misrepresentation.
It's normally good, but could also means something bad ;-)
 
well it's better than an index seek anyway!
 
It is an index seek.
Just that the index is the table itself.... so it uses the clustered index to find the start and end points of what in other names would be a table scan.
 
ok but there's no aggregate penalty
 
No... no intermediate results, but it is also reading all the columns on the table, to get to just two.
 
6:49 PM
really?
 
All the columns, not all the rows.
 
because Count(*)?
 
The GitHub documentation actually says commitish.
 
In theory, an index on the date, and the date type, would allow you to use just the index to access all the data you need..... and that would allow just an index scan to do the work.
It would be a "covering index"
 
but clustered is faster, no? because it's the same order as the physical storage order?
 
6:51 PM
Not only the same order, but the leaf-level of the index is the entire row.....
so you have to load the entire row in to memory to get just the columns you want.....
 
	declare @result int;

	select @result = (
		select count(*)
		from dwd.FiscalCalendars
		where DateType = 0 and CalendarDate between @fromDate and @toDate
	)

	return @result;
 
I think the performance gain you already have is plenty, adding the next index would be overkill.
@Mat'sMug - for your reading: simple-talk.com/sql/learn-sql-server/…
 
I think it's as good as it's going to get :)
@rolfl bookmarked
wait, the part about clustered index scan says table scan
wow that's an excellent article
 
that ^^^
The 'included columns' feature is "new" (compared to when I last did this stuff as my day job). "In the old days" we would just add the column to the index as a key column.
 
hey wait a minute, the execution plan of the function changed
 
7:03 PM
0
Q: The Badge Bot 9000

T145Because I'm both lazy and wanting to mess around more with time management and Ruby, I thought it would be fun to create a simple script that opens CodeReview once every day to go towards the daily login badge awards! There are so many ways to go about this that I'm certain you could probably do ...

0
Q: Flake id implementation in GO

NgmI have created an implementation in GO for generating Flake ids. The implementation in based on Factual\Skuld's implementation in Clojure (https://github.com/Factual/skuld/blob/master/src/skuld/flake.clj) Current limitations include: The current implementation does not store last timestamp in a ...

 
/*
Missing Index Details from CreateNDS.sql
The Query Processor estimates that implementing the following index could improve the query cost by 92.489%.
*/

/*
USE [NDS]
GO
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dwd].[FiscalCalendars] ([DateType],[CalendarDate])

GO
*/
 
Funny, isn't that what I said in my answer?
 
makes sense
and yes
 
Actually, the estimated improvement is wrong.
I suspect only about 60% ;-)
 
and... 90% index seek / nonclustered, and stream aggregate 10%
 
7:06 PM
My actual recommendation was for you to put the date column first, and the type second.
I can see a good reason now to reverse them, like the hint suggests.
 
that makes a difference?
 
The date type will always be a constant.... and you can eliminate huge parts of the date range by doing that first (like 40% gone).
Then, you can just find the date range in that one date type... easy.
pytting the date column first makes it easy to check the date range, but then you have to check each record against the type, and throw out 40% of them....
 
hmm I should go and downvote your answer then ;-)
 
Let me fix it.
done
 
:)
 
7:10 PM
Now, if you've done it right, you will never have to hit the date table itself, you can do count's in the index, and the optimizer should manage to make it a 1-off call for each query.
 
Well I wrote 21 event classes and 26 model classes today.
 
@EBrown and I regenerated my goddamn database 4 times today ...so far :)
 
@Mat'sMug Well most of these classes have over a dozen members.
 
what's that for?
 
And every f--king member has to be marked with a [DataMember(Name = "snake_case_member_name")].
GitHub Webhooks API stuff.
All 47 of those classes have a [DataContract] class.
 
7:15 PM
hmm
 
So that I can deserialize JSON responses from the GitHub webhook API into solid classes.
 
I'm pretty sure that's a solved problem already... isn't there a tool to generate classes out of JSON?
.NET has built-in tools to generate classes out of XML...
 
@Mat'sMug They generate it wrong.
You could use dynamic of course, but that's so loosely-typed I don't mess with it except for COM interop.
 
oh
 
(I already tried a few generators.)
 
7:18 PM
dynamic was made for COM interop
 
Unfortunately, they generate certain objects (especially empty arrays, or null objects) wrongly.
I mean, look at this monstrosity. And that's only one of many events.
 
s/wrongly/wrong
 
Showing 48 changed files with 1,846 additions and 1 deletion.
 
Yep.
 
7:24 PM
not enough deletions ;-)
 
I typed almost all those additions out myself.
The only ones I didn't type myself are in the .csproj file.
And I still need to extract interfaces.
Though I don't think I'll do that for these.
And I still have to make EventArgs classes for each of these.
Two down...19 to go.
 
1
Q: Item-level locks for a large number of items

Jack A.Background I'm working on a system that records information about a large number of external documents. These documents are organized by "repository". There can be a modest number of repositories (hundreds). Each repository can contain an essentially unbounded number of documents (tens of million...

0
Q: Triangle Classification

KofiA java program that receives 3 inputs as measures of a triangle's sides: Determines if the sides form a VALID TRIANGLE. If so, it classifies the Triangle as: 1. acute, right, or obtuse 2. equilateral,isosceles or scalene 3. computes the area of the triangle 4. computes the measures of the triangl...

 
7:47 PM
@Mat'sMug Check this out:
        public void OnCommitCommentReceived(CommitCommentEventArgs e)
        {
            var del = CommitCommentReceived;

            del?.Invoke(this, e);
        }
 
yay C# 6!
 
So clean.
 
could it be del?(this, e);?
 
@Mat'sMug No.
 
phew
 
7:48 PM
That operator can only appear left of a period or a bracket.
nullArr?[0] is fine, and so is nullDict?.TryGetValue("something").
 
0
Q: ML Retraining project

user123959Tear me to shreds. p.s. let me know if you want to see code from the other classes import os import datetime from retraining.StatsFile import StatsFile from retraining.Dataset import Dataset from retraining.Partitioner import Partitioner from retraining.GridBasedBalancingRandom import GridBa...

0
Q: Wanted some feedback on the Stack implementation

Savitra SapreI am a newbie to c++ and wanted to improve writing of classes as I am bad at it. I know this seems a bit messy but any suggestion is encouraged! I have no idea why is this not working. #include<iostream> using namespace std; template<class T> class Stack{ public: int capacity; int co...

0
Q: Fairly Simple Hangman in Python

MevmevThis is my take on a simple hangman game, which is played from command prompt. import random wordlist = [] word = random.choice(open("words.txt").readlines()) #word.txt is a list of words, in the same directory with the game file. length = len(word) mock_word = "_ " * length #The unders...

 
but not inline delegate invocation (or whatever it's called)
 
No.
 
eh, I prefer an explicit .Invoke call anyway
 
7:55 PM
possible answer invalidation by micon on question by micon: codereview.stackexchange.com/posts/105478/revisions
 
> 829 Warnings
> 77 Errors
No wonder I have that unselected.
If course, the errors are all in the unit tests.
And I cannot, for the life of me, get rid of them.
 
moinking
 
oink
 
plonk
 
8:05 PM
...
 
possible answer invalidation by micon on question by micon: codereview.stackexchange.com/posts/105478/revisions
 
10 mins ago, by Duga
possible answer invalidation by micon on question by micon: http://codereview.stackexchange.com/posts/105478/revisions
Repeat?
 
no, just another edit
 
Duga never repeats herself.
 
They both redirect to edit #4
 
8:07 PM
no, they both redirect to the revisions page
 
@SirPython They both refer to "revisions", all of them
 
beat ya!
 
Ah, that's right. Thanks
 
@Mat'sMug Is there a better way to do this than to use 21 methods to fire 21 events with 21 different arguments?
I think not, but a second opinion is always good.
 
0
Q: Does this method follow the rules of objective programming?

RedasDoes this method follow the rules of objective programming, if not, how can I change it static void SaveStudentData(Student[] student) { StreamWriter File1 = new StreamWriter("First.csv", false, Encoding.Default); StreamWriter File2 = new StreamWriter("Fourth.csv", false,...

 
8:09 PM
eh, I merely glanced at it
 
I am just going to assume there is not.
 
@CaptainObvious is objective programming the new OOP?
 
There's only one thing that they share in common, which is a public const string value, and that helps me none...
So instead I'll just switch on eventKey and make 21 case blocks.
 
sounds like a job for some strategy pattern
 
No idea what that is, to be honest.
I wish I could use reflection to get the stuff I need.
But that would be too slow.
 
8:13 PM
@EBrown you sure of that?
 
I assume so. Reflection (on 21 types) cannot be fast at all.
 
define "fast"
 
Especially when I need to get 21 types, then 21 other types named OriginalTypeArgs to fire to 21 events named OriginalTypeEventHandler with 21 arguments named OriginalTypeEventArgs.
What would be nice, is if I could dynamically get the class that matches eventKey by the constant in the class called WebhookEventName (which exists in all of these Event classes).
 
I'm using reflection to discover RD inspections (20-some), and to bind the many many many commands. and there's no noticeable startup delay.. at least no more than without using reflection
how fast does it need to be?
 
Well I have no idea how to use reflection in general.
@Mat'sMug Ideally as fast as possible. I'm using this for multiple API's.
 
8:17 PM
0
Q: Ceasar Cipher by Word Length V.2

Collin StumpHere is an updated version of my Caesar Cipher script. I am looking for ways to improve it, make it more succinct, and expand it's features. I would eventually like to add text import and export features. Here it is with comments galore! ####Collin's Caesar Cipher: A Caesar Cipher by Word Le...

 
56
A: How slow is Reflection

Marc GravellIn most cases: more than fast enough. For example, if you are using this to create a DAL wrapper object, the time taken to create the object via reflection will be minuscule compared to the time it needs to connect to a network. So optimising this would be a waste of time. If you are using refle...

 
Measure it before dumping it
 
I don't know how to use it to begin with, or how it would solve my problem.
 
ah, well, that's different ;)
 
8:19 PM
Coincidentally, it's also what kept my girlfriends with me all this time
hohoho
 
All 21 case statements done.
And now it should be done.
 
Reflection is easy. Get types using typeof() or GetType(), get fields using GetField(), get methods using GetMethod(). Invoke the method using method.Invoke(object, args)
done
 
But I've already completed it with the switch statement.
 
your entire explanation can probably be coded using these 3-4 methods
 
then put it up on CR :)
 
8:22 PM
how do I get rid of old forks I don't want around anymore @SimonForsberg?
 
Or make 21 branches and get shot down on CR
2
 
    public void Dispatch(string eventKey, string json)
    {
        switch (eventKey)
        {
            case CommitCommentEvent.WebhookEventName:
                OnCommitCommentReceived(new CommitCommentEventArgs(Deserialze<CommitCommentEvent>(json)));
                break;
Starts like that, and there are 21 of those case statements.
(WebhookEventName is a public const string on each CommitCommentEvent.)
 
@Malachi I read that as "old folks" at first and i really had me question you there for a moment
4
 
@Malachi you delete them?
 
I found it I think
@JeroenVannevel lol
 
8:24 PM
How much context do I need to include for CR?
Obviously I don't want to include all 26 models, 21 event classes, 21 event args classes, and all this extra bs.
 
possible answer invalidation by Jamal on question by hjpotter92: codereview.stackexchange.com/posts/105490/revisions
 
@SirPython I would suggest the Next Version. it has some nice bells and whistles
 
Okay, I'll try it out.
 
@EBrown include a subset then. 5-6 should be enough to make a point :)
 
0
Q: Java "pulse" between threads

sdgfsdhI have two threads. One runs a simulation and one runs a UI. In the UI, it is possible to trigger a "tick" of the simulation. There are a few constraints: Ticks run on the simulation thread Each tick takes a bit of time to complete. When the user asks for n ticks, n ticks should be complete...

 
8:27 PM
@Mat'sMug I'll do that when I get home then, almost time for the department meeting, and we're going to be discussing some important things.
 
@EBrown Make your question interesting and reviewable. Do that and you will live get upvoted.
 
@SimonForsberg Well, there are 69 files that make up this setup.
And some are very long.
 
96
A: How costly is .NET reflection?

ESRogsIn his talk The Performance of Everyday Things, Jeff Richter shows that calling a method by reflection is about 1000 times slower than calling it normally. Jeff's tip: if you need to call the method multiple times, use reflection once to find it, then assign it to a delegate, and then call the...

 
@EBrown explain their purpose in pure english. If they're just for context, I think it's better to explain them than to include them.
 
Again, I've no idea on how to use reflection, and the amount of time it would have taken me to write it with reflection is longer than it took me to write the massive switch. :P
 
8:31 PM
it's a BCL API like any other
they're classes like you've always used them
 
@EBrown do your keyboard's C and V keys still work?
 
possible answer invalidation by micon on question by micon: codereview.stackexchange.com/posts/105478/revisions
 
8:49 PM
0
Q: Looking for feedback on my first PHP Class

Eric GI'm relatively experienced with Java and C++ so picking up PHP wasn't too difficult. I wanted to get some feedback on my first PHP class. There's nothing extremely complicated as of now, but its nice to get feedback. The only part I feel that I will definitely get feedback is for the readCSV() f...

0
Q: Does this way of creating items in the game seem good?

Giora GuttsaitI've created some base classes for items, and I want to know how maintainable or expandable the method seems. For now, it's just Item x = new Item(.. parameters ..) , but it will be moved to a more reliable method like Item x = Item.Create(.. parameters ..) and so on. using System; using Sys...

0
Q: Library to convert any number to a metric expression

aloisdgFor a small personnal project, I was looking to write a number as a human readable number. For example, 1023 will be 1K and 12345678 will be 12M. StackExchange use the same tricks. For this, I used metric prefixes. Humanizer is a library to convert data in a human readable form. Since my feature...

 
@Duga false alert. =)
 
I bet if I showed that to half the people at my school they'd go "what's this trash?" Bad rap music?
More than half, probably.
Unfortunately
 
in The Bikeshed, Sep 3 at 17:53, by Martijn
I mean, I could also ask "How long should I grill a steak to make it open source? With open source, I mean cooked medium rare"
2
 
Damn, out of stars
 
8:58 PM
0
Q: Pong Code Java Applet

Tony Ding(this is my first question on this website by the way) I wrote a pong applet game (very simple vers., Im new to Java), so now i basically have my ball bouncing off the sides, but i want the platform to move, by using keylistner, but it won't move. Can someone correct it and explain why? im...

 

« first day (872 days earlier)      last day (3163 days later) »