« first day (580 days earlier)      last day (3442 days later) » 
00:00 - 16:0016:00 - 00:00

4:00 PM
code is in, VTR:
0
Q: Easiest way to create bootstrap modals that can run javascript in MVC5

Flame_PhoenixI have an MVC5, C# application using the Razor engine. In my application I have a view, called "Index.cshtml". In this view I want to present a bootstrap modal to the user. When presented to the user, this modal will have buttons that should be capable of running JS functions and methods usin...

 
I wrote a memory game in AS3 before
but it was for a school project
for testing Instruction Methods in Games
Like, what kind of instructions help a player best?
Plain text? Or a tutorial?
 
@Mat'sMug VTR applied!
 
That was pretty cool to do
 
@Pimgd Sounds like researching a bit of psychology!
 
It was
 
4:03 PM
0
Q: listing the representations of integer M as a sum of three squares \$ M = x^2 + y^2 + z^2 \$

john mangualI am trying a number as the sum of 3 squares. For my particular project I will require a complete list since the next step is to compute nearest neighbors [1]. In any case we'd like to find \$ M = x^2 + y^2 + z^2 \$ in all possible ways. Here's what I wrote in Python: M = 1062437 m = int(np.s...

3
Q: Simon Says in Javascript (with Knockout) - Playable Code Snippet

Kyle Hale var simonSquare = function(color) { var self = this; self.color = ko.observable(color); self.isActive = ko.observable(false); self.activeCSS = ko.computed(function() { return self.isActive() ? "active" : ""; }); self.flash = function(callback) { self.isActive(!self.i...

 
I went through a model of Kinestethic and Auditive and Visual learning styles first
before settling on Text/Imagery/Audio/Interactivity as categories
Text is plain text instructions.
 
Personally, I think tutorials are way overrated. Unless it is for a complicated task, I much prefer short hints/instructions.
 
Imagery is things like arrows, icons and pictures.
 
Go on :)
 
Audio is anything with sound (like voice instructions, or auditive feedback signals)
Interactivity is "learning by doing" - instead of showing or telling a player, a player does and learns
these 4 methods can be combined.
Showing text as someone moves throughout a level would be combining Text + Interactivity.
Portal uses Audio + Imagery + Interactivity
There's no text.
So I designed an experiment
People will have to complete a simple task, after being instructed on how to perform the task using a combination of instructional methods.
Time is measured both in receiving instructions and completing the task
Time is measured per attempt
I decided to go with a memory game for "simple task"
The first level doesn't have any instructions
the background is filled with dots
There's a white rectangle, a green star and a red circle.
 
4:09 PM
That sounds very interesting @Pimgd !!
 
Dragging the white rectangle to the green star will complete the level.
I didn't tell anyone what to do
I used my mother to play test
she didn't get it
I added the dots to the background after that
then playtested with my brother
he tried clicking things, saw the white rectangle move and figured it out after that
Then the 2nd level is imagery
you see 4 symbols (blue star, green triangle, etc...) in a line
clicking OK at the bottom, you see a circle of 8 symbols, white rectangle in the middle
anyway, after that was text, then audio,
then the combinations
Imagery + Interactivity was done with arrows and borders to the next thing you needed to touch
People blazed through that
there was no thinking involved at that stage... images are pretty powerful
 
I bet
 
audio was the worst
Even although people had configured their sound correctly, it was hard to hear
or hard to remember
In the end, Text + Imagery + Interactivity wins
 
Woohoo! Getting my SQL Server Standard set up! Bye bye SQLEXPRESS instance!
2
 
I learned many software things with that project too - statistics tracking, interface design
playtesting most of all
It hurts to place a user behind a PC
and to stand behind them and not being able to say anything
if only they'd just read this or see that they'd know how to use this
but nooo
seriously, place someone behind whatever application you're building
ask them to perform a basic task
and ask them to vocalize what they're thinking
have paper or whiteboard ready and write everything down
and if they ask questions, don't say anything
it will hurt badly, but you'll learn a ton
it prevented me from having bogus data for the audio parts because people would (apparently) start a level and then intentionally screw up just so they could hear the audio again
maybe I still have it somewhere
 
4:20 PM
@Pimgd Why not just video tape?
 
@Donald.McLean because cheapass student at the time
oh hey I still have source here
 
Playable Simon Says Code
7
Q: Simon Says in Javascript (with Knockout) - Playable Code Snippet

Kyle HaleI resolved to do the whole thing with just vanilla Javascript as a challenge, but man, Knockout's binding and state management is just too easy. A tiny bit of callback hell to get all the flashing / guessing synchronized, but what I'd really like people to look into is the OO-style of this. I tr...

 
question: does the sequence have to be seeded / just keep getting longer every round, or can it be a new random sequence that's longer by 1 item every round? ...I think I'll make it a configurable difficulty setting...
 
			levelCreators[0] = createLevel1;
			levelCreators[1] = createLevel2;
			levelCreators[2] = createLevel3;
                        ...
                        levelCreators[21] = createLevel22;
dang that's some old, bad, source
 
@Mat'sMug The idea is to memorize the sequence. Getting a new sequence each time would be insanely diffult.
Do it.
 
4:24 PM
lol
Well.... my afternoon is officially shot. =;)- — RubberDuck 2 mins ago
 
my backups even include documentation, wow
no idea what the orange things are, though.
=O ClassDescriptions.docx
Sooo
These days my private projects have better code, but much, much, much less documentation
is that a good or a bad thing?
apparently the orange classes were optional classes
 
Funny... I was working on docs too.
I like the stick guy
 
My daughter made me laugh .... let me see if I can do somtheing here.....
 
@Pimgd Eh, I don't know. Does the code document itself?
 
mostly?
 
4:30 PM
It's less likely that you'll need to communicate it beyond yourself.
 
It's just... class diagrams.
Instant memory
 
Yeah. Do you draft yours upfront?
I just started actually formally designing upfront.
 
What is class diagrams?
3
 
I've been trying TDD and it kind of forced the issue.
 
user image
6
TTGH, back in a few (hours).
 
4:35 PM
@RubberDuck You mean: It forced the solution?
 
I did mine upfront for that project
helped a lot
 
I should really also start designing
Actually start off with a requirements analysis
 
=D found the level list
x1 - Simplified Section/Tutorial (Physical)
x2 - Pictograms (Visual) / Animated Pictograms (Visual) / Simulation (Visual) / Automated game sections (Visual)
x3 - Voice-over (Aural)
x4 - Wall of Text (Verbal)
x5 - Motion picture depicting gameplay (Visual, Aural)
x6 - Fade-in Text (Physical, Verbal)
x7 - Pop-up arrows (Visual, Physical)
x8 - Text and images (Visual, Verbal)
x9 - Voiced text (Aural, Verbal)
x10 - Reactive Sound messages / Intercom Guide (Aural, Physical)
11 - Pop-up messages/Reactive instructions (Physical, Verbal, Visual)
well, planning-phase level list
 
hiya
 
time to go home
weeekeeeend
 
4:40 PM
already at home here, but when it's weekend I'm more excited about the weekly pizza
time to order it
 
5:01 PM
Well, if the issue was lack of docs and good design @skiwi, yes. It forced the solution.
 
5:17 PM
4 entries so far, and most of the 2nd-Monitor regulars haven't posted theirs yet! I like this... :)
4
 
0
Q: Improving Matlab function within big simulation

titus.andronicusI have a very big Matlab simulation project in my hands, which I wanted to optimize, since I'm running it many times to tune parameters and the like. Using Matlab's profile I identified one function that is eating up most of my time, specifically the line rho_ref(i,1)= max(mean(dens(i+1:a,1)),de...

0
Q: HTTP Performance Test in C#

John BabbI wrote a script to test how long it takes to make requests against a url. It takes a list of urls, an array of concurrent requests, and a number of times to attempt the test. How could I improve on this? //https://www.nuget.org/packages/RestSharp string baseUrl = "http://localhost"; void Mai...

 
6:12 PM
0
Q: Design a chess game using object oriented principles

SummerCodeI would like to know if my approach is correct, and how could i improve it? Also, is there a way to get rid of the relation between the Piece and the Board? At the moment, i am storing the position of the piece both in the piece and on the board, is there some way to change that? I have consider...

 
6:23 PM
posted on December 05, 2014 by bali182

Assume the following method public Foo ???Foo(String name) { if(!existsFoo(name)) { addFoo(new Foo(name)) } return getFoo(name) } As you can see, this method is like a factory-cache mix, it takes an argument, checks if the appropriate object already exists, if not, then creates it, then returns it. Now I would like to ask you for some advice

 
@CaptainObvious I tried compiling that code on compilejava.net and got 9 compile errors... is it just me?
Java question. I saw this in a tutorial. Is it common/good practice to declare multiple variables in one statement? Does it matter much if you did it in separate statements?
public class ArithmeticOperatorsDemo {
	public ArithmeticOperatorsDemo() {
		int x, y = 10, z = 5;
 
so you guys remember when my boss told me to do manual tests instead of automatic tests?
@Phrancis If it doesn't lose clarity sure
 
@Phrancis Always do it on individual lines
@DanPantry Yep...
 
1
Q: Function to grab stdin, stdout, stderr of a child process

Amr AymanI've managed to create a function to pipe the stdin, stdout & stderr of a child process and provide them as file descriptors to read and write to .. pid_t opencmd(pipes, path, argv) int *const pipes; const char *const path; char *const *const argv; { if (!pipes || !path || !argv)...

 
@skiwi well, today he had a go at me for the regressions that occurred which i warned him about. i missed 6 things out of 50.
 
6:31 PM
@DanPantry Funny that he goes against you then :)
 
@skiwi ;-; oh well
 
~.~
 
@DanPantry Did you tell him anything about... automation?
 
6:33 PM
@skiwi I fear i would lose my job if I did that. :b
 
@DanPantry You still would like to have it until you've got a new one?
 
@skiwi money is a wonderful thing
 
@DanPantry It can sure make up the misery work throws at you with an injection of happiness!
 
> Logical operators return a true or false value based on the state of the Variables. There are six logical, or boolean, operators. They are AND, conditional AND, OR, conditional OR, exclusive OR, and NOT.
This ^^ makes absolutely no sense to me
 
context?
 
6:48 PM
where is that from?
 
Context:
public class LogicalOperatorsDemo {
	public LogicalOperatorsDemo() {
		boolean x = true;
		boolean y = false;
		System.out.println("x & y : " + (x & y));
		System.out.println("x && y : " + (x && y));
		System.out.println("x | y : " + (x | y));
		System.out.println("x || y: " + (x || y));
		System.out.println("x ^ y : " + (x ^ y));
		System.out.println("!x : " + (!x));
	}
	public static void main(String args[]) {
		new LogicalOperatorsDemo();
	}
}
 
ahh
logical versus bit-wise and/or
 
> x & y : false
x && y : false
x | y : true
x || y: true
x ^ y : true
!x : false
I haven't got to bitwise yet (that's the next demo) trying to wrap my mind around this concept first. Not very successfully.
 
&& and || can occasionally return without evaluating all inputs, while & and | cannot
for example, if x is false, the && can skip evaluation of y because the expression will always be false
bitwise operations aren't limited to boolean results, so they can't short-circuit
 
So; in short, the logical operators are checking for whether or not the input would result in a "false", depending on the options given?
 
6:53 PM
0
Q: A class which represents a SQL table

MolloI'm representing DB tables as classes (in this case PHP classes). This has the goal of modeling every section of the web page, where you will get inputs from the user. My actual base design is: One class per table and every row is represented by an Object of his class. The constructors asks f...

 
pretty much
 
@CaptainObvious sigh
@DanLyons Ok, I may just be overthinking it. When I use them for something it will probably get more clear.
 
you generally use bit-wise operators if you're working with other data types like bitmasks (often integers)
 
OK. I don't understand anything about this bitwise stuff, I wonder why they put that near the beginning of the tutorial. Maybe just a reference so they have all the types of operators on the same page.
Granted, they don't explain it, merely just list and show how they are used. Moving on!
 
as the name implies, bitwise operators work on the individual bits of values
 
7:04 PM
@konijn Your questionnaire is unfortunately off-topic for Meta. However, if you post it in chat, we can pin it.
 
with bitmasks, you can effectively perform many boolean comparisons in one operation by comparing each bit of one value with the sibling bit in the other value
 
I see, makes sense, to the extent I understand bits (which is not very much at all)
 
used as a bitmask, a 32-bit integer is effectively the same thing as 32 indepdendent boolean variables which can be compared with 32 separate && operators or one & operator
 
Ok
 
@Phrancis - understanding bitwise operators, especially in a Java context, requires some theory, including understanding two's complement.
 
7:08 PM
Starting to realize this is quite over my head for right now
 
It would take a few hours to get the basics down, and it opens up some interesting opportunities to solve some problems.
 
I'm sure. I can barely wrap my mind around basic concepts (as demonstrated by my Hello World ;) so I may save that for a bit later @rolfl
 
I may keep NetBeans on my computer in case I decide to do more with Java, even though my course is about to end. It may just take me a while to get into anything too advanced.
 
@Jamal You could... make a Simon Says ;)
2
 
0
Q: effective way to remove white spaces from string

MORTALi have come up with this approach but i'm not convinced about it effectiveness #include <algorithm> #include <iterator> #include <string> #include <iostream> template <typename Container, typename OutputIt, typename UnaryPredicate> auto remove_and_copy_if(Container& c, OutputIt d_first, UnaryPr...

 
7:28 PM
@Phrancis Perhaps, after finals.
 
Time to get into selection statements (finally!)
Is it good practice to always use braces in if-type statements?
    if (a == b) {
      System.out.println("a equals b");
    }
// versus
    if (a == b)
      System.out.println("a equals b");
 
@Phrancis Yes
always use them
 
ah
great idea @200_success
JavaScript Developer Survey 2014 -> goo.gl/forms/Fl8xcmwPtM <- do it, for Glory and JavaScript :P
9
 
7:44 PM
0
Q: JAVA using PostgreSQL Effectively

Vivian MayaI'm kind of newbie for these things but I did something and I want to know how can do these effectively. part of code : import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Random; publi...

 
@CaptainObvious JAVA @Jamal
This seems like a useful Java answer from fairly new user:
4
A: Design a chess game using object oriented principles

Kyle HaleWithout offering a deep code review (as I don't have a lot of specific Java knowledge), let's look at what a full "move" entails in chess: Player chooses piece to move. Piece makes legal move according to its own move rules. In addition to purely move-based rules, there's also capture logic, so...

Same person that wrote the Stack Snippet JS Simon Says, and selfie-answered!
 
@Phrancis and it looks like a good selfie too
 
looks like CR's got a new addict!
3
 
7:59 PM
1
Q: Does this usage of AtomicLong look thread-safe?

MondainI wanted to ensure that lastActivityTime is always the "latest" value based on current time, but I wonder if my "update" method is thread-safe? If it's not, what's a better solution besides just throwing "synchronized" around. import java.util.concurrent.atomic.AtomicLong; public class Widget {...

 
@Mat'sMug I wouldn't use that term. Reviewing code is a healthy habit!
I gave another Java Review.....on Formatting even
 
@Malachi C# guy recommending Egyptian braces... made me lol.
3
 
@Phrancis IKR
I am going to be so upset when I get the answer to this question I am about to post on Stack Overflow
 
8:19 PM
Is this the correct way to indent/write this?
 
@Phrancis rubberduck'd it? lol
 
doesn't compile :(
public class IfElse {
  	public static int x = 10;
  	public static int y = 15;
  	public static void main(String[] args) {
    		if (x == y) {
      			System.out.println("The variables are equal");
    		} else {
      			System.out.println("The variables are not equal");
    		}
  	}
}
There we go
Damn demo code in the tutorial doesn't even compile
I think I need to find a better tutorial XD
 
@konijn IE 6 is not an option for the penultimate question?
 
anyone want to take a look at my Stack Overflow post? I am going away from my computer for about an hour here soon, stackoverflow.com/q/27324174/1214743
 
8:43 PM
        var result = (int)cmd.ExecuteScalar();
        return result;
is it more expensive to unbox an int or to ExecuteReader?
 
This might be better on code review: codereview.stackexchange.comChrismas007 19 mins ago
Nope
 
@Jamal nope nope nope nope nope
 
posted on December 05, 2014 by Tiffany Fisher

I have been bashing my head against this RPC call for a few hours now, and despite extensive googling I cannot figure out what is going wrong. At the moment, I am doing all testing within unity editor, (player set to run in background if that matters). For some reason, my RPC call isn't going through. There is a lot of stuff going on in the code, so the only im

 
Yeah, thanks CO.
 
0
Q: Bottleneck encountered returning records for my grid

ChakaI am using MVC 4.0/C#/EF4.0 and I have a grid page that grabs results that are filtered, sorted and paged. It's filtering results from a table that has 45,0000 records. How do I improve performance? This page takes over 30 seconds to load. var filteredresults = _unitOfWork.ModifiedDataReposito...

 
9:00 PM
> It's filtering results from a table that has 45,0000 records
ORLY IZ A BIG NUMMER KTHXBAI
 
9:26 PM
Another Java indentation question... which is most common/proper?
if (foo) {
    bar;
} else {
    baz;
}
// versus
if (foo) {
    bar;
}
else {
    baz;
}
 
9:39 PM
@Phrancis Java prefers “cuddling elses” as in (a), although I personally am absolutely convinced that (b) is superior.
 
I don't like cuddling elses much either. That was the first thing I stopped doing when I learned a bit of PHP
 
What is ?
@Phrancis foo ? bar : baz;
 
@200_success Damn right IE6 isnt!!
I think I need to apply more marketing to that Developer Survery thing...
 
9:59 PM
@nhgrif it is an Active Directory thing
> LDAP stands for Lightweight Directory Access Protocol. It is an application protocol used over an IP network to manage and access the distributed directory information service. This video gives you a high level overview of LDAP and some examples of software that utilize LDAP, such as Active Directory.
 
@nhgrif If I have a technical issue with iPhone/iCloud is Ask Different a good place to ask?
 
The Lightweight Directory Access Protocol (LDAP; /ˈɛldæp/) is an open, vendor-neutral, industry standard application protocol for accessing and maintaining distributed directory information services over an Internet Protocol (IP) network. Directory services play an important role in developing intranet and Internet applications by allowing the sharing of information about users, systems, networks, services, and applications throughout the network. As examples, directory services may provide any organized set of records, often with a hierarchical structure, such as a corporate email director...
 
@Phrancis I have no idea. I don't frequent Ask Different.
What is your issue though?
 
Oh ok. Better check the help center.
 
Thanks @Malachi
0
A: Obj-C wrapper for OpenLDAP

nhgrifThis wrapper only goes part of the way. It seems most likely that any Objective-C code that's using this will most likely want to tote its strings around as NSString objects, rather than character arrays. Also, the word "and" should be used to indicate that a method performs to distinct actions...

 
10:02 PM
@nhgrif You're welcome
 
I installed Final Fantasy VI game and iCloud works fine on the iPad, but can't connect on iPhone 4
iCloud appears to be set up properly on phone, but I guess I better RTFM to make sure
 
Maybe an OS issue? Are they both on iOS7.1.2?
Because iPhone4 doesn't update to 8, right?
 
I'll have to check, I'm at work right now
Are for {} generally preferred to while {} and do {} loops?
 
No.
Use the right one.
There's nothing one can do that the other two can't do, so use the one that makes the code most readable.
 
OK makes sense.
Performance wise are they practically identical?
 
10:10 PM
Well, if they're actually doing the same thing, then they're probably compiled to identical assembly.
But it's easy to think that two loops are doing the same thing when they're actually not.
 
hey all! Not sure if you have seen this bounty, but it is my very first. I know that the question is Objective-C, but if you feel like answering, any language is good with me! What i am doing seems pretty platform agnostic, though the implementation isn't:
6
Q: Saving bytes instead of objects to write smaller files

bazolaThis question is about reducing the size of files saved to disk in an infinite world 2D mining game. I finally added code to my game to save and load distant chunks instead of keeping all of them in memory. Up to this point, I had only used the default NSCoding Apple library to save and load ...

 
For example, Phrancis...
for (;foo.count > 2;) {
    [foo removeLastObject];
}

while (foo.count > 2) {
    [foo removeLastObject];
}
These are identical, and they'll perform identically, but the second would be preferred.
But consider writing this as a dowhile
do {
    [foo removeLastObject];
} while (foo.count > 2);
That's not identical. If foo has 2 or fewer objects before the loop, it will have 1 when the loop exits. The other two will have 2 when the loops complete.
We'd need an if to make them identical.
do {
    if (foo.count > 2) {
        [foo removeLastObject];
    }
} while (foo.count > 2);
This makes the result identical, but the performs is worse. We have to compare foo.count to 2 twice as often.
if (foo.count > 2) {
    do {
        [foo removeLastObject];
    } while (foo.count > 2);
}
 
0
Q: BinarySearch C#

GiladThe Question from an interview was to implement binary search in both ways. Please review my implementation, thanks using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { public class BinarySearch ...

 
This now makes the performance and result identical... but it just looks so much worse.
It's also important to remember there is a 4th type of loop in most languages.
It's a forin or foreach loop.
 
@nhgrif Thanks for the great explanation (as always)
 
10:22 PM
I was thinking, instead of a , I may do a Bop-It like game..
Since, on an iOS device, you can tap it, rotate it, and shake it...
 
That would be pretty badass
 
But I'm also thinking I may not want that code to be... publicly available necessarily.
There's also another neat trick I like to do with if and while conditions.
I'm not sure if this works in Java exactly, but it does work in several languages
while ((objectThatMightBeNull = functionThatCanReturnNull())) {
    doStuffFunction(objectThatMightBeNull);
}
 
Hmm interesting
 
We can also do something like this with a for loop, if we have a function that takes an integer for example.
for (int i = 0; (objectThatMightBeNull = functionThatCanReturnNullWithArg(i)); ++i) {
    doStuffFunction(objectThatMightBeNull);
}
Where in both cases, if the function in the conditional returns NULL, the loop exits.
because false is 0 and true is non-zero.
 
I'm about to be in trouble... =;-)
And... lol
 
10:35 PM
0
Q: FizzBuzz using switches

PhrancisI'm learning about control structures now, and I want to see if I'm doing this as cleanly and efficiently as possible. Seems like there should be a less... verbose way of writing the switch but I wouldn't know what it is. Any criticism welcome! FizzBuzz.java public class FizzBuzz { public ...

0
Q: Text based python game

Ismaelimport time import random print ("Welcome to Captain's pirate adventure") time.sleep(1) name = input("What is your name future pirate ") time.sleep(1) print ("Start your amazing sea adventure and join me, Future Captain",name) time.sleep(1) gold = random.randrange(0,20) shiphealt...

 
> Seems like there should be a less... verbose way of writing the switch but I wouldn't know what it is.
switch statements are the less verbose way of writing a massive if-else chain, generally... @Phrancis
 
@nhgrif i just posted my SpriteKit take on the Simon Says challenge if you are curious: codereview.stackexchange.com/questions/71819/…
 
@bazola My other thought on SimonSays for iOS was going to be using SpriteKit and making the colors move around the screen for added challenge...
 
1
Q: Simon's Opposites Game

bazolaI cooked up this little game today for the community challenge mentioned here. The idea of the game is that sometimes when Simon gives you a color, you should choose the opposite color (the color in the opposite corner). The game visually indicates this when it is an Opposite Simon. I'm not to...

 
well, you could use my code as a starting point if you want @nhgrif ;)
 
10:47 PM
@nhgrif Ah
 
I posted an answer.
 
Ah, didn't know you could "name" your cases (tutorial did not say anything about it) thanks for pointing that out
 
I'm not sure about specific Java rules, but in ObjC, you can use any constant.
By the way, that for loop in my answer could also be rewritten as a while loop:
while (start <= stop) {
    System.out.println(fizzBuzzString(start++));
}
 
Didn't know you could make your own variable types either, that's pretty damn cool and I just had an A-ha!, you know that awesome feeling when something just "clicks" into place in your brain!
I must say this place is a great place for a beginner (or a pro) to learn. I love this site!
4
 
    HelloWorld helloObj;
    helloObj = new HelloWorld("Phrancis");
You made a new variable type there.
Your variable there is of type HelloWorld.
Which is the name of your class: public class HelloWorld
 
10:59 PM
This hard class is coming in handy after all...
 
@Phrancis Riding Hello World and all the way to 4k, I see. =)
 
Well, you gotta ask the questions before you're good enough to answer them ;)
 
> If there are any huge problems, they are probably in the GameScene class.
 
And... WEEKEND!
 
Would it surprise you if I wrote an entire answer based on a single variable that's not even in the class, @bazola ?
 
11:06 PM
@nhgrif not really :)
 
@200_success I have been wondering if I should try Hello World and/or FizzBuzz in MPI/Pthreads/OpenMP. ;-)
 
0
Q: Angular-UI Router - Dynamic Page loading (with Ionic)

keldarIn my app, I have a registration screen which the user must fill out before logging in. My registration service handles the user registration and sets a localStorage registration key basically. If a user starts the app after registering, then they are presented with the login screen. I am using...

 
11:26 PM
0
A: Simon's Opposites Game

nhgrif@property NSMutableArray *sequence; So, I want to just look at this property on our class. As it stands, it's a publicly available property on our class. There's no reason someone couldn't come along and write this code: [soGameInstance.sequence removeAllObjects]; [soGameInstance.sequence ad...

@bazola
 
@nhgrif good points! i originally did do this:
NSMutableArray *newSequence;
if (oldSequence) {
    newSequence = [NSMutableArray arrayWithArray:oldSequence];
} else {
    newSequence = [NSMutableArray array];
}
[newSequence addObject:[[SOSimon alloc] init]];
return newSequence;
but i changed it to what I have now to reduce the number of lines of code
@nhgrif definitely I should have made the sequence readonly. I don't usually think about those kind of things when actually writing the game model, but the GameScene will never need to change the sequence, only render it, so readonly is best
 
Number of lines is something I sometimes worry myself about, but it's extraordinarily low on the list of priorities.
I'd never write code that performs worse for the sake of line count.
 
thinking about it now, I do think the whole method is pointless. not sure why I did it that way. I think i was in the mindset of another project I'm working on that actually does need to take an array as input.
 
All you need to do is add a new move to the current sequence, right?
 
yeah, and just nil out the array on a game reset
 
11:38 PM
So, - (void)newMove { [_sequence addObject:[[SOSimon alloc] init]]; }
I'd also add this to the SOSimon class:
+ (instancetype)simon {
    return [[self alloc] init];
}
So we can replace [[SOSimon alloc] init] with [SOSimon simon];
 
@nhgrif the only thing I don't like about that is that when you actually type in the alloc/init, then it is completely obvious to someone reading the code that a new object is being allocated. I do think that it looks cleaner with the factory method though
 
[NSArray array];, [NSDictionary dictionary];, etc.
If your class represents a thing, then essentially all of its class methods should be methods that create instances of that thing.
That's why, for example, we have to call [NSUserDefaults standardUserDefaults] instead of just saying [NSUserDefaults objectForKey:someKey]; as a class method.
 
hi everyone! :)
 
