body stringlengths 25 86.7k | comments list | answers list | meta_data dict | question_id stringlengths 1 6 |
|---|---|---|---|---|
<p>In my application, I have a small hierarchy of related classes (<em>partner categories - partners - partner points</em>).</p>
<p>The application has two representations of its content:</p>
<ul>
<li>in the form of partners points on the map</li>
<li>in the form of a list of partner categories or partners within a c... | [] | [
{
"body": "<p>I am not particularly fussed with the name <code>SearchableSortable</code>. This is a generic class ... if it was directly linked to Partners, then it would be different. You could probably do something to indicate the underlying data infrastructure, like <code>ListView</code> which allows you to ... | {
"AcceptedAnswerId": "39691",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T05:58:24.190",
"Id": "39641",
"Score": "6",
"Tags": [
"java"
],
"Title": "Class that represents searchable and sortable elements"
} | 39641 |
<p><a href="http://projecteuler.net/problem=26" rel="nofollow">Project Euler problem 26</a> asks us to:</p>
<blockquote>
<p>Find the value of <em>d</em> < 1000 for which 1/<em>d</em> contains the longest recurring cycle in its decimal fraction part.</p>
</blockquote>
<p>I wrote this function in Python to find th... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T09:18:51.987",
"Id": "66503",
"Score": "0",
"body": "Probably not worth an actual answer but gcd and decimal should probably raise ValueError if type is wrong or q is 0. Also, you are computing much more than what you realy need for... | [
{
"body": "<p>Trying to generate the actual string representation is interesting to understand the problem but you do not need to keep all that complexity in your code for problem 26. Indeed, you are only interested in the length of the cycle for <code>1/d</code>. Thus, what I did was to :</p>\n\n<ul>\n<li>remo... | {
"AcceptedAnswerId": "39651",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T06:35:58.550",
"Id": "39642",
"Score": "7",
"Tags": [
"python",
"project-euler",
"mathematics"
],
"Title": "Helper function to solve Project Euler question 26"
} | 39642 |
<p>I wrote a simple class in Python, which controls code invocation, in a multi-threaded environment, with the following logic:</p>
<p>The class' main method, named <code>try_to_do</code>, takes two function pointers as arguments: <code>yes_we_can_fn</code> and <code>no_we_cannot_fn</code>.</p>
<p>In any point in tim... | [] | [
{
"body": "<p>You could avoid the <code>is_active</code> variable by using the lock in a non-blocking manner:</p>\n\n<pre><code>def try_to_do(self, yes_we_can_fn, no_we_cannot_fn):\n if self.locker.acquire(False):\n try:\n yes_we_can_fn()\n finally:\n self.locker.release()... | {
"AcceptedAnswerId": "39655",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T10:17:02.580",
"Id": "39647",
"Score": "3",
"Tags": [
"python",
"multithreading",
"thread-safety"
],
"Title": "Invoke only by a single thread"
} | 39647 |
<p>We all know about the <a href="http://loungecpp.wikidot.com/tips-and-tricks%3aindices" rel="noreferrer">indices trick</a>, right? Here's (hopefully) an improved version...</p>
<pre><code>template <::std::size_t...> struct indices { };
namespace detail
{
template<class A, class B> struct catenate_indic... | [] | [
{
"body": "<p>You can get rid of the <code><type_traits></code> header by replacing your <code>std::enable_if</code> by a <code>bool</code> template specialization:</p>\n\n<pre><code>template <::std::size_t, ::std::size_t, bool>\nstruct expand_indices_impl;\n\ntemplate <::std::size_t A, ::std::si... | {
"AcceptedAnswerId": "43061",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T11:08:07.033",
"Id": "39648",
"Score": "10",
"Tags": [
"c++",
"c++11"
],
"Title": "Improved indices trick"
} | 39648 |
<p>I suspect that this can be done in a much neater way using list comprehension in python:</p>
<pre><code>poses = []
for x,y in get_points(spline):
pose = Pose2D()
pose.theta = 0
pose.x=x
pose.y=y
poses.append(pose)
return poses
</code></pre>
<p>Is there a way to create a nice one liner for the a... | [] | [
{
"body": "<pre><code>def make_pose(pt):\n pose = Pose2D()\n pose.theta = 0\n pose.x, pose.y = pt\n return pose\n\nposes = [make_pose(pt) for pt in get_points(spline)]\n</code></pre>\n\n<p>Alternatively, you could subclass <code>Pose2D</code> to give it an appropriate constructor.</p>\n",
"comme... | {
"AcceptedAnswerId": "39666",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T16:50:55.800",
"Id": "39665",
"Score": "8",
"Tags": [
"python"
],
"Title": "List iteration, creation, or comprehension"
} | 39665 |
<p>I need to write a function that, when given an input (string, float, or int), returns that input as a reduced partial fraction, and it needs to accept a wide array of inputs:</p>
<pre><code>1.5 => "1 1/2"
5/2 => "2 1/2"
"1/3" => "1/3"
5 => "5"
"6 1/3" => "6 1/3"
0 => "0"
</code></pre>
<p>I've wr... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T22:02:39.923",
"Id": "66574",
"Score": "1",
"body": "I misread the title at first. I was disappointed when I found that no partial _function_ is involved :) Still, good question."
},
{
"ContentLicense": "CC BY-SA 3.0",
... | [
{
"body": "<p>Non-string input can lead to surprising results:</p>\n\n<pre><code>p (5/2).to_r #=> (2/1), integer division performed first\np (1.1).to_r #=> (2476979795053773/2251799813685248), float can not be represented in binary\n</code></pre>\n\n<p>The last case is prevented by:</p>\n\n<pre><code>p 1... | {
"AcceptedAnswerId": "39677",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T19:25:20.883",
"Id": "39671",
"Score": "6",
"Tags": [
"ruby",
"ruby-on-rails",
"mathematics"
],
"Title": "Return input as a partial fraction"
} | 39671 |
<p>This is a Python program to mint a hashcash token, but my code is a lot slower than using a library. What is slowing my program down? It takes over 10 seconds to mint a 20-bit stamp, but using a library, it takes less than a second.</p>
<p>This is my program:</p>
<pre><code>from os import urandom
from hashlib im... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T21:25:25.677",
"Id": "66564",
"Score": "0",
"body": "Aside from that you're (1) using strings (and formatters all over the place) rather than numbers, and (2) rebuilding the zeros-string each iteration even though it never changes?"... | [
{
"body": "<p>The first thing to do is to profile your code. Hashcash is really designed to make you perform 2^20 hashes: if you do more work than those hashes, something's wrong!</p>\n\n<h2>Profiling</h2>\n\n<p><code>python -m cProfile -s cumtime original.py</code></p>\n\n<p>Let's look at all the places where ... | {
"AcceptedAnswerId": "39731",
"CommentCount": "8",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T19:35:19.250",
"Id": "39674",
"Score": "8",
"Tags": [
"python",
"performance",
"cryptography"
],
"Title": "Python mint hashcash token"
} | 39674 |
<p>Just a plain button, in different sizes. I wanted to achieve exactly the same styling cross browser for both anchors, inputs and buttons.</p>
<p>I'm just wondering if this could be improved.</p>
<p><strong>Markup</strong></p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>CSS ... | [] | [
{
"body": "<p>I took the liberty of adding your code to a <a href=\"http://jsfiddle.net/WbsmE/\" rel=\"nofollow noreferrer\">Fiddle Here</a> so that we could see what it being displayed and test it in different browsers.</p>\n\n<hr>\n\n<p>I tried to set my Browser to IE 8 and less and apparently it doesn't play... | {
"AcceptedAnswerId": "39812",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T20:09:25.650",
"Id": "39676",
"Score": "6",
"Tags": [
"html",
"css"
],
"Title": "Plain CSS buttons in different sizes"
} | 39676 |
<p><a href="http://www.typescriptlang.org/" rel="nofollow">Typescript</a> was developed by Microsoft and is open-source. It is a superset of Javascript and includes optional static typing and class-based object orientation.</p>
| [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T20:52:10.967",
"Id": "39678",
"Score": "0",
"Tags": null,
"Title": null
} | 39678 |
Typescript is a language which is a super set of JavaScript | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T20:52:10.967",
"Id": "39679",
"Score": "0",
"Tags": null,
"Title": null
} | 39679 |
<p>An <a href="http://en.wikipedia.org/wiki/Interpreter_%28computing%29" rel="nofollow">interpreter</a> directly executes programming language instructions without a previously compiling them into a machine language. </p>
| [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T20:55:00.883",
"Id": "39680",
"Score": "0",
"Tags": null,
"Title": null
} | 39680 |
An interpreter is a computer program which directly executes instructions written in a programming language. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T20:55:00.883",
"Id": "39681",
"Score": "0",
"Tags": null,
"Title": null
} | 39681 |
<p><a href="http://en.wikipedia.org/wiki/Cyclomatic_complexity" rel="nofollow">Cyclomatic Complexity (Wikipedia)</a> was developed in 1976 by Thomas J. McCabe Sr. as a measure of the complexity of program methods, programs, or blocks. It works by tracking and counting all the linearly independent paths through a progra... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T20:57:22.783",
"Id": "39682",
"Score": "0",
"Tags": null,
"Title": null
} | 39682 |
Cyclomatic Complexity is a metric of the complexity of a program or a section of a program. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T20:57:22.783",
"Id": "39683",
"Score": "0",
"Tags": null,
"Title": null
} | 39683 |
<p>I've created this abstract base class for testing the <code>Equals</code> method.</p>
<p>The basic idea is that derived class implements methods to get:</p>
<ul>
<li>the primary test instance, and </li>
<li>a list of unequal instances (it's up to
the derived class to ensure that this list is sufficient instances f... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T09:42:13.710",
"Id": "66642",
"Score": "0",
"body": "`HashCode_DifferentObjects_NoneMatch` is wrong. From [`GetHashCode` documentation](http://msdn.microsoft.com/en-us/library/system.object.gethashcode%28v=vs.110%29.aspx) \"Do not t... | [
{
"body": "<p>It seems to be complete but keep in mind that equality is reflexive, symmetric, and transitive so, as a formality, I would add tests:</p>\n\n<ul>\n<li><code>a.Equals(b)</code> has the same value as <code>b.Equals(a)</code></li>\n<li>if <code>a.Equals(b)</code> and <code>b.Equals(c)</code> are both... | {
"AcceptedAnswerId": "39688",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T21:23:30.867",
"Id": "39684",
"Score": "8",
"Tags": [
"c#",
"unit-testing"
],
"Title": "Am I missing any unit tests in this base class for testing equality?"
} | 39684 |
<p>I have implemented a calculation of Pi in Python, just for the lulz.
But now I wonder if I could improve this more. Could you help me out? I do not program a lot in Python.</p>
<pre><code>from time import time
from decimal import *
def faculty(m):
k=m
n=1
while(n<m):
k=k*n
n+=1
i... | [] | [
{
"body": "<p>I find that your program is obfuscated and therefore incomprehensible to anyone except for perhaps an expert in those calculations methods. You should pick more informative variable names than <code>a</code>, <code>b</code>, <code>k</code>, <code>m</code>, <code>n</code>, and <code>x</code>.</p>\... | {
"AcceptedAnswerId": "39695",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T21:56:54.530",
"Id": "39689",
"Score": "5",
"Tags": [
"python",
"mathematics"
],
"Title": "Calculating Pi in Python"
} | 39689 |
<p>I need to split one <code>NSArray</code> into <code>NSDictionary</code>. Every key in <code>NSDictionary</code> will contain an <code>NSArray</code> with the object with the same value.</p>
<p>i.e. I have an array with 1000 customers and I want create an <code>NSDictionary</code> based on their zip code.</p>
<p>I ... | [] | [
{
"body": "<p>As far as name of the method is concerned I have two points:</p>\n\n<ul>\n<li>There is no need of the work <code>Array</code> here, as it is NSArray instance method.</li>\n<li>The work <code>With</code> gives wrong impression here. (the phrase \"group a with b\" will generally mean to group them t... | {
"AcceptedAnswerId": "39727",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T21:59:38.593",
"Id": "39690",
"Score": "6",
"Tags": [
"array",
"objective-c",
"hash-map"
],
"Title": "Splitting an NSArray into an NSDictionary of array more elegantly"
} | 39690 |
<p>I used the following code:</p>
<pre><code>#include<vector>
class UltrasonicRecorder
{
public:
UltrasonicRecorder(int referenceValue, Input referenceInput) :
_referenceValue(referenceValue),
_referenceInput(referenceInput)
{}
std::vector<int> GetData();
void RecordData(I... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-19T01:49:47.763",
"Id": "72426",
"Score": "0",
"body": "This does not look like a moving average. Could you separate the compensation part from the averaging part?"
}
] | [
{
"body": "<p>How about initializing the compensation factor so that it doesn't have to do the convergence from an undefined state?</p>\n\n<pre><code>UltrasonicRecorder(int referenceValue, Input referenceInput) :\n _referenceValue(referenceValue),\n _referenceInput(referenceInput)\n{\n _compensation = ... | {
"AcceptedAnswerId": "44086",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T22:34:07.683",
"Id": "39694",
"Score": "7",
"Tags": [
"c++",
"algorithm",
"floating-point"
],
"Title": "stability of an exponential moving average"
} | 39694 |
<p>I would like to replace the string "The quick brown fox jumps over the lazy dog" with the string "The1 quick2 brown3 fox4 jumps5 over6 the7 lazy8 dog9".</p>
<p>Is there an cleaner, more elegant, sexier way?</p>
<pre><code>String.prototype.concatWordNumber = function() {
var myArray = this.split(' ');
var my... | [] | [
{
"body": "<blockquote>\n <p>Is there an cleaner, more elegant, sexier way?</p>\n</blockquote>\n\n<p>I guess regex makes it more elegant and sexier, but your implementation is fine:</p>\n\n<pre><code>String.prototype.concatWordNumber = function() {\n var i = 1;\n return this.replace(/\\b\\w+\\b/g, function(w... | {
"AcceptedAnswerId": "39700",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-20T23:20:47.017",
"Id": "39699",
"Score": "5",
"Tags": [
"javascript",
"strings"
],
"Title": "Edit string to concatenate word numbers in javascript"
} | 39699 |
<p>I am starting with a starting colour, a target colour and a starting position in an image. I want to change every contiguous pixel if it is close to the starting colour.</p>
<p>Imagine a stop sign. It has white letters on a red background. But the red is faded to a bunch of different reds. It should work that all o... | [] | [
{
"body": "<p>An optimization in here would be for you to cache the results of your <code>FindDeltaColor</code> lookup in a dictionary.</p>\n\n<pre><code>deltacache = dict()\n.....\nwhile ...\n (a,b,c) = image.getpixel((x,y))\n delta = deltacache.get((a,b,c));\n if delta is None:\n delta = FindD... | {
"AcceptedAnswerId": "39810",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T00:21:32.853",
"Id": "39701",
"Score": "10",
"Tags": [
"python",
"performance",
"beginner",
"image"
],
"Title": "Recolour a shape"
} | 39701 |
<p>I made a simple program to catalog some old records I have. It seems a tad redundant in the searching function. Does anyone know what I can do about that?</p>
<pre><code>import easygui as eg
import sys
namedoc = open(r"C:\Users\User\Desktop\RcrdCat\names.txt", 'a')
nd2 = open(r"C:\Users\User\Desktop\RcrdCat\names... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T00:52:23.233",
"Id": "66592",
"Score": "1",
"body": "I think you may be confused about how `readlines` works http://stackoverflow.com/questions/14541010/pythons-function-readlinesn-behavior"
},
{
"ContentLicense": "CC BY-SA ... | [
{
"body": "<p>So I've got a little disclaimer. I'm not at a pc with python on it.</p>\n\n<p>A quick look would sugggest an approach like:</p>\n\n<pre><code>def searchrecs(term):\n hits = []\n\n searchterms = {\n \"name\": namedoc,\n \"year\": yeardoc,\n \"pub\": pubdoc,\n }\n\n ... | {
"AcceptedAnswerId": "39703",
"CommentCount": "6",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T00:35:54.010",
"Id": "39702",
"Score": "7",
"Tags": [
"python",
"python-3.x"
],
"Title": "Record Cataloging Program"
} | 39702 |
<p>This is one of the longest programs I have made with methods and I think I must be doing this rather inefficiently. Any comments to improve would be appreciated.</p>
<pre><code>package numberwords2;
import java.awt.Component;
import javax.swing.JOptionPane;
public class NumberWords2
{
static String rawInput;
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T14:35:50.813",
"Id": "66668",
"Score": "2",
"body": "Minor spelling: 19 = Nineteen 40 = Forty"
}
] | [
{
"body": "<pre><code>int input = Integer.parseInt(rawInput);\n</code></pre>\n\n<p>This can throw an exception if rawInput isn't a number.</p>\n\n<hr>\n\n<pre><code> else if(input < 10)\n {\n output += ones(0);\n }\n else if(input < 20)\n {\n output += teens(0);\n }\n el... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T01:51:29.610",
"Id": "39707",
"Score": "8",
"Tags": [
"java",
"parsing",
"converting",
"extension-methods",
"numbers-to-words"
],
"Title": "Digit to words converter"
} | 39707 |
<p>Below is a Singleton that I designed as a piece of sample code for a website I'm working on for fun. The goal is to use the Singleton to hold an <code>Earth</code> object since Earth is unique and there is only 1 of them. Please let me know your thoughts on the implementation. </p>
<p><strong>Singleton.java</strong... | [] | [
{
"body": "<p>The code you have is nicely formatted, and well documented, etc. ... but, as a singleton, it has a number of problems....</p>\n\n<p>The two most glaring are:</p>\n\n<ol>\n<li><p>It is not a singleton</p>\n\n<pre><code>Earth real = Earth.getInstance();\nEarth.setEarth(null);\nEarth alternate = Eart... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T02:53:06.397",
"Id": "39710",
"Score": "6",
"Tags": [
"java",
"singleton"
],
"Title": "Simple Java Singleton"
} | 39710 |
<p>This is a parsing function that will at tildes (~) to end of search terms in certain circumstances.</p>
<p>Example an inputs and outputs:</p>
<pre>
Input: Output:
name:(john doe) name:(john~ doe~)
name:[andy TO charlie] name:[andy TO charlie]
john doe ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T04:04:42.917",
"Id": "66622",
"Score": "0",
"body": "What would be an example of `rawQuery`? Can you provide input and output? I don't fully understand what you're doing here..."
},
{
"ContentLicense": "CC BY-SA 3.0",
"C... | [
{
"body": "<p>You aren't using regular expressions to your advantage. Capture, don't split. Capturing helps you analyze the tokens you are interested in. Splitting just gets you the location of the delimiters.</p>\n\n<pre><code>function fuzzQuery(rawQuery) {\n \"use strict\";\n // ( 1 ) ... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T03:55:51.653",
"Id": "39715",
"Score": "6",
"Tags": [
"javascript",
"parsing"
],
"Title": "Parsing function is 50 lines long"
} | 39715 |
<p>I would prefer if more experienced users could give pointers on how I can optimize and think better when writing code.</p>
<p>If you are unfamiliar with unity3d, ignore the use of UnityEngine, the heritage from <code>MonoBehaviour</code> as well as the <code>Debug.Log();</code>, <code>Debug.LogWarning();</code>, an... | [] | [
{
"body": "<ol>\n<li>Your code style is really inconsistent. As if you were copypasting code blocks from various places and didn't bother to refactor it. Part of the reason your code is hard to read. A somewhat accepted code style is: a) prefix field names with underscores, b) if possible use auto-properties fo... | {
"AcceptedAnswerId": "39719",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T05:13:09.957",
"Id": "39718",
"Score": "4",
"Tags": [
"c#",
"xml",
"unity3d"
],
"Title": "Dynamic Storing Objects from XML in RPG"
} | 39718 |
<p>I have started to learn C and I have tried my hand at temperature conversion. The idea is to convert a temperature from Fahrenheit to Celsius and vice/versa. Can somebody review my code and let me know how I might be able to improve it? My program is as follows:</p>
<pre><code>#include <stdio.h>
void fahco... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T15:46:44.490",
"Id": "66671",
"Score": "1",
"body": "Considering your preference for wide open space for curly-brace-delimited things, your math (and comma) operators feel a bit snug. Regarding the actual math, your use of floats in... | [
{
"body": "<ul>\n<li><p>You don't need <code>invalidchoice()</code> as it just prints a statement and nothing else. Just put the <code>printf()</code> under <code>default</code>.</p></li>\n<li><p>Consider receiving all user input in <code>main()</code> and having the functions only do the calculations. It's b... | {
"AcceptedAnswerId": "39722",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T06:19:24.403",
"Id": "39720",
"Score": "14",
"Tags": [
"c",
"beginner",
"converting"
],
"Title": "Temperature conversion in C"
} | 39720 |
<p>How could I simplify the <code>onCreate()</code> method? Maybe via compact and properly-named methods?</p>
<pre><code>public class FilterActivity extends FragmentActivity {
private Bundle args;
private FilterFragment filterFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {... | [] | [
{
"body": "<p>Is this method really a problem? Why are you worried about it? There are some small changes you can make, but they do not have much of an impact on the performance of the routine (if it is slow...).</p>\n\n<p>About the only things I can think of improving are:</p>\n\n<ol>\n<li>you check whether th... | {
"AcceptedAnswerId": "39742",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T11:33:00.520",
"Id": "39732",
"Score": "2",
"Tags": [
"java",
"android"
],
"Title": "Filter fragments manager"
} | 39732 |
<p>I have finished a program, and it does what I want it to do, but I feel I am "doing it wrong", even though it's seemingly efficient enough. I have prepared a small example of what I feel I am handling wrong with the <code>backgroundworker</code> class and would like to see if I could have handled this any more clean... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T12:10:04.223",
"Id": "66649",
"Score": "0",
"body": "Your thing with the alphabet, what is it supposed to model? Progression of a single process?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T18:38:... | [
{
"body": "<p>In general, passing controls to the <code>BackgroundWorker</code> should not be necessary at all. Think about it as it simply has some <em>job</em> to do and that's all. However, it can of course <em>report</em> about progress of its job. Those two ideas were taken into account when designing <cod... | {
"AcceptedAnswerId": "39758",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T11:38:44.120",
"Id": "39733",
"Score": "10",
"Tags": [
"c#",
"thread-safety"
],
"Title": "Abuse/Misuse of C# BackgroundWorker?"
} | 39733 |
<p>As I understand creating lots of resource managers in C# may be a bad idea so I thought that the best thing to do would be to create a singleton for this.</p>
<p>However, I'm not 100% if this is a good idea, or if this is a good way to implement it. </p>
<p>The main thing about the implementation I am unsure about... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T23:23:24.217",
"Id": "67013",
"Score": "0",
"body": "I think this may be an extension of the same mistake that results in the use of ServiceLocators, in a slightly less dangerous manner. Both are a mess to try to test."
}
] | [
{
"body": "<blockquote>\n <p>The main thing about the implementation I am unsure about is making the \"Instance\" private and creating number of static functions to expose the functionality. This means I can call Local.GetString instead of Local.Instance.GetString which is less clunky. I have not seen any sing... | {
"AcceptedAnswerId": "39740",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T12:02:56.697",
"Id": "39735",
"Score": "4",
"Tags": [
"c#",
"singleton"
],
"Title": "ResourceManager Singleton"
} | 39735 |
<p>I have made some jQuery Fallback Support for the CSS Property "background-attachment: local" and I am mainly a CSS developer. I do some jQuery, but I thought I would check to see if I am doing this in the more efficient way, as I may have multiple versions of this on one page.</p>
<p><a href="http://codepen.io/2ne/... | [] | [
{
"body": "<p>This code annoyed me for a while, the part outside of the initialization does not belong and it seemed silly to add it to the listener. Plus, the code outside of the listener will mess up when you have multiple <code>data-holder</code> elements.</p>\n\n<p>Then I realized that I could take a differ... | {
"AcceptedAnswerId": "39931",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T14:51:43.343",
"Id": "39745",
"Score": "5",
"Tags": [
"javascript",
"optimization",
"jquery",
"css"
],
"Title": "jQuery Fallback Support for the CSS Property \"background-a... | 39745 |
<p>I am <a href="http://code.google.com/p/jmapper-framework/" rel="nofollow">using <code>JMapper</code> to map</a> from multiple sources to a destination class. Could you review it and let me know if the code looks OK to you? Please suggest any changes that I can make to improve it.</p>
<p>Interface to <code>Map</code... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-18T11:08:09.973",
"Id": "102547",
"Score": "1",
"body": "what you need is already implemented: https://code.google.com/p/jmapper-framework/wiki/ExplicitRelations There are many examples that will be useful: https://code.google.com/p/jm... | [
{
"body": "<p>I can understand the usefulness of a class/tool like this. The basic thinking is:</p>\n\n<ol>\n<li>need to transform class A to class B.</li>\n<li>also need to transform class C to class B.</li>\n<li>JMapper can help.</li>\n<li>there are other classes that need transformations as well</li>\n<li>we... | {
"AcceptedAnswerId": "91259",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T16:52:54.100",
"Id": "39749",
"Score": "8",
"Tags": [
"java",
"generics"
],
"Title": "Mapping from multiple sources to destination using JMapper"
} | 39749 |
<p><strong>Question</strong></p>
<blockquote>
<p>Suppose we have two sorts of classes</p>
<ul>
<li>an input class <code>Input</code>
<ul>
<li>defines a type <code>result_type</code></li>
<li>defines <code>set(result_type)</code></li>
</ul></li>
<li>an output class <code>Output</code>
<ul>
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T01:46:10.777",
"Id": "66731",
"Score": "0",
"body": "Just as a question, how are the arbitrary number of `Inputs` stored in `Output`?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T09:22:10.053",
... | [
{
"body": "<p>Looks to me as if you've already got the most elegant solution in mind.</p>\n\n<p>In C++14 you'd remove the dependency on <code>std::function</code> and simply return a naked lambda, like this:</p>\n\n<pre><code>template <class Output, class... Inputs>\nauto make_function(const Output& o... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T16:58:23.980",
"Id": "39750",
"Score": "7",
"Tags": [
"c++",
"c++11",
"variadic"
],
"Title": "Most elegant variadic functor"
} | 39750 |
<p>I'm receiving data from a serial port in C, using <a href="http://www.cmrr.umn.edu/~strupp/serial.html">Serial Programming Guide for POSIX Operating Systems</a> as a guide.</p>
<p>The data I receive should be always 10 bytes in length but I want to be sure that, if there is any error (more or less bytes received), ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T17:50:15.700",
"Id": "66681",
"Score": "1",
"body": "What do you mean by \"right solution?\" The \"right solution\" is the one that fulfills your particular requirements. What are your requirements?"
},
{
"ContentLicense":... | [
{
"body": "<p>The code you posted contains no error-recovery at all. It's a bit off-topic on this site to ask how to implement a new feature (error-recovery); but I'll try.</p>\n<p>It's not clear what your communication protocol looks like. It might be:</p>\n<ol>\n<li>A continuous stream of bytes, to be split i... | {
"AcceptedAnswerId": "39768",
"CommentCount": "7",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T17:47:30.837",
"Id": "39752",
"Score": "11",
"Tags": [
"c",
"stream",
"error-handling",
"timeout",
"serial-port"
],
"Title": "Reading from a serial port"
} | 39752 |
<p><strong>Accordion plugin</strong></p>
<p>As I don't use jQuery (because I just have fun with Chrome and iOS/Android) and I prefer to write my own functions, I decided to write a simple Accordion function some time ago:</p>
<ul>
<li>Short code</li>
<li>High performance</li>
<li>Latest JS CSS3 HTML5 technologies</li... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T19:39:07.323",
"Id": "66693",
"Score": "0",
"body": "What happened to the indentation? You really use 1 space and no whitespace? It reads like minified code."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-... | [
{
"body": "<p>Your code has a lot of style problems, so many style problems that it would take a long time to figure out what it does. Well written code does not pose this problem. I can really only point out what you are doing wrong style wise and after the code is cleaned up, perhaps we ( or you yourself ) ca... | {
"AcceptedAnswerId": null,
"CommentCount": "9",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T19:34:42.437",
"Id": "39755",
"Score": "2",
"Tags": [
"javascript",
"classes"
],
"Title": "Accordion JS plugin, CSS3 webkit"
} | 39755 |
<p>A while back I wrote the following code (target is embedded C code on an 8 bit atmel device):</p>
<pre><code> bool received;
tryAgain:
received = radioReceive(radiogram, MatchTree, CycleClock, duration);
if (received && radiogram->timeSlit == SolicitMask)
goto tryAgain; // not interest... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T21:00:20.780",
"Id": "66712",
"Score": "2",
"body": "`Is this just a case of the Law of Conservation of Ugly?` .... thank you kind sir. Much appreciated. I can use that frequently."
}
] | [
{
"body": "<p>If you can do without the <code>received</code> variable...just make the <code>radioReceive(...)</code> the condition of a <code>while</code> loop. You get rid of <code>received</code>, and your loop condition now has a purpose. :)</p>\n\n<pre><code>while (radioReceive(radiogram, MatchTree, Cycl... | {
"AcceptedAnswerId": "39760",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T19:54:00.363",
"Id": "39757",
"Score": "5",
"Tags": [
"c",
"embedded"
],
"Title": "Better way to write this branch with an exceptional retry in an embedded C environment?"
} | 39757 |
<p>I'm writing my first JavaScript application (no 3rd party libraries used) and looking for some high-level guidance on how to better organize the code into separate classes & files.</p>
<p>Here is a simplified/contrived example to illustrate my current organizational layout/problems:</p>
<p>game.js:</p>
<pre><... | [] | [
{
"body": "<h1>Using a closure</h1>\n\n<p>You can avoid putting constants in the global scope by wrapping <em>everything</em> in another closure, i.e. the code produced after the compiling process should look something like this:</p>\n\n<pre><code>(function() {\n/* all your definitions here */\nfunction ui() {\... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T21:17:17.573",
"Id": "39761",
"Score": "8",
"Tags": [
"javascript",
"game"
],
"Title": "Graphical game application"
} | 39761 |
<p>How can I simplify this in Delphi?</p>
<pre><code>Procedure colori1
Begin
if Temperatura<=15 then
begin
Form1.Label1.Font.Color:=clBlue;
Form1.Label2.Font.Color:=clBlue;
Form1.Label3.Font.Color:=clBlue;
Form1.Label4.Font.Color:=clBlue;
Form1.Label5.Font.Color:=clBlue;
end;
if (Temperatura>=16)... | [] | [
{
"body": "<p>Declare a local variable to hold the color:</p>\n\n<pre><code>var\n Color: TColor;\n</code></pre>\n\n<p>Then decide what the color should be:</p>\n\n<pre><code>if Temperatura<=15 then\n Color:=clBlue;\nelse if Temperatura<=18 then\n Color:=clAqua;\nelse ...\n</code></pre>\n\n<p>Then assig... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T21:26:30.283",
"Id": "39763",
"Score": "11",
"Tags": [
"delphi"
],
"Title": "Make it easier with color changing"
} | 39763 |
<p>I have coded a webpage and it looks exactly how I want, but I think there could be improvements, possible as unnecessary floats, etc...</p>
<p>Could anybody please review my <strong>CSS</strong> code? Its not difficult or vague, I guess.</p>
<p>DEMO:
<a href="http://jsfiddle.net/dqC8t/2364/" rel="nofollow noreferr... | [] | [
{
"body": "<p>Font:</p>\n\n<pre><code>font-family: 'ProximaNova-Regular';\n</code></pre>\n\n<p>You need a fallback font (or two). If this one doesn't exist then it needs to find another appropriate font. Usually I will put serif, san-serif or monospace last. For example:</p>\n\n<pre><code>font-family: 'ProximaN... | {
"AcceptedAnswerId": "40113",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-21T23:01:35.467",
"Id": "39770",
"Score": "7",
"Tags": [
"optimization",
"html",
"css"
],
"Title": "Removing unnecessary floats, height, widths"
} | 39770 |
<p>I'm writing a service to parse machine log files as they are written to a central directory and push them to a web service. Each machine generates several log files at a time, with each file encapsulating a particular domain of operational information (e.g. user login sessions, errors, statistics, etc.).</p>
<p>The... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T06:02:06.960",
"Id": "66741",
"Score": "0",
"body": "What is your issue with worst-case scenario you proposed? If you encounter new log format - you simply create a new strategy. Why does it matter if format changes due to new manuf... | [
{
"body": "<p>Few thoughts about your code:</p>\n\n<ul>\n<li><p>your case resembles more <a href=\"http://en.wikipedia.org/wiki/Abstract_factory_pattern\" rel=\"nofollow\"><code>Abstract Factory</code></a> pattern more than <code>Strategy</code> pattern. <code>ILogFactory</code> is your <code>Abstract Factory</... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T00:39:07.270",
"Id": "39772",
"Score": "4",
"Tags": [
"c#",
"design-patterns"
],
"Title": "Abstract Factory + Strategy pattern for parsing log files in multiple formats — improvement ... | 39772 |
<p>At this point I've written a fair amount of code to deal with dynamic line items. I've slowly refactored most of the code into an Order object that's created at page load which contains the methods for various actions within the table.</p>
<p>I'm hoping to get some feedback from another set of eyes as to how to fur... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T03:12:07.563",
"Id": "66734",
"Score": "3",
"body": "Post JS code here, please."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T03:16:29.637",
"Id": "66735",
"Score": "0",
"body": "In abse... | [
{
"body": "<p>You could generate your row string using .map to eliminate selecting each input one by one by id.</p>\n\n<pre><code>// build new table row from line item inputs\nvar newRow = \"<tr>\";\nnewRow += $(\".line-items tfoot\").find(\":input\").map(function(_,obj) {\n return \"<td>\" + $(o... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T02:26:17.417",
"Id": "39774",
"Score": "4",
"Tags": [
"javascript",
"optimization",
"jquery"
],
"Title": "Refactor jQuery code to use fewer selectors"
} | 39774 |
<p><a href="http://mustache.github.io/" rel="nofollow">Mustache</a> is a simple template language for preprocessing text templates.</p>
| [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T02:50:15.863",
"Id": "39777",
"Score": "0",
"Tags": null,
"Title": null
} | 39777 |
Mustache is a "logic-less" templating library available in a range of languages. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T02:50:15.863",
"Id": "39778",
"Score": "0",
"Tags": null,
"Title": null
} | 39778 |
<p>I have written some code for one of my assignments. However, I feel that I am repeating myself slightly in a few places. I have that niggling feeling that there is a better way to do things.</p>
<p>Here is the code in full:</p>
<pre><code>#include <stdio.h>
#include <string.h>
#define ARR_SIZE 256
i... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T03:33:00.660",
"Id": "66738",
"Score": "5",
"body": "Hi Dr.Pepper. On CodeReview we rollback edits if they invalidate answers that have already been given... just a head's up."
},
{
"ContentLicense": "CC BY-SA 3.0",
"Cr... | [
{
"body": "<p>You currently have separate variables for each input. You could instead have a two-dimensional array:</p>\n\n<pre><code>char inputs[4][ARR_SIZE];\n</code></pre>\n\n<p>You have variables <code>clean1</code>, <code>clean2</code>, …, <code>nCount</code>, but only use <code>clean1</code>. Since they'r... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T03:11:31.727",
"Id": "39779",
"Score": "8",
"Tags": [
"c",
"strings",
"homework",
"validation"
],
"Title": "Inputting and displaying strings"
} | 39779 |
<p>Search an element in a n-ary tree. Looking for good code practices, optimizations etc.
If question is ambiguous, let me know and I will reply ASAP.</p>
<p>Note - <code>SearchInANAryTree</code> name of class is for personal maintenance reason, so please ignore feedback as that name does not sound good. Also, help m... | [] | [
{
"body": "<p>I am taking a very broad stab at this, answering your questions along the way but with additional comments on the code in general.</p>\n\n<pre><code> public SearchInANAryTree(T[] items, int nary) {\n if (nary <= 0) throw new NullPointerException(\"The branching factor : \" + nary ... | {
"AcceptedAnswerId": "39874",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T07:31:00.580",
"Id": "39784",
"Score": "1",
"Tags": [
"java",
"tree",
"binary-search"
],
"Title": "Search an element/item in an n-ary tree"
} | 39784 |
<p>As part of learning more C, I wrote this extremely trivial C program that takes Student scores from <code>stdin</code> and, upon termination, prints out the minimum score/maximum score and the average score. Can somebody review my code and tell me how I might be able to improve my code?</p>
<pre><code>#include <... | [] | [
{
"body": "<p>You should get into the habit of initialising variables whenever possible. It's a little more difficult here, since <code>currentMax</code>, <code>currentMin</code>, and <code>currentEntry</code> may seem not to have a sensible default value. However, all arithmetic values have an upper and a lowe... | {
"AcceptedAnswerId": "39788",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T07:35:30.307",
"Id": "39785",
"Score": "4",
"Tags": [
"c",
"stream"
],
"Title": "Processing student scores from the stdin"
} | 39785 |
<p>In my Android application, I have two types of filters: search filters and sorting filters.</p>
<p>I need to read filters from view, display filter on view, and save them into and from memory. I should include these needed features into one class to help myself add new filters in the future. I also need to divide f... | [] | [
{
"body": "<p>You have presented similar code to this before, and while some of the recommendations I had have been implemented, others have not... ;-) This is fine, presumably you have your reasons, but the one that sticks out is the <code>public void includeInIfNeed(Filters filters)</code> method, which is re... | {
"AcceptedAnswerId": "39802",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T07:47:59.217",
"Id": "39786",
"Score": "3",
"Tags": [
"java",
"android"
],
"Title": "Search filters and sorting filters"
} | 39786 |
<p>I have just started to use PHP OOP and I would like to write a class to make a multi-language website. I started from <a href="http://www.bitrepository.com/php-how-to-add-multi-language-support-to-a-website.html" rel="nofollow">this</a> but I wanted to use OOP so I came up with this:</p>
<p><strong>Language.php</st... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T14:50:19.583",
"Id": "66780",
"Score": "0",
"body": "this isn't really an answer, but Google will Translate your site into many common languages, you shouldn't waste your time reinventing this. I mean that anyone can navigate to a s... | [
{
"body": "<p>You've made a good start, but the switch statement in <code>userLanguage()</code> just doesn't feel right from an Object orientated perspective:</p>\n\n<p>A class called <code>Language</code> should represent a single language which is generic enough to fit all cases: however at the moment, whatev... | {
"AcceptedAnswerId": "39799",
"CommentCount": "9",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T07:50:43.857",
"Id": "39787",
"Score": "12",
"Tags": [
"php",
"object-oriented",
"php5",
"i18n"
],
"Title": "Multi-language website management"
} | 39787 |
<p>I have 18 <code>RadioGroup</code>. I am declaring the <code>RadioGroup</code> like this way </p>
<pre><code>private RadioGroup kn1RadioGroup, kn2RadioGroup, kn4aRadioGroup,
kn4bRadioGroup, kn4cRadioGroup, kn4dRadioGroup, kn4eRadioGroup,
kn4fRadioGroup, kn4gRadioGroup, kn4hRadioGroup, kn4iRadioGroup,kn4jRadioGroup,a... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T11:15:49.513",
"Id": "66763",
"Score": "2",
"body": "So...can you explain why this question is different [to your previous one](http://codereview.stackexchange.com/questions/39468/refactoring-radiogroup-setter-code)?"
}
] | [
{
"body": "<p>The easiest way would be to define a constant integer array holding the ids:</p>\n\n<pre><code>private static final int[] ids = { R.id.kn1_radio_group, R.id.kn2_radio_group, R.id.pr1_radio_group, /* and so on... */};\n</code></pre>\n\n<p>And then using the same method as in my answer to <a href=\"... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T09:04:19.567",
"Id": "39790",
"Score": "1",
"Tags": [
"java",
"android"
],
"Title": "How to reduce this RadioGroup Code?"
} | 39790 |
<p>We have multiple scripts which write into XLSX with the same format, into a different format or slide variation. I am trying to write an API which saves time for other programs, but I need input on restructuring the file.</p>
<pre><code>import openpyxl
from xlsxwriter.workbook import Workbook
class xlsx_extend(obj... | [] | [
{
"body": "<h2>Naming Conventions</h2>\n\n<p>According to the official Python style guide, class names should be in <code>PascalCase</code>:</p>\n\n<pre><code>No:\n class my_class():\nYes:\n class MyClass():\n</code></pre>\n\n<p>In your case, I would capitalize the entire <code>xlsx</code> because it is a... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T09:46:26.137",
"Id": "39792",
"Score": "5",
"Tags": [
"python",
"api",
"python-3.x",
"excel"
],
"Title": "XLSX writer implementation"
} | 39792 |
<p>The assignment is very open and we have only 4 things it needs to cover:</p>
<ol>
<li>File write and read</li>
<li>Use a Struct</li>
<li>Export into HTML format</li>
<li>use a common sorting algorithm</li>
</ol>
<p>so I've decided to create a little "Library" with following features:</p>
<ul>
<li>read the input f... | [] | [
{
"body": "<p>You don't need the two definitions of book:</p>\n\n<pre><code>typedef struct {..} book ;\nstruct book {..} ;\n</code></pre>\n\n<p>What I would normally do is:</p>\n\n<pre><code>typedef struct Book {\n...\n} Book ;\n</code></pre>\n\n<p>This allows you to write either:</p>\n\n<pre><code>struct Book ... | {
"AcceptedAnswerId": "39872",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T10:46:01.060",
"Id": "39795",
"Score": "6",
"Tags": [
"c",
"beginner",
"parsing",
"library"
],
"Title": "Educational \"Library\" project"
} | 39795 |
<p>I'm new to jQuery/JSON and I've build an dynamic toggle system. It work fine, but I'm not sure about my code and I want a better way of building this.</p>
<p>Could you please see my code and give comments/solutions/explanations for a better structure for this system?</p>
<p>NOTE: All JSON files are the same build<... | [] | [
{
"body": "<p>You are definitely repeating a ton of code, as far as I can tell the following is true</p>\n\n<ul>\n<li>You always set the html <code>$('ul.elements-list')</code> to show either an <code>.A</code> or <code>.B</code> list</li>\n<li>The amount of elements varies, but it seems to be never more than 3... | {
"AcceptedAnswerId": "39807",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T10:47:10.380",
"Id": "39796",
"Score": "6",
"Tags": [
"javascript",
"jquery",
"beginner",
"json"
],
"Title": "Dynamic toggle system"
} | 39796 |
<p>Currently working on writing out some test for an iOS enterprise application. My concern is in this set up of my overloaded constructor.</p>
<pre><code>- (id)init
{
CRMHttpClient *client = [CRMHttpClient sharedClient];
NSOperationQueue *queue = [NSOperationQueue new];
UIApplication *application = [UIAp... | [] | [
{
"body": "<p>Go with #3, \"Create a nice mock for <code>mockOperationQueue</code>.\" The only reason you're having to do that stubbing is that OCMock creates \"strict\" mocks by default. Strict mocks used to be the standard, but mock object frameworks have evolved. The problem with strict mocking is that they ... | {
"AcceptedAnswerId": "41778",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T14:24:01.643",
"Id": "39808",
"Score": "5",
"Tags": [
"unit-testing",
"objective-c",
"ios",
"http"
],
"Title": "Configuring Constructor Parameters and Unit Testing"
} | 39808 |
<p>I'm looking to simplify the initialisation of the second constant, preferably to just one line. Any ideas? Anything from Guava or JDK (up to 1.6) is ok to use.</p>
<pre><code>enum Box {
PROMO_HEADER,
FREEMIUM,
EXTRA_STORIES,
TOP_STORIES,
TOP_CHARACTERS,
TOP_THEMES,
TOP_ARTISTS,
TOP_I... | [] | [
{
"body": "<p>Use <a href=\"http://docs.oracle.com/javase/7/docs/api/java/util/EnumSet.html\"><code>EnumSet</code></a> for that. From docs:</p>\n\n<blockquote>\n <p>A specialized Set implementation for use with enum types. (...) The iterator returned by the iterator method traverses the elements in their natur... | {
"AcceptedAnswerId": "39821",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T14:40:31.767",
"Id": "39811",
"Score": "5",
"Tags": [
"java",
"collections",
"enum",
"guava"
],
"Title": "One-line initialisation for a constant list with all entries excep... | 39811 |
<p>I wrote this code many years ago to analyze Excel data coming in from the clipboard.</p>
<p>Please review for performance and maintainability concerns.</p>
<p>One minor note, from an OO perspective, a class level property is pretty much global level as every method has access, so these are prefixed with <code>G_</... | [] | [
{
"body": "<p>I would recommend using CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'</p>\n\n<p>I do not think there is an option to use field symbols though.</p>\n\n<p>If a field symbol contains internal table data you can use ASSIGN COMPONENT sy-index. The values are retrieved one by one as well. </p>\n\n<p>This... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T14:48:56.387",
"Id": "39813",
"Score": "23",
"Tags": [
"excel",
"abap"
],
"Title": "ABAP Excel data analyzer"
} | 39813 |
<p>ABAP (Advanced Business Application Programming, originally Allgemeiner Berichts-Aufbereitungs-Prozessor, German for "general report creation processor"[3]) is a high-level programming language created by the German software company SAP. It is currently positioned, alongside the more recently introduced Java, as the... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T14:51:11.100",
"Id": "39814",
"Score": "0",
"Tags": null,
"Title": null
} | 39814 |
ABAP is a high-level programming language created by the German software company SAP. The syntax of ABAP is somewhat similar to COBOL. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2014-01-22T14:51:11.100",
"Id": "39815",
"Score": "0",
"Tags": null,
"Title": null
} | 39815 |
<p>I'm working on the ui for an application which uses a custom ui control that is loosly related to a treeview.</p>
<p>This treeview has two levels:</p>
<ol>
<li>Top level which has a number of different geographical regions as well as a 'select all' item</li>
<li>Second level which has a number of countries in thos... | [] | [
{
"body": "<p>Your code looks very busy;</p>\n\n<p>if there is one thing you should take away from this review : do not namespace your css classes, it makes for hard to read code. </p>\n\n<p><strong>regionLabelClick</strong></p>\n\n<p>You mention the same CSS class a few times, you should extract those in to a ... | {
"AcceptedAnswerId": "40463",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T15:07:02.183",
"Id": "39816",
"Score": "7",
"Tags": [
"javascript",
"jquery"
],
"Title": "A better looking 'treeview' - dealing with lots of checkboxes"
} | 39816 |
<p>Attempting to jump into the Windows Server ServiceBus 1.1 code-base along with adopting the new TPL async methods. But I could not find an easy way to just spin up N number of handlers for message sessions (might have 100 or so concurrent sessions). So it would be great to get some feedback on the following code, an... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T15:07:22.077",
"Id": "39817",
"Score": "2",
"Tags": [
"c#",
"task-parallel-library"
],
"Title": "Easy way to handle AcceptMessageSessionAsync and ReceiveAsync - Windows Server Service... | 39817 |
<p>I am programming with Java (server side) and JavaScript a card game and I do not know how to give properties (on server side) to every card that I create. For a match I need 20 different cards from a complete set of cards (52). Now I want that these 20 cards get a value (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen,... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T16:57:55.163",
"Id": "66801",
"Score": "0",
"body": "Is this the only piece of code that you can provide? From just this one can not really review your code. You should at least include your Card class. Also if you do not have a cla... | [
{
"body": "<p>Can't help but think that a trick with integer division and clever Card enum setup would help a lot:</p>\n\n<pre><code>this.symbol = Card.values()[(id - 1) / 13];\n</code></pre>\n\n<p>Replace all your code with the above 1-liner ;-)</p>\n",
"comments": [],
"meta_data": {
"CommentCoun... | {
"AcceptedAnswerId": "39830",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T16:13:49.267",
"Id": "39823",
"Score": "4",
"Tags": [
"java",
"javascript",
"game",
"playing-cards"
],
"Title": "Turn-based game setting properties for playcards"
} | 39823 |
<p>New to Ruby here. I just made a script that print some metrics from a Windows machine about its disk. The script works fine and as I wanted it to. Now, since I'm new to the ruby and programming world, I'd like to ask you if anyone could help me to make to code look better or if there's other more efficient way I cou... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T12:52:45.840",
"Id": "66904",
"Score": "0",
"body": "Magic, but you can just delete line `return logical_disk`"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T15:00:12.910",
"Id": "66921",
"Sc... | [
{
"body": "<p>Some general pointers:</p>\n\n<p>Refrain from using <code>tmp</code> as variable names. <code>raw_output</code> will do the job better.</p>\n\n<p>Working with arrays as object replacement (<code>x[0]</code> is the caption, <code>x[1]</code> is the type...) is cumbersome, unreadable, and difficult ... | {
"AcceptedAnswerId": "40831",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T16:15:44.130",
"Id": "39824",
"Score": "4",
"Tags": [
"ruby",
"beginner",
"windows"
],
"Title": "Printing some metrics from a Windows machine"
} | 39824 |
<blockquote>
<p>Adapt the ideas of <code>printd</code> to write recursive version of <code>itoa</code>; that is, convert integer into a string by calling a recursive routine</p>
</blockquote>
<p>Here is the implementation of printd:</p>
<pre><code>void printd(int n) {
if(n < 0)
putchar('-');
if(n... | [] | [
{
"body": "<p>There are two bugs in <code>printd()</code>:</p>\n\n<ol>\n<li>The last character is an <code>l</code> instead of a semicolon.</li>\n<li>If <code>n</code> is negative, it prints a negative sign before each digit.</li>\n</ol>\n\n<p>Your <code>itoa()</code> also has a bug in handling negative input. ... | {
"AcceptedAnswerId": "39848",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T16:42:13.670",
"Id": "39825",
"Score": "8",
"Tags": [
"c",
"recursion",
"converting"
],
"Title": "Integer-to-string conversion using recursion"
} | 39825 |
<p>I've made a small class whose purpose is to generate dynamic HTML. However, it seems that my implementation turned into a state machine algorithm. And so here am I seeking help on a possible design pattern that I may apply, so my code can be more readable, objected oriented and more maintainable.</p>
<pre><code>pub... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T02:55:46.187",
"Id": "66866",
"Score": "1",
"body": "Please read [What makes a good question?](http://meta.codereview.stackexchange.com/a/76/34757) I hope this code might get better review answers, if you added some introduction to ... | [
{
"body": "<p><code>BindingModelToHtmlEh</code> - really, an <code>Eh</code> suffix for a delegate?</p>\n\n<blockquote>\n<pre><code>public delegate object BindingModelToHtmlEh(object sender, BindingModelToHtmlArgs args);\n</code></pre>\n</blockquote>\n\n<p>Wait a minute. This <em>looks</em> like an event handle... | {
"AcceptedAnswerId": "39865",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T17:27:02.147",
"Id": "39827",
"Score": "5",
"Tags": [
"c#",
"html"
],
"Title": "Generating dynamic HTML"
} | 39827 |
<p>I would really like something to replace all of these <code>REPLACE</code> Statements.</p>
<pre><code>SELECT DISTINCT
CAH.CaseNbr
, REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
(SELECT table1.Degree
FROM SDUJS.dbo.fnWorstDegreeCharge(CB.CaseID) AS table1), 'F... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T19:38:48.190",
"Id": "66822",
"Score": "0",
"body": "Are there, or can there be, other values starting with 'F' that would be broken if you selected the first leftmost character instead? It might be useful to include a few possible ... | [
{
"body": "<p>This strikes me as best being done by using a temp table, or <code>with</code> clause.</p>\n\n<p>Also, the DISTINCT part worries me.... why is that needed? Are your joins not good?</p>\n\n<p>Still, I think you may have some more contentment with:</p>\n\n<pre><code>SELECT DISTINCT\n CAH.CaseNbr,... | {
"AcceptedAnswerId": "39842",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T17:38:49.593",
"Id": "39828",
"Score": "8",
"Tags": [
"sql",
"sql-server"
],
"Title": "Can you replace a REPLACE statement, or 9?"
} | 39828 |
<p>I've seen a similar question to this but mine's a little more specific. I have the below</p>
<pre><code>File f = new File("./data.txt");
if(f.isFile())
{
try
{
FileChannel fc = new RandomAccessFile(f,"r").getChannel();
//Get information and return it
}
catch(FileNotFoundException e)
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T18:07:37.353",
"Id": "66805",
"Score": "3",
"body": "Exceptions control flow whether you like it or not. You shouldn't **throw** Exceptions to control **normal** program flow, that doesn't mean that you should avoid controlling the ... | [
{
"body": "<p>In cases like this, I like taking a default-unless-better approach... Consider this re-working of your code to do the same thing in a different order.</p>\n\n<p>The basic premise is:</p>\n\n<ol>\n<li>set up a default value (or null if it is a complicated thing to do).</li>\n<li>do the hard work wh... | {
"AcceptedAnswerId": "39835",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T17:45:59.703",
"Id": "39829",
"Score": "6",
"Tags": [
"java"
],
"Title": "Flow control with try catch to reduce redundancy"
} | 39829 |
<p>This functionality is for a Monopoly board game. In particular, when the player lands on Chance or Community Chest, a random card is drawn with a particular set of instruction, a bonus could be paid out, or perhaps the player is fined. The two cards are different in that one is a set of 16 cards and the other a set... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T18:09:47.063",
"Id": "66806",
"Score": "0",
"body": "1. `chanceCards()` , 2. `chestCards()` , 3. `createCards()`.\n\nI want to DRY 1 and 2."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T20:12:48.830... | [
{
"body": "<p>The first thing I would suggest to DRY your code, is to organize your cards in collections (arrays of objects), rather than nested objects. The reason is: arrays have order, and JavaScript has many built-in methods to work with collections, like <code>sort</code>, <code>map</code>, and many others... | {
"AcceptedAnswerId": "40077",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T18:07:59.850",
"Id": "39831",
"Score": "14",
"Tags": [
"javascript",
"game"
],
"Title": "Monopoly game cards"
} | 39831 |
<p>I am writing a function to filter a "dictionary" by the "subject" of its definitions.</p>
<p>The dictionary data structure is a hash-map of this kind:</p>
<pre><code>{ "word1" {:foo :bar
:definitions [{:definition "def1" :subject ["Subject1" "Subject2"]}
{:definition "def2" :sub... | [] | [
{
"body": "<p>Updated answer:</p>\n\n<p>Thanks for clarifying the question, the examples helped. Here is my new attempt:</p>\n\n<pre><code>(defn update-subjects [dict subj]\n (map (fn [[k {val :definitions}]]\n [k {:definitions\n (filter (fn [{s :subject}] \n ((into #{... | {
"AcceptedAnswerId": "39837",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T18:21:58.623",
"Id": "39832",
"Score": "2",
"Tags": [
"functional-programming",
"clojure"
],
"Title": "Filtering a dictionary by subject of definitions"
} | 39832 |
<p>I am just now learning Scala a bit on my own time. I wrote some code that works, but was wondering if you could eyeball it to see if its structure can be improved. It is a partial octree implementation.</p>
<pre><code>class octree(min_x:Double,
min_y:Double,
min_z:Double,
max_x... | [] | [
{
"body": "<p>Some ideas:</p>\n\n<ul>\n<li>Properly indent your code and strictly adhere to some style guide. (For example it's very uncommon to have class name starting with a lowercase letter.) I recommend you to read some style guide or study the code of some publicly available libraries. This is very import... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T18:41:09.727",
"Id": "39833",
"Score": "3",
"Tags": [
"beginner",
"tree",
"scala"
],
"Title": "Partial octree implementation"
} | 39833 |
<p>I want you to give me some tips on what I could have done better and is considered "bad practice". The code works, but I think there are better ways to do stuff, so please let me know.</p>
<pre><code>var Artikel = Backbone.Model.extend({
urlRoot: 'api/items.json',
defaults: {
titel: 'Titel niet opge... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T23:55:59.270",
"Id": "66850",
"Score": "4",
"body": "Seriously, komaan man, don't put Dutch in your code, it makes us Dutch speaking developers look bad!"
}
] | [
{
"body": "<p>I don't see major refactorings in your code. However:</p>\n\n<ul>\n<li><p>Use triple-equals (see <a href=\"https://stackoverflow.com/questions/359494/does-it-matter-which-equals-operator-vs-i-use-in-javascript-comparisons\">here</a> for more) when doing comparisons with zero or one (and probably t... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T22:14:56.033",
"Id": "39843",
"Score": "6",
"Tags": [
"javascript",
"backbone.js"
],
"Title": "Managing article information"
} | 39843 |
<p>The following class was designed to help create a more detailed error message than what's provided by the repository when a user tries to insert text into a column that is > the column max length. The users would like to be able to track down exactly which column(s) were the issue. Therefore, I created the following... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T23:36:58.863",
"Id": "66848",
"Score": "1",
"body": "Outstanding first post. Welcome!"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T00:15:47.837",
"Id": "66852",
"Score": "1",
"body": "... | [
{
"body": "<p>I think <code>QueryBuilder</code> can use constructor parameters, and that its auto-properties can be changed to be <code>{ get; private set; }</code>. Otherwise the public setters seem to make an opportunity for some trouble. Actually I'd drop the auto-properties and initialize <code>private read... | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T22:24:48.440",
"Id": "39844",
"Score": "12",
"Tags": [
"c#",
"object-oriented",
"design-patterns"
],
"Title": "Implementation of the Strategy Pattern using an interface, abstract ... | 39844 |
<p>I'm writing a list of inputs and outputs for to be compared in unit tests.</p>
<pre><code>var equals = [
//input //output
["name:(John Smith)", "name:(John~ Smith~)" ],
["name:Jon~0.1", "name:Jon~0.1" ],
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T03:19:05.630",
"Id": "66869",
"Score": "0",
"body": "I imagine one possible problem would be that it might spill over on different editors/screen sizes, and look awful."
}
] | [
{
"body": "<h1>An argument against table-style alignment in code</h1>\n\n<p><em>Except</em> when the editor/IDE helps maintain alignment with little work from the programmer, <em>and</em> all those who work with the code have that same facility, horizontal, table-like alignment in code is more trouble than it's... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-22T22:44:38.863",
"Id": "39845",
"Score": "29",
"Tags": [
"javascript",
"unit-testing",
"formatting"
],
"Title": "Code indentation for declaring inputs/outputs in an array"
} | 39845 |
<p>I don't want any feedback on the regexes as I know what needs to be updated here. Also, don't need any feedback on naming conventions.</p>
<p>I'm looking for feedback on the structure and correctness of the class.</p>
<pre><code>/************************************************************************************... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T02:12:26.843",
"Id": "66861",
"Score": "0",
"body": "I would abstract the validation process from the data, and the data from the DOM. It seems you have to create a validation object with methods and everything for every form, or is... | [
{
"body": "<p>A quick review, as the illustrious <code>user34330</code> is no longer with us.</p>\n\n<ul>\n<li><p>This:</p>\n\n<pre><code>if (val.type !== 'checkbox') {\n this.form[val.name] = val.value;\n} else if (val.type === 'checkbox') {\n this.form[val.name] = val.checked;\n}\n</code></pre>\n\n<p>sh... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T01:59:50.787",
"Id": "39853",
"Score": "2",
"Tags": [
"javascript",
"form",
"validation"
],
"Title": "A class for form data validation"
} | 39853 |
<p>Looking for feedback on correctness and code structure.</p>
<p>Follow up to:</p>
<p><a href="https://codereview.stackexchange.com/questions/19825/sstorage-remember-v0">SStorage (remember) - v0</a></p>
<p>Note that b.c. the user can only change the storage type when logging in, there is no need to copy back and fo... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T07:19:29.897",
"Id": "66880",
"Score": "0",
"body": "Can I get a comment on why the object (presumably becoming a prototype) has `this.A.foo` instead of `this.foo`?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate":... | [
{
"body": "<p>From a once over:</p>\n\n<ul>\n<li>You are a bit overdoing the blank lines in your definition of <code>A</code></li>\n<li>I like the namespace idea, given how you implement <code>getObj</code> and <code>setObj</code>, it would be nice if the caller could set the namespace.</li>\n<li><code>setType<... | {
"AcceptedAnswerId": "39857",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T02:05:54.977",
"Id": "39854",
"Score": "4",
"Tags": [
"javascript"
],
"Title": "A class for remember me"
} | 39854 |
<p>This class creates dynamic input labels. You give it a pair of elements and it sets up the event listeners and CSS toggles to accomplish this.</p>
<p>Looking for feedback on code structure and correctness.</p>
<p>Toggle classes do what they say, they toggle one class on and another class off.</p>
<pre><code>/***... | [] | [
{
"body": "<p>The code is not bad;</p>\n\n<ul>\n<li>Quite configurable</li>\n<li>Helper functions</li>\n</ul>\n\n<p>However,</p>\n\n<ul>\n<li>There is quite a bit of copy paste code</li>\n<li>Placing the style classes in <code>self.A.</code> makes for verbose code</li>\n<li>The css classes themselves are length... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T02:17:49.377",
"Id": "39855",
"Score": "2",
"Tags": [
"javascript",
"reinventing-the-wheel",
"event-handling"
],
"Title": "A class for dynamic inputs"
} | 39855 |
<p>I am fairly new to web development, and would like some feedback. It is HTML/CSS, with some JS (button hovers, anchor scrolling and image sliders) from elsewhere. Comments on best practices and any other suggestions would be great as I feel I'm probably doing a lot wrong, but specifically:</p>
<ol>
<li><p>I used di... | [] | [
{
"body": "<p><strong>CSS</strong></p>\n\n<p>Instead of having 5 different rules all saying the same thing for 5 selectors. You can group them like this.</p>\n\n<pre><code>h1.light,\nh2.light,\n.darkgrey a,\n.darkestgrey a,\n.button.light\n {\n color: #fff;\n}\n\nbody,\n.underline.light {\n background-col... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T05:28:07.903",
"Id": "39859",
"Score": "11",
"Tags": [
"html",
"beginner",
"css"
],
"Title": "One page website with JS functionality"
} | 39859 |
<p>I was doing a simple exercise to calculate the amount based on an expression.</p>
<p>For example:</p>
<p><code>(((2*2)+(3*5/5)+(2*5)))</code> outputs 17</p>
<p><code>((2*2)(3*5/5)(2*5))</code> output 120 etc</p>
<p>I have written the code, but I am not satisfied with what I've done. Could you please help me to r... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T09:14:50.890",
"Id": "66885",
"Score": "3",
"body": "Do you have any experience with writing parsers? There are less convoluted ways to do what you're doing, such as writing a bog-standard recursive descent parser."
},
{
"Co... | [
{
"body": "<p>I agree with the point in the comments. The approach you can implement that would simplify your code heavily is a recursion. The structure would be following the idea that you have interface/class Element, lets say, as you have it here but that would be just an interface. This interface would have... | {
"AcceptedAnswerId": "41278",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T08:02:06.833",
"Id": "39863",
"Score": "3",
"Tags": [
"java",
"math-expression-eval"
],
"Title": "Refactoring calculator expression"
} | 39863 |
<p>As suggested <a href="https://stackoverflow.com/questions/21278204/stdunordered-map-how-to-track-max-min-key-at-any-time">here</a>, I'm using Boost multi-index to implement orderbook. So far my code looks like this:</p>
<p><code>"CommonsNative.h"</code> contains <code>typedef int64_t myDecimal;</code> and <code>enu... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T23:07:41.120",
"Id": "67012",
"Score": "0",
"body": "javapowered ..... time to change your nick? ;-)"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-24T07:28:25.917",
"Id": "67049",
"Score": "0",... | [
{
"body": "<ul>\n<li><p><code>myDecimal</code> is an absolutely unhelpful name overall. I don't see any need to give <code>int64_t</code> a <code>typedef</code> here, but even if there is one, then it should still use a better name.</p></li>\n<li><p>Empty <code>void</code> parameters are not needed in C++:</p>... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T12:04:44.480",
"Id": "39870",
"Score": "7",
"Tags": [
"c++",
"boost",
"container"
],
"Title": "Boost multi-index based orderbook"
} | 39870 |
<p>I have a little js I call a "jqGrid Factory" to encapsulate common settings and functionality across my web app.</p>
<p>I just want to see what improvements I can make.</p>
<pre><code> var jqGridReportFactory = (function () {
var config = {
datatype: 'json',
mtype: 'GET',
h... | [] | [
{
"body": "<p>I like your code, good use of the Revealing Module pattern.</p>\n\n<p>I only have the following minor observations:</p>\n\n<ul>\n<li><code>mtype</code> could use a better name ( I know, jqGrid uses it )</li>\n<li><code>autowidth</code> -> <code>autoWidth</code> ( lowerCamelCasing )</li>\n<li><code... | {
"AcceptedAnswerId": "39880",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T12:27:57.950",
"Id": "39871",
"Score": "7",
"Tags": [
"javascript",
"jquery",
"revealing-module-pattern"
],
"Title": "First \"Revealing Module\" implementation"
} | 39871 |
<p>I'm using these 2 functions to handle file input/output and would like to know if there's anything that should be changed.</p>
<p>For content retrieval, enough space is allocated and the file content is copied. To make sure saving a file either saves all or nothing, I'm writing to a buffer then renaming it after al... | [] | [
{
"body": "<p>I think that a more idiomatic C interface would be</p>\n\n<pre><code>ssize_t file_get_content(const char *file_name, char *content[]);\n</code></pre>\n\n<p>Returning the number of bytes actually read would be analogous to <code>read(2)</code> and <code>printf(3)</code>. On error, the return value... | {
"AcceptedAnswerId": "39926",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T15:23:45.660",
"Id": "39876",
"Score": "7",
"Tags": [
"c",
"security",
"file"
],
"Title": "Are these file handling functions safe?"
} | 39876 |
<p>I needed to build a one-way web service for a mobile app I developed. Its only goal is to receive incoming JSON data and insert it into the correct tables. It works, but it looks very "kludgy" and cobbled together (happens a lot with solo development). </p>
<p>I'd like another pair of eyes to see where it could be ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T16:48:54.730",
"Id": "66930",
"Score": "0",
"body": "As an addendum, I found a decent example of how to encapsulate my db class [Database class](http://pastie.org/8660848). Trying to incorporate this now like this `try {\n $d... | [
{
"body": "<p>There are some big holes in your security </p>\n\n<ol>\n<li>Authenticate the data source. (Is it a legitimate source, username/password/etc)</li>\n<li>Sanitize the user data.</li>\n</ol>\n\n<p>Check $trackCols against a list of valid column names you are expecting, to stop me doing things like I h... | {
"AcceptedAnswerId": "40082",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T15:27:49.487",
"Id": "39877",
"Score": "7",
"Tags": [
"php"
],
"Title": "Home-grown web service"
} | 39877 |
<p>I have a <a href="http://en.wikipedia.org/wiki/BLAST" rel="nofollow">BLAST</a> output file and want to calculate query coverage, appending the query lengths as an additional column to the output. Let's say I have</p>
<pre><code>2 7 15
</code></pre>
<pre><code>f=open('file.txt', 'r')
lines=f.readlines()
import ... | [] | [
{
"body": "<p>One serious bug is that you open <code>results.txt</code> for each line of input. It's almost always better to <a href=\"https://stackoverflow.com/a/9283052/1157100\">open files in a <code>with</code> block</a>. Then, you won't have to worry about closing your filehandles, even if the code exits... | {
"AcceptedAnswerId": "39897",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T15:45:57.800",
"Id": "39879",
"Score": "6",
"Tags": [
"python",
"regex",
"linux",
"csv",
"bioinformatics"
],
"Title": "Calculate query coverage from BLAST output"
} | 39879 |
<p>The <a href="http://msdn.microsoft.com/en-us/library/dd460717.aspx" rel="nofollow">Task Parallel Library</a> (TPL) is a set of public types and APIs in the <a href="http://msdn.microsoft.com/en-us/library/system.threading.tasks.aspx" rel="nofollow">System.Threading.Tasks</a> namespace in the .NET Framework 4 and 4.5... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T16:06:21.013",
"Id": "39881",
"Score": "0",
"Tags": null,
"Title": null
} | 39881 |
The Task Parallel Library is part of .NET 4 and .NET 4.5. It is a set of APIs to enable developers to program asynchronous applications. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T16:06:21.013",
"Id": "39882",
"Score": "0",
"Tags": null,
"Title": null
} | 39882 |
<p>Several programming languages support an asynchronous programming model using co-routines, with the <code>async</code> and <code>await</code> keywords.</p>
<p>Support for the model was added to C# and VB in VS2012, and Python in 3.5. A <a href="https://github.com/tc39/ecmascript-asyncawait" rel="nofollow noreferrer"... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2014-01-23T16:07:32.567",
"Id": "39883",
"Score": "0",
"Tags": null,
"Title": null
} | 39883 |
This covers the asynchronous programming model supported by various programming languages, using the async and await keywords. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T16:07:32.567",
"Id": "39884",
"Score": "0",
"Tags": null,
"Title": null
} | 39884 |
<p>I've written a function that can be used at runtime to suggest how the provided incomplete Lua expression can be completed so that it would make sense (that is, it would evaluate to a non-nil value). For example, this can be used with an application console that can evaluate Lua expressions at runtime, so that it wo... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-04-02T09:36:30.970",
"Id": "80278",
"Score": "0",
"body": "I don't know Lua, but aren't you scared of side effects when you evaluate your base string? Like deleteMyHardDrive().f<complete here>"
},
{
"ContentLicense": "CC BY-SA 3.0... | [
{
"body": "<h2>Single Responsibility Principle</h2>\n\n<p>Your function does a lot! It has over 100 LoC and there clearly are seams where separation should take place. You should have an own function for each completion case:</p>\n\n<ul>\n<li>\"global completion\" (where no separator occurs in the string)</li>\... | {
"AcceptedAnswerId": "61550",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T16:49:50.880",
"Id": "39887",
"Score": "14",
"Tags": [
"c++",
"lua"
],
"Title": "Runtime expression autocompletion"
} | 39887 |
<p>For a website with four pages (blog, portfolio, profil and impressum) I have four different color schemes (for links, headings, code, etc.). This results in bloated CSS which I want to reduce.</p>
<p>Here is a <a href="http://jsfiddle.net/A8xHf/" rel="nofollow"><strong>demo</strong></a>. You see the navigation ite... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T17:34:42.150",
"Id": "66938",
"Score": "1",
"body": "Sass is the name of the CSS preprocessor, which has 2 syntaxes: scss and sass. There's no reason to have an scss tag."
},
{
"ContentLicense": "CC BY-SA 3.0",
"Creati... | [
{
"body": "<p>Some days passed and I feel like I should share the changes I have made so far.</p>\n\n<h2>Naming</h2>\n\n<p>I started using page names instead of color names on classes and variables. This leaves me with the benefit of being able to change the color scheme of an entire page only by changing the v... | {
"AcceptedAnswerId": "40088",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T17:25:57.070",
"Id": "39890",
"Score": "8",
"Tags": [
"html",
"css",
"sass",
"scss"
],
"Title": "Improve page-specific CSS for different color schemes"
} | 39890 |
<blockquote>
<p>Write a recursive version of the function reverse(s), which reverses the string <code>s</code> in place.</p>
</blockquote>
<p>Here is my solution:</p>
<pre><code>void reverse(char a[], int i, int j) {
char tmp;
if(i >= j) {
return;
}
reverse(a, i + 1, j - 1);
tmp = a... | [] | [
{
"body": "<p>It looks ok to me.</p>\n\n<p>As a few comments in a random order:</p>\n\n<ul>\n<li>I guess I don't have to tell you that writing a non-recursive function for this is quite straightforward.</li>\n<li>You could give <code>tmp</code> its final value as you define it : <code>char tmp = a[i];</code>.</... | {
"AcceptedAnswerId": "39892",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T17:28:08.500",
"Id": "39891",
"Score": "5",
"Tags": [
"c",
"strings",
"recursion"
],
"Title": "Recursive reverse function"
} | 39891 |
<p>Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. It’s translated to well-formatted, standard CSS using the command line tool or a web-framework plugin.</p>
<p>Sass has two syntaxes. The new main syntax (as of Sass 3) is known as “SCSS” (for “Sassy CSS”), and is a... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T17:41:49.147",
"Id": "39893",
"Score": "0",
"Tags": null,
"Title": null
} | 39893 |
The new main syntax for SASS 3, known as Sassy CSS (SCSS), is a superset of CSS3's syntax. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T17:41:49.147",
"Id": "39894",
"Score": "0",
"Tags": null,
"Title": null
} | 39894 |
<p>I'm trying to find maximum the <a href="http://en.wikipedia.org/wiki/Collatz_conjecture#Statement_of_the_problem" rel="nofollow">Collatz sequence</a> between 1 and 1000000. I wrote the following code below. I guess it is correct but it is extremely slow. Can you give me a few hints to make it faster?</p>
<pre><code... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-24T02:47:35.757",
"Id": "67031",
"Score": "1",
"body": "Just a minor point: `x = x / 2` can be shortened to `x /= 2`."
}
] | [
{
"body": "<p>Your program is non-portable, since an <a href=\"https://stackoverflow.com/a/589684/1157100\"><code>int</code> is only guaranteed to hold numbers up to 32767</a>. I would change your data type to <code>unsigned long long</code>; otherwise, <a href=\"http://oeis.org/A222292/internal\" rel=\"nofoll... | {
"AcceptedAnswerId": "39904",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T18:30:50.490",
"Id": "39898",
"Score": "5",
"Tags": [
"c++",
"performance",
"collatz-sequence"
],
"Title": "Finding maximum Collatz sequence between 1-1000000"
} | 39898 |
<p>This pattern is like the module pattern; it focuses on public & private methods. The difference is that the revealing module pattern was engineered as a way to ensure that all methods and variables are kept private until they are explicitly exposed; usually through an object literal returned by the closure in wh... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T18:41:55.770",
"Id": "39899",
"Score": "0",
"Tags": null,
"Title": null
} | 39899 |
This pattern is like the module pattern; it focuses on public & private methods. The difference is that the revealing module pattern was engineered as a way to ensure that all methods and variables are kept private until they are explicitly exposed; usually through an object literal returned by the closure in which it’... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T18:41:55.770",
"Id": "39900",
"Score": "0",
"Tags": null,
"Title": null
} | 39900 |
<p>I want to implement the cleanest amount of CSS through proper use of inheritance. All links need to be a shade of white, so lets say <code>#fff</code> </p>
<p><strong>HTML</strong></p>
<pre><code><div class="header">
<div class="headerLogo">
<a href="/">BruxZir</a>
</div>
&l... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T19:47:24.227",
"Id": "66963",
"Score": "2",
"body": "Using `div`'s there is just fine. Why not `.header a { color: #fff; }`?"
}
] | [
{
"body": "<p>KleinFreund is right.</p>\n\n<p>if you want all the links the same throughout the header</p>\n\n<pre><code>.header a {\n color: #fff;\n text-decoration: none;\n}\n</code></pre>\n\n<p>and if you want the links throughout the entire page to be the same color than you want something like this</... | {
"AcceptedAnswerId": "39911",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T19:24:26.053",
"Id": "39905",
"Score": "4",
"Tags": [
"html",
"css"
],
"Title": "Making CSS rules for links in header more DRY"
} | 39905 |
<p>I have the following grid shape:</p>
<pre><code> __ __ __
|__|__|__|
|__|__|__|
</code></pre>
<p>I have the following 3 types of shapes to fill it (they cannot rotate):</p>
<pre><code> __
|__| __
|__| |__| (6x6 one above, or full size)
</code></pre>
<p>I have also 3 "shape lists" that need to fill it in ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-24T05:30:14.087",
"Id": "67037",
"Score": "0",
"body": "By pattern, are you looking for suggestions or direction on an approach/algorithm to solve the problem? The general class of 'packing problems' is very well covered, but it sounds... | [
{
"body": "<p>There is a fair amount of common code that can be extracted into a function.</p>\n\n<p>There is a common check in the while clause and the if clause.</p>\n\n<pre><code>boolean CanAdd(LargeContentBlock largeContentBlock, ShapeList shapes)\n{\n return largeContentBlock.CanAddBlock(shapes.Peek().S... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T19:25:23.887",
"Id": "39908",
"Score": "5",
"Tags": [
"c#",
"design-patterns"
],
"Title": "Reducing nested while statements for building a grid?"
} | 39908 |
<p>This class provides animation messages to the user. Looking for general feedback.</p>
<p>I've posted the library I use as well if you have time to look that over.</p>
<pre><code>/***************************************************************************************************
SMessenger - messaging system to pr... | [] | [
{
"body": "<p>It looks really good! The only bit I don't like is the nested <code>ifs</code>, but I'm really nit-picking.</p>\n\n<pre><code> if (hide) {\n if (obj.input_element) {\n obj.input_element.removeEventListener(\"keypress\", obj.enter);\n }\n obj.co... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T20:38:52.100",
"Id": "39912",
"Score": "4",
"Tags": [
"javascript"
],
"Title": "A class for animating messages as feedback to the user"
} | 39912 |
<p>Concerned with the length of this and the organization. Looking to organize it better if possible. If anyone knows the jQuery equivalent of these methods I would like to put them in the comments.</p>
<p>I'm not interested in changing the style, i.e. - identifier names, whitespace, etc.</p>
<pre><code>/**********... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T21:10:54.893",
"Id": "66983",
"Score": "3",
"body": "\"Concerned with the length of this and the organization\", Ironically the StackExchange system automatically flagged this question as \"excessively long\" :) There's nothing wron... | [
{
"body": "<p>From a once over</p>\n\n<ul>\n<li>ASCII header, using \"use strict\" in a surrounding function, good stuff</li>\n<li><code>addTags</code>, would have been nice if the caller could set the parent to which the tags should be added ( a la jQuery )</li>\n<li><code>addTags</code>, it is unclear from na... | {
"AcceptedAnswerId": "39994",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T20:43:52.240",
"Id": "39913",
"Score": "3",
"Tags": [
"javascript",
"jquery"
],
"Title": "A package for the DOM"
} | 39913 |
<p>Addressed both issues in this <a href="https://codereview.stackexchange.com/questions/39619/a-package-for-sort-algorithms-v2">codereview post</a>.</p>
<p>Fixed the indexing issue and the call mechanism of the function expression.</p>
<p>Looking for perfect code. Hope this is the last rev.</p>
<pre><code> /***... | [] | [
{
"body": "<p>I would remove <code>Pub.swap</code> and copy its code where you need it.</p>\n\n<p>That's because function calls are expensive, so better avoid calling a function at each iteration if possible.</p>\n\n<p>And try to cache the expressions in loop's condition. For example, </p>\n\n<pre><code>var len... | {
"AcceptedAnswerId": "40020",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T22:06:57.873",
"Id": "39915",
"Score": "2",
"Tags": [
"javascript",
"algorithm",
"sorting"
],
"Title": "A package for sort algorithms - v3"
} | 39915 |
<p>After finishing Project Euler 24, I decided to make a scrabble type of application using /usr/lib/dict as my dictionary what I cat that into a word file. It does take a few seconds, and the dictionary selection isn't that great.</p>
<p>Is there any way I could make it faster, more effective, and with a better dicti... | [] | [
{
"body": "<p>If what you are trying to do is store a huge list of valid words in such a way that you can test whether a given string is a valid word, a Trie works well. See <a href=\"https://stackoverflow.com/questions/2225540/trie-implementation\">this</a> Stack Overflow question.</p>\n\n<p>Load the wordlist... | {
"AcceptedAnswerId": "39923",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-23T23:20:50.597",
"Id": "39922",
"Score": "8",
"Tags": [
"java",
"algorithm",
"performance",
"search",
"hash-map"
],
"Title": "Scrabble algorithm review and performance su... | 39922 |
<p>I've been iterating on my repository pattern implementation over the course of the past 4-5 months. In my new projects I choose to use this pattern and I try to improve upon what I learned in previous projects. I'm pretty pleased with the state of my current implementation. I feel like I could improve upon my valida... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-24T01:45:33.257",
"Id": "67025",
"Score": "0",
"body": "Welcome to CR! Awesome first post, keep 'em coming! :)"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-24T02:18:47.040",
"Id": "67027",
"Score... | [
{
"body": "<blockquote>\n <p><em>The only thing that I think if slightly leaky is updating an existing entity.</em></p>\n</blockquote>\n\n<p>It isn't the only leak you have:</p>\n\n<pre><code>public interface ISession : IDisposable\n</code></pre>\n\n<p>This is a <em>leaky abstraction</em>. You have a specific ... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-24T01:07:31.520",
"Id": "39927",
"Score": "5",
"Tags": [
"c#",
"asp.net",
"entity-framework",
"asp.net-mvc"
],
"Title": "Entity Framework, code-first repository pattern review. W... | 39927 |
<pre><code>class MyObject
{
public static enum Type {A, B, C, D;}
public static final int ID_MAIN = 1;
public static final int ID_MAIN_UK = 2;
public static final int ID_MAIN_US = 3;
public static final int ID_SUB = 4;
// lots more constants here
public static final String DESCRIPTION_1 = ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-24T06:04:51.140",
"Id": "67038",
"Score": "0",
"body": "Static methods cannot possibly switch on instance variable `id`."
}
] | [
{
"body": "<p>This is a classic case for <a href=\"http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html\" rel=\"nofollow\">using an Enum</a>....</p>\n\n<pre><code>public enum MyEnum {\n ID_MAIN(\"Desc Full Name\", Type.A),\n ID_MAIN_UK(\"Desc Full Name\", Type.B),\n ID_SUB(\"Desc1 Full Name\", ... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-24T03:31:54.207",
"Id": "39929",
"Score": "5",
"Tags": [
"java",
"constants"
],
"Title": "Refactoring Java class with lots of constants"
} | 39929 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.