I think "I'm" and "I am" are mostly interchangeable informally, whereas "I am" is best for formality. On SE, I think the former would apply. Now, if this change was pretty much the only thing in that edit, I probably would've rejected as too minor.
There are currently 61 questions tagged software-design, 214 questions tagged design, and 47 questions tagged architecture. Some questions are tagged with a combination of those tags.
I'm not sure what benefit these tags have.
The software-design wiki mentions design concepts, design considera...
I've put together a board for Ultimate Tic-Tac-Toe (What's that?). This is part of the current code-challenge: Code a Ultimate Tic-Tac-Toe
Resources:
Live demo of my view – For you to see what I did there
Simon's working implementation – To illustrate that this is going to be a functional game...
Please can you help me do it? I tried but can't figure out how to exactly do it. I am not really expert in JavaScript and had to get lot of help to get the above working – Loai 1 min ago
This is already quite tight, I like it.
There is one big thing that jumps out:
validator = this;
var currentmsg =this;
You are using this, and validator and currentmsg all really pointing to this, that is making it harder than needed. Furthermore you escape scope by not using var for validator!
Please can you help me do it? I tried but can't figure out how to exactly do it. I am not really expert in JavaScript and had to get lot of help to get the above working — Loai5 mins ago
In my opinion, the null tag is not helpful for anyone. Even if this tag matches the content of the question, it might be a bit too specific.
I'm not a programmer. What are your opinions on burninating the tag?
The null tag has four tagged questions:
Reducing cyclomatic complexity in a simpl...
@lol.upvote: Yeah, kinda sounds like help vampirism. As this is a Q&A site, we're not obligated to explain many things on request, especially if there's a minimal understanding issue.
In my opinion, the null tag is not helpful for anyone. Even if this tag matches the content of the question, it might be a bit too specific.
I'm not a programmer. What are your opinions on burninating the tag?
The null tag has four tagged questions:
Reducing cyclomatic complexity in a simpl...
I just wrote this and don't like how bulky it is, also given the fact I will have to add at least another if statement.
I was going to switch it to a case statement but wanted to check if there were even better ways to reduce the clutter?
string emailLetterPath = Server.MapPath("~/emails/re...
I have the following code below and it's taking quite some time to run due to high volume of answers there are. Is there anyway I could speed it up?
var controlStrings = answerControlStrings.Where(a => a.ControlN.Substring(a.ControlN.IndexOf('_') + 1, a.ControlN.Length - a.ControlN.IndexOf('_')...
Implementing basic sorting algorithms to learn them, and coding, better. Criticisms/ critiques welcome. Also possible optimizations.
import unittest
import random
def merge_sort(seq):
"""Accepts a mutable sequence. Utilizes merge_sort to sort in place, return
a sorted sequence"""
if...
It all works exactly as it should. It finds data from today, finds unique emails and puts them in an array. I then check the data again from today, against the emails to total up different values. Then output those values to a sheet.
I'm sure there might be better methods to do what I wish. Su...
I have the following code below and it's taking quite some time to run and I'm getting an Out of Memory Exception due to the high volume of answers there are. Is there any way I could speed it up?
var controlStrings = answerControlStrings.Where(a => a.ControlN.Substring(a.ControlN.IndexOf('_') ...
It all works exactly as it should. It finds data from today, finds unique emails and puts them in an array. I then check the data again from today, against the emails to total up different values. Then output those values to a sheet.
I'm sure there might be better methods to do what I wish. Su...
Define "high volume"? What's exactly constitues an answer - we have nothing to review here, and it's not clear whether you're asking for a peer review or for us to find where your OutOfMemoryException comes from. Former is fine but needs more context, latter is off-topic on this site and needs more context. — lol.upvote45 secs ago
@Grey Yes, at least in this case. When we do var foo = "abc" the compiler looks at that and sees that foo will be a string. So it's the same as string foo = "abc", just less verbose. It's still statically typed and everything
@lol.upvote Statically typed is when you know the type at compile time (I think). C# and Java and stuff are statically typed languages, you have to declare the variable's type along with it. JavaScript and PHP for example are dynamically typed languages, you have no idea at compile time whether a variable is an object, which class it is (if any), if it's an array, or int, or string, or double, and so on...
(Can you tell that I don't really like dynamically typed languages?)
"A type, in type theory, which has the property that it is the subtype of all other types in the universe. As it is impossible for an instance to be a member of all types (there is no instance which is a record, AND a boolean, AND a function, for instance); this type is empty or "uninhabited"; no instances of this type exist."
class Dog {
int legsCount;
public void addLegs(int x ) {
this.legsCount += x;
}
}
Imagine: I have called the method addLegs on an instance and updated the legsCount, and I now want to rollback the method call so that the legCount remain unaltered.
Is there any ways to achieve this using an...
Well, there was an algebra problem that was asked yesterday. I'm still not sure how that even got here...
@konijn: If CR had a Medal of Honor badge to award, you'd probably earn it. Hardly anyone would be likely to answer so many zombies, with just rep and bronze badges as payment.
@Grey No. The “bottom type” concept is just a formalization of dynamic typing – if the expression foo is of the bottom type, it can be used where any other type is expected, be it an int or a string or any other object. Not all languages with an unified type system have a bottom type.
Java has an unified type system for objects, but no bottom type. Instead, you'd use the top type (Object) and downcast wherever needed: Object foo = ...; String bar = (String) foo.
Not only is it bad practice, I'd say it's horrible practice. Save yourself, or others which will be dealing with your code, some future headache and use as few static variables as possible, preferably none!
I'd say that not using the default constructor is perfectly fine, if all your Reporter ob...
How can I add different background image in different JButtons which is in array.
import java.awt.*;
import javax.swing.*;
public class Snake_Ladder {
public static void main(String[] args) {
new Snake_Ladder();
}
public Snake_Ladder(){
int i;
JFrame frame = new JFrame();
JPanel pane = ne...
In addition to what others already have mentioned, I just have a few things to add:
Magic numbers. Why 7? Where does that come from? Why 6? (There are 20-sided dice as well). Declare these numbers as constants, usually any number that's not 0 or 1 (and even those too sometimes, for when you don...
I have the following function, intended to take standard dice notation (XdY+Z) and return a (sort of) random number based on the input. Are there any bugs/bad ideas/optimizable sections I am missing?
function dieRoll(dice) {
if (/^[\d+]?d\d+[\+|\-]?\d*$/.test(dice) == false) { //Regex valida...
I have the following function, intended to take standard dice notation (XdY+Z) and return a (sort of) random number based on the input. Are there any bugs/bad ideas/optimizable sections I am missing?
function dieRoll(dice) {
if (/^[\d+]?d\d+[\+|\-]?\d*$/.test(dice) == false) { //Regex valida...
Unfortunately your question about "How to..." is off-topic for this site but I feel that your code really needs to be reviewed as there are some things that can be improved.
Don't import .* Only use the imports that you need. If you need to import JButton, import JButton, don't import all other...
@SimonAndréForsberg: Would you prefer to ask about this on Meta?
On another note, I'm proceeding with killing null. As for this question, there is no language tag (that might also explain the low views in nearly a year).
I have a simple two-class hierarchy to represent U.S. ZIP (12345) and ZIP+4 (12345-1234) codes. To allow clients to allow both types for a field/parameter or restrict it to one type or the other, the specific types inherit from a common generic ZipCode interface.
Update: A ZIP code is five digit...
@rolfl I don't think my loop and yours are very different. My loop is equivalent to the more verbose int i; for (i=0;n>1;++i) {...} return i;which is the same as yours.
But I appreciated the heads-up that you had edited. I appreciate your revisiting it, to leave no bad answer behind.
@ChrisW - I really went back for myself.... I have two down-votes on that answer, and it irritates me when I mess things up. Essentially, that QA is a mess, and I figured it needed a bit of history (I also rolled-back an edit on the main question which I found invalidated a lot of things).
At least I am now satisfied I got it right.... and I think the OP has it wrong by accepting the answer he has....
I have the following code and it's taking quite some time to run. I'm getting an Out of Memory Exception due to the high volume of answers there are. Is there any way I could speed it up?
var controlStrings = answerControlStrings.Where(a => a.ControlN.Substring(a.ControlN.IndexOf('_') + 1, a.Co...
@rolfl It's for sure not the fastest; but fwiw it's the one I chose to test mine against.
@rolfl Are you kidding? You don't really believe he's asking for the most efficient way to run out of memory. He's saying, "I build a dictionary as follows but this implementation is slow and may run out of memory".
@ChrisW: I'm getting an Out of Memory Exception due to the high volume of answers there are <--- the only answers to that are: get more memory, don't do what you're doing.
There is no way to store what he's storing, so therefore it needs a redesign
Your answer makes it just a neater way to run out of memory, you're storing all the same data, in all the same structures, but your out-of-memory is more readable ;-)
and the asker does not show what sort of loop structure or other call mechanism is used to call the code.
I assumed that "Where" is the only 'loop'. If he has enough memory to store answerControlStrings then I'd guess he has more-or-less enough memory for newAnswer too.
I mean, it's not very clear. If he'd posted more he might have got a better answer. But I thought there was enough code to review, little though that was.
@ChrisW ... would it make sense to remove the items from the controlStrings list as it is iterated, so that you don't keep both the controlStrings values as well as the substrings of them?
After programming in Haskell for a while, I've gotten attached to a functional style. This is clearly evident in the code for my genetic algorithm.
Could you provide me with some hints as to how I can make this code more pythonic? By that, I mean provide some method of organisation rather tha...
I had a situation when I needed to move all array elements in circular fashion. When I say this, I mean:
0 1 2 3
1 2 3 0
2 3 0 1
3 0 1 2
So the array:
var players = ["hash1","hash2","hash3","hash4"];
Players is the array that contains user hashes and their place on the table. Table is round...
I've done some reading about implementing AES256 and deriving a key from a password. If I understand correctly:
I want to generate a new salt (for the key) and a new IV (for the encrypted message) for every new message.
It should also not be a problem sending the salt and the IV together with ...
@rolfl Assuming that controlStrings is a list, altering the list while you're iterating it probably throws. My usual workaround if I need to, has been to make a copy of the list, so that I can iterate one while mutating the other (which wouldn't help here).
I've written an implementation of a dynamic array in C, but I'm not sure if my implementation is correct... This is what I'm worried about: if I add an element, will it remain in the collection? This problem has arisen from my (apparently) limited knowledge on void pointers. I haven't found any a...
I've implemented a common wrapper pattern I've seen for the .Net cache class using generics as follows:
private static T CacheGet<T>(Func<T> refreashFunction, [CallerMemberName]string keyName = null)
{
if (HttpRuntime.Cache[keyName] == null)
HttpRuntime.Cache.Insert(keyName, refreash...
I created this testimonial on CodePen
I am a bit skeptical about a few things in my HTML structure. For example, I typically see testimonials enclosed in <div>s with custom classes. In my case I used a <blockquote> but had to overwrite a lot of rules.
Also wondering if enclosing the author in <
@JamesKhoury I'm suspicious of temporaries created inside Linq's Where, and a local variable bound to each Where, and the fact that he iterates the resulting enumerale 4 or 5 times; but I don't see/understand why temporaries aren't created/destroyed on demand (if they aren't being, and their not being is what's causing 'out of memory').
@ChrisW Good question. I don't know. The OP needs to give us some numbers of the amount of times this s being run and the number of questions. otherwise it would be too hard to tell.
Also a micro-optimisation might be to switch out the lists for arrays
After looking at it. I think there first .where( is kept around until the controlStrings variable is out of scope. Which means any memory created in the lambda is staying around till controlStrings leaves scope.
I'm guessing that GC runs on another thread when it thinks it's needed, and without blocking the user thread. So if the user's thread generates too much too quickly then it will throw.
@ChrisW I think in this case Linq is not the best choice. I think the for loop idea is good. With the minimum number of comparisons for speed and the minimum number of created objects to clean up.
I tried to make a calculator in Java, I added some stuff. As can be seen in the title I'm a beginner, I only learned yesterday how to make buttons ;). Here's my code:
import java.awt.Dimension;
import javax.swing.*;
import java.awt.Toolkit;
import java.awt.event.*;
public class JavaCalculatorCo...
Having gotten the Strunk & White badge, I can now see my review stats. The trouble is, I see nothing but zeroes both for today, and all.
In the past I've clicked through plenty of questions both in the "First Questions" and "First Answers" tabs on StackOverflow.com/review and voted/edited man...