« first day (473 days earlier)      last day (3547 days later) » 

12:00 AM
I gotta write some HTML/CSS for the first time in about a decade... need a refresher :\
Notepad++ good for HTML or recommend another tool?
 
0
Q: Struct C# Best Practice

adminI have a struct lying in a class as below. I think that that is not good. Struct should be separate a file, however, in this case, this struct is only use in a class. Please help me a idea about that: how best practice for C# struct? class StudentMangement { private struct Student ...

 
0
A: Further refactored Model class that represents a calculator

nhgrif Are my constants defined in the correct location in my Model class's implementation file? It is impossible to tell. Where a variable needs to be declared is entirely dependent upon its intended scope. If a variable is used only within a single block (within an if, else, or loop, or anyt...

 
@CaptainObvious that is... not enough code
 
Maybe that one is better for Programmers, though they may already have lots of duplicates.
 
there's no problem having a private struct
in this case, however, it shouldn't be a struct
argh
 
12:10 AM
For us to really answer this question, you really need to add some of the code from the class's methods that actually use the struct. — nhgrif 38 secs ago
Along with a vote to close as unclear.
1 vote away from 1 vote away:
23
A: How could I optimize this script?

nhgrifThis script is a total of 99 lines. Of that, 49 lines are insulting, annoying, and ironic self-congratulating comments. In general, comments are good. They help any future maintainer (including yourself when it's been 6 months since the last time you looked at the script) to understand what ...

 
@mjolka to answer the question, no. It's not enough code. To give some meaningful advice, it definitely is.
0
A: A struct within a class

ckuhn203There's not a lot to go on here, but consider this. Can someone's age be -10? Will a student ever be 1000 years old? An int can be both of these values. That means a simple default getter/setter isn't sufficient. You'll need to write some bounds checking in the setter and throw an exception if so...

 
I've upvoted your answer, but I still think the question should be closed as unclear.
Because from recent meta discussions, we've sort of established that...
1. Context is important. 2. The plain-English part matters. 3. The posted code and the plain-English part should match up.
If we ignore the plain-English part, we can comment about the problems with age using a default setter. We could even comment about the fact that this class is completely useless as it only contains a private struct (so we can't use that struct, etc)
 
I was trying to find a close reason @nhgrif, but I couldn't settle on one. "Unclear" seemed... unclear.
I thought that close reason would cause confusion for OP. given the text in the close reason.
 
> or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking.
 
What it really is being closed for is pack of context.
 
12:21 AM
Plus my comment.
 
yeah that's a whole pack of context right there ;)
 
But it's not unclear what's being asked. It's perfectly clear what's being asked. There just isn't sufficient context to be able to answer.
 
0
Q: Is this edit okay?

nhgrifA struct within a class, and this is the edit history: http://codereview.stackexchange.com/posts/60534/revisions The original code include this method: public bool AddStudent(string name, int age, string grade) { // To do something } None of the code in the snippet provided uses this meth...

 
I would have closed as hypothetical/stub code
 
@Mat'sMug I really miss Montreal on days like this...
 
12:27 AM
@Mat'sMug Is that comment in reference to the C# question or a chat-answer to my meta question?
 
the C# question in question ;)
 
Are C# strings actually entirely on the stack, or is it actually a pointer to a heap object?
 
they're full-fledged objects on the heap
 
So this struct in the C# question is less than 16 bytes?
    private struct Student
    {
        public string Name { get; set; }
        public int Age { get; set; }
        public string Grade { get; set; }
    }
 
sure, but it's a mutable struct, which is a very very bad thing
 
12:33 AM
@nhgrif x86 or x64?
 
Either?
 
(actually the string properties could get pretty large)
 
You also can't inherit from a struct.
 
But the struct is just carrying around the pointer to the string
The string itself is on the heap
The stack has the pointer to the heap address.
 
right
it's still a mutable struct
 
12:35 AM
You should elaborate on how and why the struct in the question violates 1 or more of these points. It doesn't seem particularly obvious to me. — nhgrif 8 mins ago
How is it mutable? Could it be made immutable?
I'm not familiar with C# at all.
And you can't put Objective-C objects in structs in ARC.
 
1
Q: Is this edit okay?

nhgrifA struct within a class, and this is the edit history: http://codereview.stackexchange.com/posts/60534/revisions The original code include this method: public bool AddStudent(string name, int age, string grade) { // To do something } None of the code in the snippet provided uses this meth...

 
it's mutable because it exposes setters for all properties
 
So it could be made immutable by simply not exposing the setters?
 
and having a constructor that takes a value for each property
 
If you don't expose the setters, how do you set them in the first place? How do you create a C# struct?
 
12:36 AM
that's the constructor's job ;)
 
Okay, so this struct would be okay if it just didn't expose the setters?
(and if it weren't a private struct in a class with nothing else in it)
> Does Student represent a single value, similar to primitive types? Again, no. Things that would match this criteria include coordinates, rectangles, colours, etc.
@mjolka I couldn't disagree more.
 
not quite: a struct should also be valid for all default values, so a Student with string.Empty for a name and age 0 in grade string.Empty would have to be valid.
 
A student IS the single value represented.
 
because you can't override a struct's default (parameterless) constructor
 
A rectangle with 0 width/length makes sense?
 
12:40 AM
Actually, yes. It does.
 
it won't throw anything
 
It's a special case of a rectangle, but it is an infinitely small rectangle.
 
How is a rectangle with 0 width/length and more valid than a student with 0 age and no name?
Truly, age should be unsigned.
Because negative age doesn't make sense
 
i'm starting to regret answering this question...
 
And grade should be an enum.
 
12:41 AM
@mjolka lol
looks like it's reviewable after all...
 
i wanted to leave it as a comment lol
 
Ultimately, I think the point I'm trying to make is that I think Student is fine as a struct, but this particular implementation
 
I was going to mention that.
It's not though. A month from now someone is going to want to inherent from student.
 
^^ that
 
Yeah yeah. I know. YAGNI, but...
 
12:43 AM
@nhgrif i took those examples from msdn.microsoft.com/en-us/library/0taef578.aspx "The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color."
 
although Student could be Student : IPerson
 
And most likely should be Mug.
 
Yes, I understand. But I think a student could be a struct.
It depends on how you want to use it.
 
I'd probably go "WTF" and change it to a class
 
Yup.
 
12:45 AM
I mean, in this case, it's a private struct within a class.
It's intended to be used only within the class.
 
right. that doesn't make it a value type
a class can also be nested
making it a struct is basically like shooting yourself in the foot
 
private struct Student
{
    public string Name { get; set; }
    public int Age { get; set; }
    public string Grade { get; set; }

    public void SetGrade(string grade)
    {
        this.Grade = grade;
    }
}
 
Yuck. Wouldn't recommend that, but yeah. It can be.
 
var students = new[] { new Student { Name = "bobby tables", Age = 23 } };
foreach (var student in students)
{
    student.SetGrade("A+++");
}

Console.WriteLine(students[0].Grade);
2
 
Wait...
 
12:47 AM
@mjolka why?
 
If structs should have public setters, then why does the language even allow it?
 
@Mat'sMug because it prints null and that's going to be crazy confusing
 
indeed.
 
That makes an assumption about the use-case though... which is why the question is bad.
And why it's closed.
This, though, is still 1 vote away from 1 vote away: codereview.stackexchange.com/questions/10167/…
 
now just 1 vote away ;)
 
12:50 AM
;)
It's quite an entertaining read, Santa.
 
