« first day (495 days earlier)      last day (3515 days later) » 

12:00 AM
@Haney is there any chance we could put regular text in between the different types of code in the snippet. Formatting posts like this is common on Code Review and things get kind of cluttered without being able to put a small "Header" in between. Heck, nevermind. Would it be possible to bake in some headers for HTML, JS, CSS?? — ckuhn203 37 secs ago
 
@sim let the unicorns know!
 
Where are the unicorns?
 
Just ping @Haney on meta ;)
@RubberDuck comment is gone??
 
What do you mean @Mat? I just followed the link back.
I definitely need to brush up on my Javascript though. Just to play with it.
 
Ah, got it. Upvoted!
 
12:12 AM
I figure we need to track some of these issues.
Suggestions?
The meta post on SO is .... crowded.
A post on Meta StackExchange is possible, but, I like the idea of keeping it here on CR so it is not as frenetic
 
Besides, it's not SE-wide anyway ;)
 
Answers here should point to valid questions/answers on the main site, this is not just a playground for Stack Snippets, it is for showing them doing real work.... Is it your code? Why don't you post it for a review, then link back to the question from this answer. — rolfl ♦ 40 secs ago
 
0
Q: Javascript Minesweeper (with Stack Snippets!)

Simon André ForsbergAs Stack Snippets are live on Code Review now, I wanted to do something quick in it. And when you make things quick, they probably get dirty. And when things get dirty, you post them up for review. So, as many of my previous questions has been about Minesweeper probabilities, what better thing t...

 
0
Q: Any improvements for my LoginController class?

Kid DiamondThis is probably going to be my final question regarding controllers. I feel like I have a good enough understanding of them now and am able to write them cleanly. I've recently adapted a less error prone way of communicating with the corresponding View. But I would still like to know if there i...

0
Q: Javascript Minesweeper (with Stack Snippets!)

Simon André ForsbergAs Stack Snippets are live on Code Review now, I wanted to do something quick in it. And when you make things quick, they probably get dirty. And when things get dirty, you post them up for review. So, as many of my previous questions has been about Minesweeper probabilities, what better thing t...

 
that was pretty quick @SimonAndréForsberg!
 
12:18 AM
@bazola It would have been even quicker if my browser wouldn't have crashed an hour and a half ago...
I had to rewrite the whole damn thing
Sorry, JavaScript, but... YOU SUCK!
2
 
> As Stack Snippets are live on Code Review now, I wanted to do something quick in it. And when you make things quick, they probably get dirty. And when things get dirty, you post them up for review.
 
Damn it, I'm not even first in using snippets...
@RubberDuck I'm considering changing it to "And when things get dirty, you refactor them. And when you're not sure how to refactor, you post it up for review."
3
I take those stars as a sign that I should do that edit.
 
Yeah. The bouncing boxes is cool.
And yes. I think that's what we're saying. =;)-
 
@sim lol KABOOM!
 
I got lots of Kabooms...
 
12:25 AM
That's great, now the tag on Code Review has a whole new meaning...
 
I hadn't even thought of that!
 
Right.. CR games are now playable on-site!
@sim I retagged with community challenge
 
codepen.io/srkimir/pen/mGbrf
 
@Mat'sMug I'm not sure if it's a good idea to use that tag for this challenge (as the things we'll make will probably be quite different), but heck... go ahead for now!
 
Also I nominate this post for the best usage of the community-challenge tag.. ever! — Mat's Mug 2 hours ago
No?
 
12:37 AM
I posted my experience of the snippets here:
1
A: Stack Snippets are Live! - Click here for your Sandbox

Simon André ForsbergWhen using these snippets in my recent question, I wrote the entire snippet from scratch inside the Stack Exchange editor, so I used it quite a lot. From my usage, I have a few primary issues: AUTOSAVE. After about one hour of editing and writing JavaScript I ran into yet another one of the Jav...

feel free to point a unicorn towards it
Once I get a few answers to my existing JS question, I'll probably make a cleaner UTTT version. Possibly with... hmm... does Stack Snippets support websockets?
 
