« first day (1434 days earlier)      last day (3530 days later) » 

10:04 PM
I'm writing a WCF service and it makes me feel dirty. Is that normal?
 
I'm working with an API that expects a sqlite database containing JSON to be sent via HTTP. I'm not sure what normal is any more.
 
Could I get some feedback on how I wrote some code, if it is good or bad?
 
Sure
 
    private void InitializePod()
    {
        if (UserAccount.CurrentAccount() != null && !string.IsNullOrEmpty(UserAccount.CurrentAccount().ExternalAccountNo))
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[@"DB"].ConnectionString))
            using (SqlCommand command = new SqlCommand(@"proc_CustomerInvoiceCheck", connection))
            {
                int id = 0;
                string account = UserAccount.CurrentAccount().ExternalAccountNo;
 
@Greg -
a) Why can't you internalize some of that to UserAccount?
b) This is duplicated `!string.IsNullOrEmpty(account)`
 
10:12 PM
@TravisJ Is it? Was trying to ensure it does indeed double check to an extent.
@TravisJ I see what you mean.
@TravisJ With the duplicate, I can't internalize because of how the library is built for it.
 
At the very least, you don't need to check here:
if (!string.IsNullOrEmpty(account))
int.TryParse(account, out id);
but it would be nice if you had UserAccount provide a .Id
int? id = UserAccount.Id;
if( id != null )
{
 
@TravisJ True.
 
I'm personally a fan of an early return rather than extra nesting throughout the function if the precondition isn't met.
At least leave a comment making it explicit that the value of 0 is a valid default for the customer number, does the length of 20 have any significance?
 
@user1112560 Yeah, if it goes over that it isn't valid in our PIM
 
10:23 PM
Code could be consolidated to:
command.Parameters.Add("@CusNum", SqlDbType.Int).Value = id;
Heyo
 
@user1112560 Didn't know that.
Otherwise how would you rate it?
 
It's good (aside from the duplicated logic as mentioned above). I'm being far too pedantic because you posted it asking for feedback.
 
If you saw that, you wouldn't go "Ew, horrible."
 
Should coding newbies be trying to write algorithms
 
@Tokencodingnewbie Sure, how would you learn otherwise?
 
10:34 PM
I'm not even sure where to start though :(
Trying minimax
for tic tac toe
 
Nope, as a complete domain noob, a few comments (even if just a link to the docs for the SP) wouldn't go amiss.
But definitely not horrible.
 
10:58 PM
I often forget how to use 2D arrays because I use them so infrequently, is this just me?
 
int[][] 2dints = new int[2][2]();
 
That... is not... a 2D... array...
 
Kendall Frey D: I have failed you.
 
lol
Apparently I forget too :P
 
That's a jagged array in C#, not a 2D one :P
 
11:01 PM
int[,] ints2d = new int[2,2];
 
Can you tell me what a double[][,] is?
That's the coolest array I've ever used
 
It would be an array of doubles, perhaps rates or percentages, with an associated array of doubles
 
youtube.com/watch?v=iWkS19wCYsg#t=32 - Jon Skeet on arrays with negative indices.
 
@TravisJ errr, what? no...
@user1112560 I saw a question with sorta the same idea on SO recently
 
@KendallFrey - I see, there is no associate for the index at first
Lately I have been using lists of dictionaries with tuples
 
11:23 PM
wut is a tuples
 
A tuple is the generic version of a pair, triple, quadruple, etc.
A 2-tuple is merely a thing that contains 2 values
A 35-tuple contains 35 values.
 
A data structure for an ordered list of N elements (possibly of different types).
 
that sounds copied :P
 
Ish
To be fair, I presumed the .NET tuple was a 2-Tuple, shows how much I use them.
 
There are more than one
I think there are... 9?
They're designed so that if you need more than that, you can nest them.
 
11:28 PM
Looks like it goes up to 8 parameters: msdn.microsoft.com/en-us/library/…
At that point, might as well make a class
 
Yeah, I avoid even the 2-tuple
 
No clue wut ur saying.
 
I'm still trying to figure out how to determine how to find out how to give a risk score to these buttons based on the human players action.
Been thinking about it at work all day :/
 
As an aside, I really like Google's AutoValue instead of using tuples: github.com/google/auto/tree/master/value
 
11:30 PM
@Tokencodingnewbie Rather than trying to guess based on one move, play out each possible game
 
but as the row get's filled with x's that row should be considered "risky" to not try and block
I'm not sure what you mean play it out?
 
No, don't think about risk
only think about what is guaranteed
A basic minimax will figure out all possible outcomes, and then play the move that eliminates the worst ones.
 
How do I equate that in code tho?
I mean I get what a minimax is, it's just...putting it into code lul.
You saw how basic my stuff was, ifchecks galoreeeeeeeee
 
maybe you should try some simpler recursion first, and come back to this later
Have you used recursion before?
 
No, I don't know what that is.
Yeah I think this might be a little above my head.
but I was thinking about it.
 
11:36 PM
Alright, start with a fibonacci function
 
I've failed you D:
 
Then try the Ackermann function
But don't crash your computer :)
 
I've never heard of either of these.
 
great googley moogley ;)
 
11:38 PM
Oh I'm already googling it.
 
@TravisJ har, har, that'll just confuse him
 
:P
 
I hate when people call an infinite loop "recursion"
 
Yeah that did confuse me lul
 
Are there any tools out there that help you make screenshots of your app and make it look like the screenshot is running on the phone?
 
11:41 PM
You mean not taking a screenshot, but making it look like one?
 
What platform?
 
I just want the phone to be in the image too. Like show an image of the phone running the app.
Kinda like you see here: metrotubeapp.com
 
Man
I laughed so hard at this.
Hope I don't get b@ for posting it
lul
 
@KendallFrey - It is an infinite recursion.
@KendallFrey - For example, my car is my car. That is a recursive definition of my car.
 
That is, yes
 
11:47 PM
It is also an infinite loop
 
But there is no such thing as useful infinite recursion
 
I agree
 
A better example is Google's Did you mean: recursion joke
That's clearly not recursion
 
The key point in recursion is a self reference.
 
yeah
So.... I am recursive
that was low :/
Anyway, I gotta go get ready for HOCKEY
 
11:49 PM
For example if I can replace all "S" with "hello" or "helloS" and all I had was "S" I could make
hello
hellohello
hellohellohellohellohellohellohellohello
hellohellohellohello
 
For me, recursion's best introduced using trees
 
That is a good way to look at it. Every person has a parent. Your parent is a person. Your parent has a parent.
public Person GrandParent(Person p, int Generation = 0)
{
 if( Generation == 2 ) return p;
 return GrandParent(p.Parent,Generation+1);
}

var you = new Person("you");
var GrandMa = GrandParent(you);
 
What is the point of this assignment?
Like wut am I leveling up here?
 
Of which assignment?
 
Assignment?
 
11:57 PM
That is an example of recursion
using a family tree
it finds the grandparent by looking at a person's parent recursively for 2 generations
 
If you'd like to understand recursion better, take a look at this: chat.stackoverflow.com/transcript/message/18995461#18995461
 
This Fibonacci thing.
 
Heh, Fibonacci, so amusing that they teach recursion with it, when it can be an O(1) operation. Side affect is that so many people recurse to find it even later on.
 
It's also a nice way to explain template metaprogramming in C++
 

« first day (1434 days earlier)      last day (3530 days later) »