I'm pretty sure this is my highest voted comment.
I don't know weather to upvote or ... Eh, what the heck. +1. — ckuhn203 yesterday
 
Look at the upvotes on this comment:
S. Lott, I'm actually using yours! Should I stop using it? — Noah Clark Jul 2 '09 at 20:55
3
 
LOL. Pure awesome.
 
@nhgrif in a vague way, that reminds me of this news.ycombinator.com/item?id=35079
 
> William Shakespear
William shakes pear
 
12:54 AM
Shake the spear man. You'll scare them away.
 
@nhgrif I had gone through parts of it earlier today, but yeah, it's actually quite a ...gem.
good evening @200_success :)
 
@nhgrif what if the // do something comment would have been replaced with actual code, like
public bool AddStudent(string name, int age, string grade)
{
    _students.Add(new Student { Name = name, Age = age, Grade = grade });
}
If _student were found as a private field in the class, would the question have been on-topic?
I'm inclined to say it would be a not-so-great question, but we've reviewed smaller questions before.
hmm..
 
1:12 AM
Hi!
 
hi!
 
Hi!
 
@CaptainObvious I need a drink
oh, wait..
 
@nhgrif He couldn't even respond to that. XD Still funny.
 
1:15 AM
Jamal
1:14 AM
edited: Hi!
I love my italics :)
 