Because what would be confusing is if NSUserDefaults stood as a class that wasn't intended to be instantiated, rather you call class methods to access various sorts of objects you've stored.
 
Hi @shuttle87!
 
11:46 PM
Hi! Fun Fun Fun
 
Got a question about this: codereview.stackexchange.com/questions/71697/… I made one long post with a bunch of comments and I see that success200 made smaller posts. In future should I change my answers to make multiple smaller answers with one topic of improvement per post?
 
Hey @rolfl, nevermind that meta comment... brainfart.
 
Also... @bazola, when you restart your game, I don't actually think you should nil out the array. Or if you do, you shouldn't instantiate it on init. If it's okay for it to be nil, then it should most likely be nil on init. Otherwise, on resetting the game, we should [_sequence removeAllObjects]; or just reallocate it: _sequence = [NSMutableArray array];
 
@Mat'sMug Your comment was only confusing because my wrist-watch 'buzzed' and when I looked, there was nothing.
 
Don't you see the dead deleted stuff?
 
11:51 PM
Only if I look specifically for it.
Mods see:
 
@shuttle87 long answers are ok; short answers are ok too.. there's a meta post about that somewhere...
 
 
Oh
 
I have to click that to see the actual deleted stuff
 
I got somewhat confused with the wording, and realized a second after posting that the problem was between my two ears ;)
Nice addition to the post btw
 
11:54 PM
the wording is bad...
 
^^ you said it ;)
Gotta go, bbl
 
@Mat'sMug ok thanks
 
Found the meta post?
 
00:00 - 16:0016:00 - 00:00

« first day (580 days earlier)      last day (3442 days later) »