No clue
 
Way too easy ^^
I need to implement a "You win"-feature...
 
We should tweet about this stack-snippets thing
Might just be the biggest thing to hit CR since... since the Great Revival!
4
 
12:53 AM
> RELOAD
(a bit late)
 
Web Sockets work!
 
Also, monkevening :)
 
Next up: Multiplayer Tic Tac Toe Ultimate!
@Phrancis speaking of late.... I should really go to bed...
 
Night
 
I was going to say... It's like, 02:55 no?
 
12:55 AM
Yup ^^
night
 
Bye Simon
 
(playing minesweeper on CR)
 
Javascript Minesweeper (with Stack Snippets!). First playable game directly at Code Review! #codereview #2ndmonitor http://codereview.stackexchange.com/q/62583/31562?stw=2
Night again :)
 
1:15 AM
There are no unit tests here to review, as such, this is a request for advice on code not yet written. — RubberDuck 17 secs ago
Also, he just posted the same code again without making a single change to it...
 
-1
Q: Suggest How to do Unit testing

Mike RossSHIP Class public class Ship { Dictionary<String, ArrayList> cabins = new Dictionary<String, ArrayList>(); String name; public Ship(String name) { this.name = name; this.setupShip(); } public void setupShip() { ArrayList groupA = new Arra...

 
Well... as is, we can certainly review the code you have posted, given a bit of context, i.e. write what your code does in plain English. But asking the community to suggest how this might be tested, is plain off-topic - we don't write code for you - no Stack Exchange site does. Please reformulate this post to keep it on-topic, it would be a shame to close this question. — Mat's Mug 6 secs ago
 
1:36 AM
1
Q: Histogram of length of words in text

user3590149This my first real program in python. I welcome harsh criticism. I tried to make it as efficient as possible. Trying to balance speed and readability as well. My program takes a file of text and parses and counts the frequency of the length of each word. For example: If the this was the t...

 
@RubberDuck yay, my first hammer-close-as-a-dupe!
(was actually an accident, I didn't even remember that my C# gold badge + closing as a dupe meant auto-hammer-close)
@all 1 more delete vote and it's gone
and @RubberDuck with Expresso, this is the actual correct Regex pattern I meant to use in my answer earlier today:
> ^(?<whole>\d+)?\s+?(?<numerator>\-?\d+)\s?/\s?(?<denominator>\-?\d+)\s*?$
()
 
1:56 AM
ugh. I hate VB.NET. Like, wtf?
 
Ahhh that makes more sense @Mat.
And I'll admit that I was a little confused when I say my name listed as saying it was a dupe. Lol
Must be because I put a close vote on it.
 
yup
now I need to remember that my C# close-as-dupe votes are binding.
(not that that happens very often...)
 
Dude... Wtf is right! Why does VB think it's ok to reuse keywords like that?
 
            Dim wholePart As String = If(match.Groups("whole").Value, "0")
            Dim numeratorPart As String = If(match.Groups("numerator").Value, "0")
            Dim denominatorPart As String = If(match.Groups("denominator").Value, "0")
^^ ugh
var wholePart = match.Groups["whole"].Value ?? "0";
 
And that returns the part or zero, right?
 
2:01 AM
yeah
 
Because it sure as hell looks like it returns a bool.
 
funny, nobody seems to have noticed the accidental semicolon in my Dim statement
Dim fractionPattern As String = "(?<numerator>\-?\d+)\s?\/\s?(?<denominator>\-?\d+)"; <----- C#
 
@Mat'sMug you might want to check if \d == [0-9]
 
why is that?
 
because you probably(?) just want [0-9]
not all unicode digits
 
2:04 AM
what else would \d match?
 
"\d matches any decimal digit. It is equivalent to the \p{Nd} regular expression pattern, which includes the standard decimal digits 0-9 as well as the decimal digits of a number of other character sets.
If ECMAScript-compliant behavior is specified, \d is equivalent to [0-9]. For information on ECMAScript regular expressions, see the "ECMAScript Matching Behavior" section in Regular Expression Options."
 
interesting
699
Q: \d is less efficient than [0-9]

westonI made a comment yesterday on an answer where someone had used [0123456789] in a regular expression rather than [0-9] or \d. I said it was probably more efficient to use a range or digit specifier than a character set. I decided to test that out today and found out to my surprise that (in the C#...

@mjolka thanks, I've edited the code I'm working on for my upcoming edit ;)
 
@Mat'sMug np :)
 
^(?<whole>[0-9]+)?\s+?(?<numerator>\-?[0-9]+)\s?/\s?(?<denominator>\-?[0-9]+)‌​\s*?$
 
@Mat'sMug can you link to the question or answer you're working on?
 
2:08 AM
No time to include example code, but will edit when I get home, promise :) — Mat's Mug 8 hours ago
 
ta :)
 
0
Q: Stylish range input, Google Chrome only

Sean AndersonI have an input[type=range] element which is customized using CSS to look more modern. I'm unhappy with my CSS because of the need to use position:relative on the wrapping element and position:absolute on an invisible range input. I'm wondering if I made this logic unnecessarily convoluted. Is...

 
@radarbob may I suggest that you go ahead and post an answer? — RubberDuck 23 secs ago
smh...
 
my first encounter with @radarbob:
8
A: Win Forms design pattern

radarbobAs an addendum to @retailcoder epic answer I offer... Object Oriented Dice Lots of your existing code will simply melt away when we take a more object oriented approach. The key is making classes for the basic things in dice game world and have each class responsible for doing what it is suppos...

...led to this:
5
Q: Dice game rules implementation review

Mat's MugMy in-laws taught me a dice game a couple years ago, and we play every once in a while. A recent excellent answer from @radarbob inspired me to proceed with translating the rules of that dice game into code. Here's what came out of it: So it works perfectly, and somehow I'm just as unlucky ...

which reminds me... that I need to finish that dice game... or should I use it as an excuse to learn some JS?
monking @Yuushi!
 
heya @Mat'sMug
@Mat'sMug Now why would you want to do something silly like learn JS? :)
 
2:21 AM
seen this?
6
Q: Challenge - Showcase the Stack Snippet Feature!

rolflThe Stack Snippet feature is now live. When you ask, or answer a question, click this button: When you use this feature in a question or answer on the main site, please answer this question with a link to your contribution (note that Stack Snippets currently support JavaScript only - that may/...

snippets are now live on the main site!
 
ah, I see
and yet it still isn't enough of a reason to touch javascript (for me at least)
 
lol
2
fun fact: google up "gethashcode for a fraction struct"
#2 is my CR post!
 
it's #1 for me
 
nice!
 
0
Q: C++ implementation of Java's floatToIntBits() and intBitsToFloat()

user1551I am trying to implement Java's floatToIntBits() and intBitsToFloat() methods in C++. The latter method is the inverse of the former method, and the purpose of the former one is to pack a 32-bit floating point number into four 8-bit bytes. More specifically, my replacement function float2ul() for...

 
2:45 AM
0
Q: Dynamically-sized stack - follow up

gues532Follow up of - Which is a better implementation of a stack data structure (based on an array)? Please review my stack implementation from before. I've made it dynamically sized if needed and made a few tweaks. #include <stdio.h> #include <stdlib.h> #include <stdbool.h> typedef struct { in...

 
ugh. shame on you VB.NET
33
A: Is there a VB.NET equivalent of C# out parameters

GuffaNo, there is no equivalent of the out keyword in VB. However, VB does automatically initialise all local variables in a method, so you can use ByRef without needing to explicitly initialise the variable first. Example: Sub Main() Dim y As Integer Test(y) End Sub Sub Test(ByRef x As Intege...

 
3:15 AM
speaking of out parameters, @Mat'sMug you might be interested in this blogs.msmvps.com/kathleen/2014/09/06/…
 
interesting
C# 6 is really going to be something
 
3:34 AM
@SimonAndréForsberg Mine Sweeper is Awesome!
TTGTB
 
3:57 AM
Is there a CR equivalent for SO's ?? operator?
 
!!
 
Nice reword Mug
 
huh, where?
 
Oh wait... this and that somehow looked very similar in how they were worded.
Thought they were the same... '~'
 
4:01 AM
Wait... They ARE the same...
 
lol yeah
 
0
Q: Is it long polling or short polling?

PyaythuI am a newbie of PHP and jQuery. I worte the following script and php code for long-polling architecture by googling references. But I am not sure that is long-polling or short-polling. Please confirm me. Thanks in advance. **bc_test.js** jQuery(function($) { var data = []; function pullNot...

 
> I worte the following script
 
Kudos for the effort... I feel it may get lost in the shuffle on SO but I UV, your solution looks quite thorough
 
the shuffle on SO?
 
4:04 AM
Er. Nevermind. I need some sleep '~'
 
me too!
(and thanks!)
 
Had about 1 hour of sleep last night, and I'm hallucinating wrong site logos from my opened tabs at this point... Damn insomnia.
 
I had a "nightmare" last night
I dreamt my CR account got hijacked because I was stupid enough to enter my password on a phishing page.
2
I'm so fucking pathetic
TTGTB
 
^^ that (and, idem.)
TTGTB... stop ... hammer time
 
hammerTIME!
 
4:17 AM
0
Q: Calculating the speed of a bicycle given the gear size and cadence

Oompa LoompaThe following question was taken from Absolute Java 5th ed. by Walter Savitch: Bicyclists can calculate their speed if the gear size and cadence is known. Gear size refers to the effective diameter of the wheel. Gear size multiplied by pi (3.14) gives the distance travelled with one turn of ...

 
4:29 AM
@RubberDuck he answered!
1
A: Managing a cruise system

radarbobWhere I'm Going Define data structures and model the "cruses" domain in a more OO way "Push details down" into appropriate classes See what the resulting encapsulation does to the main() and other classes. enum uber string public enum CabinClass { undefined, A, B, C, //etc. } public...

 
4:59 AM
morning @all
 
morning @chillworld
you're early! i thought it was almost home-time
 
5:19 AM
@mjolka nah 7 am here now
just early at work :)
 
5:31 AM
1
Q: Singly linked list implementation and related questions

Court PhillipsI started brushing up Data Structures and Algorithms several days ago in preparation for upcoming interviews in a few months. I began with linked lists and discovered I'm a bit rusty. With clause that I haven't interviewed in quite some time and code is most likely not expected to be perfect - p...

 
lol looking at @SimonAndréForsberg starred messages, there are some languages what doesn't suck : Fim++, Cobol and assembler :D
 
i thought the c# sucks section was severely lacking
 
:D
java and javascript is euuh long :D
 
5:47 AM
bizarre how c# is the only one complaining about the existence of null references
 
prob a c# programmer who wrote it :p
yesterday evening playing in vba with brother in law
creating mastermind :)
last problem I didn't solve (when I set 2 colors blue and the solution has 1 blue color, we wanted the text in the labels : 1 other place and one wrong, now it was twice other place
but was 11:45 pm and wife wanted to go home ^^
 
6:14 AM
0
Q: Espresso Queue simulation

Juha UntinenI was asked to do a technical test with the following specification, but my solution was rejected and I was not selected for the available position (Junior to "normal" level, with 4 days of time to finish the test). Could you point out which areas need improvement in my solution? Thank you! I...

 
6:28 AM
0
Q: Swap images on click with specified image

Stevei am new to Jquery and needed a solution for the following problem: There are 3 images in a row and when the user clicks on one of them all three pictures are hiding and instead another image shows up (depending on the click). So while the markup and css is quite simple and only a quick draft the...

 
that espresso simulator question seems.. under-specified
 
0
Q: Teamwork - editing your answer based on another answer or comment

firdaThis will be related to teamwork on this question: So we all had some ideas and I really don't want to: Accuse anybody of stealing my ideas - it is great to see somebody use and enhance it or even make the incomplete idea (preprocessing + different structure in this case) into complete solutio...

 
Monking
Log in to RDP session... Taskbar is gone, yay!
Restarting explorer.exe luckily worked
 
7:25 AM
Monking
 
7:57 AM
Monking @Vogel612
༼ ͒ ̶ ͒༽
^ Unicode troll
 
help how do I fix indentation
0
A: Bouncing stacking boxes

Pimgdif (this.velocity > dampening) { this.velocity -= dampening; } else { this.velocity = 0; } this.velocity = -this.velocity; Seems like you could use Math functions for this: this.velocity = Math.min((this.velocity - dampening)*-1, 0); That will simplify it somewhat. There's this too:...

 
8:13 AM
0
Q: Small PHP Router

trollzI'm building for my very small MVC Framework a small router class. Could someone look over it and tell me what to make better? I have not idea how to make good error handling. I would like to make it with exceptions, can someone give me a hint? => routes.php (Register all Routes) $route->get(...

0
Q: insert topspeed(tps) file into ms sql database using sql scripting

purpleI have tried use topscan.exe and extract tps into text. The text file can be imported into ms sql database manually. Are there any way to import tps file to ms sql and read file from database. Thank you.

 
11
Q: What is the purpose of a Code Review

ChadI am in the process of trying to sell my organisation on the value of code reviews. I have worked at several places where they were employed. I have seen them used to nitpick styling choices, and functional decisions, and I have seen them used as nothing more than a gut check to make sure nothi...

Interesting...
 
+1, I think you spotted the main points well, with the correct priorities. Keeping the design consistent when dealing with coworkers who constantly find very creative "WTF" solutions can only be achieved by regular code reviews. — Doc Brown 12 hours ago
I'm glad I can at least identify some of my own
Plus points if I identify them while implementing, also called hacks
 
8:29 AM
Monking
 
Monking
 
Only one JS answer? That's less than I expected...
 
yeah well the rest is lazy
 
Monking @SimonAndréForsberg
> This project cannot be added because it does not produce a JAR file using an Ant script.
Aaargh
 
@Malachi glad you like it. You might see more JS games by me.
 
8:32 AM
More the reason to convert all my work projects to Maven
 
0
Q: ASP MVC Model Binding With a ViewModel

gerdiI have a ViewModel, well i have two ViewModels actually with the one referencing the other. public class GiveViewModel { [Required] public int GivenLifelines { get; set; } public string ToUser { get; set; } public string FromUser { get; set; } } public class UserDetailsViewMode...

1
Q: Recursive linear search - style and layout

dcorkingIs my layout of the if/else statement reasonable? It feels clumsy to me to spread the termination condition over the first three lines of the function. Can I squeeze it into one or two lines? Would it help if I used the ternary operator? How can I make the JavaScript more idiomatic? Any other i...

 
many thanks @200_success
 
1
Q: Teamwork - editing your answer based on another answer or comment

firdaThis will be related to teamwork on this question: So we all had some ideas and I really don't want to: Accuse anybody of stealing my ideas - it is great to see somebody use and enhance it or even make the incomplete idea (preprocessing + different structure in this case) into complete solutio...

Hi all, I came here for some good hint how to resolve that.
 
Could you convert the addendum to your answer into a comment?
 
It in fact still is my idea, but there was something injected to the thought process from another answer. Now I have a dilema how to proceed.
 
8:43 AM
2
Q: Thumbnails for bootstrap carousel jQuery plugin

SrleCodepen: http://codepen.io/srkimir/pen/mGbrf Github: https://github.com/srkimir/thumbnails-carousel While you slide left or right appropriately, thumbnails gets selected and change their opacity to be different among others thumbnails. You can also click on thumbnails to show the appropriate i...

 
@200_success: well, yes, probably, at least for now, until I come with complete solution. Thx
@200_success: could you look at my edit. Is that good?
 
Looks good, I think. Let's move on then.
 
Monking
 
@200_success: thx, resolved :)
 
S/O answer, but what do you guys think of my answer here? stackoverflow.com/a/25782647/1073868
 
9:10 AM
Does anyone know how to specify a regex that never matches? Situation: I am using a regex to determine if I should wipe out a character or not, in the default case I do not want to wipe out any character
 
> Does anyone know how to specify a regex that never matches?
@skiwi can you give an example of expected output from input?
 
@DanPantry Say I have words ["a", "0", "b"] I could specify a regex to remove all digits
That's the way my method works
but now I do not want to remove anything and I can neither omit the regex
 
can you make the regex = ""?
(empty string)
 
I can try
 
9:17 AM
How about matching any group of only digits that contains a character?
Constructs like that.
 
@DanPantry It seems to work
@Pimgd I'm actually just supplying it to a String#replaceAll(regex, "") call
But the nature of the part described above is that my output is a list of individual symbols (more precisely, a list of Symbol classes, containing the String symbol of the symbol)
 
@skiwi /[]/g
Match any character in this group of 0 characters.
 
Only worry now is that it will start doing unnecessary replaces, but that may be a flaw in my design
 
alternative is /[^/s/S]/g - Match any character that is not (whitespace or not whitespace)
 
Is there also a regex possible that is impossible to match? Though then it will do extra work to try to match it
 
9:24 AM
Erm... do you not read what I write or something?
 
@Pimgd: interesting options, didn't think of those
 
@Pimgd Not when I am still typing, actually
now I see it though
 
I prefer the first one though, it's basically saying "match any character that is in this empty list of characters". Seems like it's flawless whereas "match any character that is in the set of whitespace characters and not in the set of non-whitespace characters" might have some strange quirks somehow.
 
What is then the difference between literally nothing and []?
 
[] is the set match operator
anything within [] is treated as one set, and will match any thing within that set
for example [abc] will match a, b or c
if [] is empty, then you're saying 'match with no characters' which obviously doesn't work :p
so regex should match nothing
 
9:32 AM
The danger of //g is that it matches 0 characters - that is, any empty string that can be made from your string.
 
@DanPantry Ah of course, that construct
 
So you get infinite hits.
Alternative regex that will go much faster, I think would be if you can insert the length of the string
then match any string that's longer than the bit of text that you're searching
 
@Pimgd That could work, if I only knew how
 
/[^]{LENGTH}/g
or /[/s/S]{LENGTH}/g
I suggest trying both
that is, try /[]/g, /[^]{LENGTH}/g and /[/s/S]{LENGTH}/g for performance
 
Yeah, but it is statically defined, so I cannot pass the length in the regex itself
 
9:39 AM
99999999999999999999999999999999999999999999999999999999?
 
At least in PCRE, you can't have empty character classes such as “[]” or “[^]”. Use “.” to match any character
 
then /.^/
 
0
Q: Trying to make this code more efficient

WillCurrently I'm using this code: <?php /* Clean, Simple, Minimal. */ $pages = array('home', 'login', 'register', 'logout', 'test'); if (isset($_GET['p'])) { $page = $_GET['p']; if (in_array($page, $pages)) { include('pages/' . $page . '.php'); } } else { echo 'Hi'; } ?>...

 
that one might be best actually
"match not any character"
ah crap linebreaks
scratch that /.^/ does horrible things
 
what exactly are you trying to do?
 
9:42 AM
@skiwi /[^a]+b/ <--- Matches all non-a's and then a b. Totally impossible.
I'm with @amon. Your question does not make sense.
 
Read up a bit, I explained it there, unless you've still got questions
 
You don't have two problems, you have at least three.
 
Skiwi made a doodoo and now he's forced to return a regex which matches no groups for use in String.replaceAll
 
> Situation: I am using a regex to determine if I should wipe out a character or not, in the default case I do not want to wipe out any character
if (regex == null) {
   // do nothing
}
else {
   // wipe whatever you want
}
 
So you want a regex that matches nothing, i.e. always fails?
 
9:45 AM
And ideally said regex is fast
 
@amon Yes
@SimonAndréForsberg Using null to indicate behavior is meh
 
You shouldn't handle this at the regex-level, you should handle it at a code leve.
 
@skiwi null for behav-
...
I think it's whack time
 
@skiwi Just an example. The principle is the same. Use the code, @skiwi
 
9:45 AM
where I roll up my mousemat and whack you.
 
@Pimgd whack me?
 
strategy pattern time
 
@skiwi In PCRE, I'D use a negative lookahead like (?!). Otherwise, use a charclass that matches no characters, i.e. [^\s\S] or [^\w\W].
 
str => Regex.Match(....) and str => str
 
For some reason "" seems to be working in Java
so that's literally an empty regex
 
9:46 AM
Because "" matches nothing
As @SimonAndréForsberg said this should be handled at a code level - I didn' want to say it because I get in trouble for not answering a question directly but instead saying "no, do this instead" :p
 
"" should match any zero-length substring – i.e., any string
 
I don't see a clean way to do that yet... But atleast I made a //TODO for it!
 
@skiwi use the strategy pattern. ask for a Function<String,String> or Function<String,Boolean> and let that do the regex comparison
@amon yeah according to regexr "" is infinitely matchign so it matches everything. Infinity is a weird concept
 
so I went looking at grepcode
 
@DanPantry It's not the first time @skiwi asks an XY-question...
 
9:48 AM
I just went from a clean Function<String, String> mapper method that can replace whatever it wants, but I couldn't use that somewhere else, so I refactored it here
 
if (pattern.length() > 0) {
1150            compile();
1151        } else {
1152            root = new Start(lastAccept);
1153            matchRoot = lastAccept;
1154        }
 
Because in practice I was never replacing anything, I was only removing things, so I figured a replace is no appropiate
 
well, technically by removing things you are replacing a character with an empty character ;-) if you do String.replace('a', '') that is
 
That would work fine if I was always dealing with Strings, but I am dealing with a List<Symbol> at some point
Where the Symbol class has an attribute String symbol <- Yes, that name needs a refactoring
Or it's actually a SymbolChoice instead of Symbol
 
list.toString().replace()
huehuehuehu
 
9:51 AM
pfff replaceAll("",...) does a lot
I'm already 12-14 function calls deep and I'm still not sure whether it's safe
3
 
@DanPantry I still need it in the form of List<SymbolChoice>, a replace function does actually not even make sense in my context... I cannot add or replace anything, I can only remove things
 
@skiwi it was a joke :p perhaps you should filter, rather than remove? doesn't java have .where on a list?
 
@DanPantry Yeah, could also work
 
certainly i knwo tehre's some kind of bastardized version of LINQ in Java
 
It may be in a working state now
 
9:53 AM
Filtering implies using strategies anyway so that's two birds with one lambda expression there
 
So I'm happy with a working state for now
 
If not you can still do foreach(SymbolChoice choice : list) { if(!(strategy(choice)) continue; }
 
@skiwi... I suggest passing empty string back and just checking if it's empty before using replaceAll. Cause there's so much objects constructed and code ran that a single if seems a much cleaner workaround
 
Well, this was just my first refactoring and code got a lot cleaner already
Another one is planned... And after that, another one
 
9:56 AM
And I'm not sure, but it looks like you incur a O(n) penalty for it
If not more.
@SimonAndréForsberg You're talking to the wrong person.
 
@skiwi
 
Mandatory announcement btw
You all know you can enable/disable desktop notifications?
 
^^ yes. still haven't tried them though
 
@SimonAndréForsberg they're actually working again, y'know
 
9:59 AM
@DanPantry you are repeatedly referring to higher-order functions as the “strategy pattern”. This is inaccurate. The Strategy Pattern is when you have an abstract base class. You then subclass the strategy to fill in the required methods. The Command Pattern is about using objects to pass around some action. Usually, these command objects only have a single methods like execute or apply. They are the OOP encoding of first-class functions.
 
:17617761
> The strategy pattern

defines a family of algorithms,
encapsulates each algorithm, and
makes the algorithms interchangeable within that family.
 
lambdas in Java compile into Runnable/Consumer<V> etc. While a lambda is a higher order function it is compiled into a class. Further , the callee takes a Runnable/Consumer<V> as an argument, not a function
 

« first day (495 days earlier)      last day (3515 days later) »