removes room ownership
 
:'(
 
:P
 
0
A: Is this edit okay?

Mat's MugThe problem with that question isn't that it's unclear. class StudentMangement { private struct Student { public string Name { get; set; } public int Age { get; set; } public string Grade { get; set; } } } That edit removes a piece of noise, that could hav...

 
-1
Q: Histogram Separation Energy Equation Based Bhattacharyya Matlab code

johnmarkI am working in level set method, specially Lankton method paper. I try to implement Histogram Separation (HS) Energy problem (Part III.C). It based on Bhattacharyya to control the evolution of contour. To understand it, the first we consider global method in which given an input image and a cont...

 
1:28 AM
^^^ Very odd question that
It's like he didn't look on which SE site he was posting to when he pressed the "Ask Question" button.
 
Regardless, time to close.
 
still not closed yet?
 
1:41 AM
@Mat'sMug Got it
 
1:52 AM
1
Q: Efficiently creating a menu consisting of multi-level structure

HelpNeederI was asked to modify existing code to allow multi-level page structure. Each page can have one parent, and one page can have multiple children. I will present following code. My question is is there a more efficient way of doing this? I am hard-coding the number of levels that are reachable. ...

 
going to watch a movie, @ckuhn203 I have a draft on its way, will resume after Iron Man II (got some major catching-up to do on my superhero movies!)
 
@Mat'sMug You have seen Iron Man 1, right?
 
gah, I'm always asleep when questions are posted :(
 
No worries @Mat'sMug. I'm not in a hurry.
 
@Yuushi Or too busy with something IRL
@hichris123 You could ask @Yuushi
If you didn't get an answer before.
 
2:05 AM
Oh, yeah, that.
Hold on, I have to say this first:
@AlexL Congrats on getting populist!
2
Okay, now that we've got that out of the way.
@Yuushi still around?
 
@hichris123 Yep
 
So what I'm doing is trying to wrap this line of code (C++):
const& std::vector<myclass::mytype> const get_my_vector() { return my_vector; }
I'm not sure of a good place to wrap it, any tips @Yuushi?
 
what do you mean by "wrapping" it?
 
Putting it on two lines. I'm trying to conform to the Google C++ style guidelines (max 80 chars per line).
 
oh
const std::vector<myclass::mytype>&
get_my_vector() const
{
    return my_vector;
}
that's probably how I'd lay it out
 
2:10 AM
Ok.
 
2:26 AM
Hello @Will
 
Hi
 
@Will What brings you here?
 
Click-happy mouse fingers I guess...
Just checking out if there's anything interesting going on in rooms like these.
 
Well it did lead me to look at your profile, which led me to look up your 1 answer, which led me to upvoting it. :)
 
Haha. Thanks.
 
2:28 AM
@Will Right now is one of the quieter times in this room
@Will You are a dev?
 
About that question... why do you think nobody considered doing what I wrote? It seemed like the obvious olution to me...
Yeah, mostly C
 
@Will All answers on that question have a low number of votes. Mostly because visitors don't usually vote on things.
@Will You should post some code for me to review!
 
Well, I was late to the "party" I guess
 
Yeah, that doesn't help
 
I'll think about it. Thanks.
 
2:31 AM
1
A: Is it possible to optimize the following boolean checks?

WillI can't help but question everyone's sanity on this page, as this function really has no business being any longer than this: def is_ok(user_dbs, self_db): return not user_dbs or (len(user_dbs) == 1 and user_dbs[0].key == self_db.key)

@Will Users in this room are more likely to get votes than those who aren't ;)
 
You are helping me there with your fancy quoting :)
 
Ahh, the chatroom automatically does that with it's autoboxing feature
 
@syb0rg You're a Java guy, I see
But I also see C
 
Definitely into
Love it
It's awesome
 
Me too, but it sort of pains me that everyone seems to write it as if it's still 1989...
 
2:35 AM
Thank you!!!
(I hate that too)
 
It's even worse with C++ :(. Every time someone insists that C++ is a memory leaking, error prone piece of crap, I die a little inside.
3
 
"I would stick to C89" - NO! There is no good reason for not using the nice things C99 or C11 gives you, besides being able to use the crappy Visual Studio C compiler (which does support some C99 features anyways). — syb0rg 2 days ago
 
@Corbin You and me both
 
A comment I made chewing out a user recommending 25 year old standards.
 
C89 in 2014 is absurd
4
Even the ability to declare variables inline is worth moving to at least 99, and even then it's 2014.
 
2:38 AM
Yes, tight scoping is just a good idea without any drawbacks IMO
 
@Will Nice answer on storing the crypto keys in CPU registers btw. However, you forgot to mention the security benefits of doing so.
 
@Will Every now and then I'll get into an argument with someone that it's more efficient to declare variables above their loops. Freaking people stuck in 1980... x.x
 
@syb0rg I'm lazy, I guess. BTW: don't dig too much in my profile: there's stuff in there from when I was still a beginner :p
 
Same with my SO account ;)
I almost never go on SO anymore though.
 
The noise to signal ratio is awful these days, especially with [c]
"my program crash. i don't understand. help."
 
2:41 AM
The signal to noise ratio has always been pretty terrible with C, I'm afraid. It's amazing how wide-spread terrible, archaic practices can be with widely used languages (C++ too). It's depressing :(. Thankfully though, the world seems to be waking up with regards to C++, and to a lesser extent C. Or maybe I've just pulled my head out of the sand -- no idea.
Hah. At least it's not "JAVA NO WORK NEED HELP FIX"
Every time someone writes "JAVA", god kills 3 kittens.
 
And of course schools aren't helping with that...
 
@Will Unfortunately, the rate questions being asked is somewhat lacking over here.
Take a look at this answer:
1
A: Is it possible to optimize the following boolean checks?

WillI can't help but question everyone's sanity on this page, as this function really has no business being any longer than this: def is_ok(user_dbs, self_db): return not user_dbs or (len(user_dbs) == 1 and user_dbs[0].key == self_db.key)

New user, should probably toss him some votes ;)
 
@syb0rg you are so kind!
Ppl will mistake you for my sockpuppet!
 
@Will Already have one ;) </kidding>
 
@syBorg Nice. How do you use it?
 
2:46 AM
@Will He's been decommissioned for a while. Probably due for an upgrade soon...
He used to post the most recent answers in a separate chatroom, so the regulars could see them more easily.
Since we couldn't get a working RSS feed like the @CaptainObvious we have for this room.
 
I like how you had the robot asking for a review of itself
 
Yeah, I gave up a lot of rep for that haha
 
Thanks for the HTML/CSS link @syb0rg
 
@Phrancis Sure thing! Have you taken a look at it yet?
 
No just got back home
Looks nice though, sure beats W3Schools
 
2:51 AM
Easily :)
@Will Out of curiosity, how old are you?
 
31 (and I am a late bloomer, I think)
My petals are almost starting to straighten...
2
@syb0rg Why did that question pop up in your mind though?
Wait, it's because of C, right? A somewhat "arcane" choice these days, I guess.
 
@Will Yeah, that's mostly the reason. I was kinda wondering if you were a student as well.
 
I am, but only in the almost meaninglessly broad and informal sense of the word...
 
@Will 30 here late to the party as well. Don't feel bad about it, better late than never
 
@Phrancis Cheers. And no worries: I gave up on feeling bad about my life choice mostly already...
 
2:57 AM
@Will This site will get you on the fast track to being a master if you stick around. :)
 
I can select some records and even start transaction woohoo ;)
 
BTW, any of you familiar with prolog(-like languages)?
 
May want to browse the tags on the main site
 
Nah, I was just phishing for the off chance of some enthusiasm for the subject among you folks here ;)
 
But I guess here's as good a place as any to ask... I've never heard of it personally
 
2:59 AM
I have heard of it, but never really knew what it was
Until I just looked it up that is
 
Basically, you define your problem domain in first order logic, and then the language finds solution though logical inference.
 
@will you can edit recent chat messages by pressing the ^Up arrow on your KB, on the little drop-down menu on the left of each message... FYI :)
 
@Will You have up to 2 minutes to edit in stuff to your message.
 
19 secs ago, by syb0rg
@Will You have up to 2 minutes to edit in stuff to your message.
OH it's even dynamic
NICE
 
@Phrancis I think you posted that just after I edited it, but I could be wrong
 
3:02 AM
I should have taken a screen capture ;)
 
I accidentally removed my message now! Anyway, thanks for the help! :)
 
@Phrancis You can still view the history of the message
 
Oh noes, I have The Whiteboard in my "other rooms" feed... so dirty...
I saw the word posted multiple times in a 2 minute span... also something about optimizing your wifi for a large software patch all the while not disrupting downloads of... ... and beer.
All within less than an hour
 
Hello @TopinFrassi
 
How frequent of problem can it be that you don't just pause the download of ? o.O
 
3:10 AM
^ Right.
Verizon was his ISP, from my understanding. Root of the problem right there
 
Hrmmm, I wonder if Verizon has data caps. How much can he possibly be downloading that 24/7 connection is urgent?
Weird.
 
I think the question is more like... how much bandwidth can you expect to have for $10/month...
 
0
Q: Reviewing AI based on how it performs

syb0rgOn Code Golf is is common to see a king-of-the-hill question where you have to implement an AI based on the rules given in the question. So then I got to thinking - "If I developed an AI for one of these 'games', I could post it on Code Review to improve it!" But then I was wondering how an AI ...

 
Verizon has a $10 a month plan? Wow. I'm sure it's crap, but still. That's cheap as hell.
 
^ That
Actually, that's wrong. But anyways...
> Starting today, all existing FiOS Internet customers can upgrade to our entry level FiOS Quantum tier of 50/25 Mbps tier for just $10 more a month and keep the speed for as long as they wish. - See more at: newscenter.verizon.com/residential/news-articles/2013/…
 
3:23 AM
what is the best fundraising site out there?
 
I hear many are using kickstarter these days. I have spent zero time comparing them though.
 
Indiegogo from the little research I have done.
 
kickstarter sounds like it is for a product though
 
That may be the case
 
I want to gather funds to send me on a short mission trip, so to say...I am using the term mission trip fairly loosely here,
 
3:26 AM
Can you qualify that a bit better? I may know a few options but hard to say without more details...
Specifically, "mission trip"
 
I am in a Motorcycle ministry and want to go to Bike Blues and BBQ but need to have the funds to get me and at least another guy down there and back. somewhere around $500
 
@Malachi You could always make potato salad.
 
In Fayetteville?
 
@Jamal lol you saw that too
@Corbin yes
 
Ah :p. BB&B makes me think of loud motorcycles going by my dorm room at 3 in the morning x.x. lol
If I were still in Fayetteville, me you and ngfrif would have to have a mini CR meetup haha.
 
3:29 AM
you live there too? you know the other monkey?
@Corbin lol yeah
 
I lived there for 4 years during college, and my girlfriend still lives there while she's finishing school, but I moved in May.
 
if I can get down there. and get the wife to sign off on it
but I think if I could pay for her dad to go with me, he would set her straight...lol
 
And I've actually never met nhgrif, though we lived about 5 minutes apart lol.
Ahhh, sneaky
 
Motorcycle ministry... interesting concept... Try any local charity?
Or you could always take a gamble dare on eBay to do something crazy in exchange lol.
But either way, good luck hope you make it @Malachi
 
@Corbin lol
@Phrancis interesting concept
 
3:36 AM
Monking @All
 
Hello @Heslacher
 
Monknight @Heslacher
 
@Malachi Using my phone, it isn't fun to edit more than the language tag of a question. Btw. I just don't care about badges & points.
 
@Heslacher lol makes sense
goodnight all
 
I feel a little sad that my automagically zombie answer is sitting there at -1 ... show some love anyone? I think vogel forgot to re-upvote after he misread it...
 
3:41 AM
@Malachi Goodnight!
 
Bye @Malachi dream about motorcycles & country roads :)
 
night @Malachi
 
Thanks Santa :)
 
@Phrancis There had been 3 downvotes all together.
 
Hmm why... odd
 
3:44 AM
Now its 4 up and 3 down
 
Still not sure if people have seen this or not: codereview.stackexchange.com/a/60517/27623
 
Javascript is hurting my eyes ;-)
 
@syb0rg yeah, I had seen the first. My wife rented the three movies this weekend, will see the 3rd later this week
 
@Mat'sMug You rent movies? You need this: popcorntime.io
 
3:54 AM
haha yeah... we're so old-school!
@syb0rg hadn't
 
o.o
I used RedBox online a little bit ago to "rent" a movie...
 
I had late return fees for $4.50 dating back from September of last year...
anyway TTGTB, will lurk again tomorrow :)
 
Are there still any places where you can walk up to the counter, hand the tender an empty case from the display shelf, tell them you want to rent this movie?
 
@Mat'sMug Bye!
 
Bonne nuit @Mat'sMug
 
3:58 AM
@Phrancis yes!
 
dies inside a little bit
 

« first day (473 days earlier)      last day (3547 days later) »