body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>I have been implementing a delegate class with C++11 that supports class member functions. I am interested in knowing if there are any potential problems with this implementation. My main concern is the private <code>Key</code> struct of the <code>Delegate</code> class. Can I always rely on the key being correct in ...
[]
[ { "body": "<h2>Fatal bugs:</h2>\n\n<p>A <strong>big</strong> issue is the fact that you take a copy of the object in the function in this line:</p>\n\n<pre><code> std::function &lt; void (Class, Params...) &gt; f = func;\n</code></pre>\n\n<p>This needs to be <code>Class&amp;</code> at the very least. Otherw...
{ "AcceptedAnswerId": "36441", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-27T21:16:50.540", "Id": "36251", "Score": "3", "Tags": [ "c++", "c++11", "delegates", "pointers" ], "Title": "C++ delegate implementation with member functions" }
36251
<p>Euler problems (projecteuler.net) often invites to quick and dirty solutions. </p> <p>While hurrying through <a href="http://projecteuler.net/problem=32" rel="nofollow">Problem 32</a> I found myself in want of the std:: toolkit. Not sure what it is though.</p> <p>The problem description is included in the first co...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T12:09:44.667", "Id": "59442", "Score": "0", "body": "I think, you should add a reference to the original task in your comment. I think it's at least as important as the date and stating that you were the author." } ]
[ { "body": "<ol>\n<li><p>Your conversions are... pretty WTF :)</p>\n\n<pre><code>void insert_if_product(string const&amp; factor1, string const&amp; factor2, string const&amp; product) {\n auto p = std::stoul(product);\n if (std::stoul(factor1, nullptr, 10) * std::stoul(factor2, nullptr, 10) == p) {\n ...
{ "AcceptedAnswerId": "36258", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-27T21:38:28.440", "Id": "36252", "Score": "1", "Tags": [ "c++", "c++11", "project-euler" ], "Title": "Euler problem c++ / std::library usage" }
36252
<p>I have a Combobox and I want to edit a boolean value.</p> <pre><code> &lt;dxe:ComboBoxEdit ItemsSource="{Binding EnumItemsSource}" DisplayMember="Name" ValueMember="Id" IsTextEditable="False" EditValue="{...
[]
[ { "body": "<p>It's not clear <em>where</em> this <code>PrepareDataForBitTemplate(PropertyInfo)</code> method is located. Is it code-behind? Whatever it is, if the goal is to bind a <em>ComboBox</em> with some enum values, I would much rather keep it standard - meaning the <code>DataContext</code> of the <em>Com...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-27T23:03:34.190", "Id": "36255", "Score": "3", "Tags": [ "c#", "wpf", "xaml" ], "Title": "WPF Load boolean values in combobox" }
36255
<p>I have to do a task hard for me and maybe you can help me. I've tried to design a window dialog to update data from a database view. This database view contains integer, DateTime, string, Time, Boolean properties. </p> <p>First of all, I load the database view data into a <code>GridControl</code>. The <code>GridCon...
[]
[ { "body": "<p>I think Controls related code should be in XAML. Ideally in MVVM pattern we provide property values in our viewmodel. But how those property will be displayed is define by XAML. You have told that you are using DevExpress Controls. I have not explored DevExpress Controls, but I bet Gridview availa...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-27T23:08:41.050", "Id": "36256", "Score": "6", "Tags": [ "c#", "wpf", "mvvm", "xaml" ], "Title": "WPF Window with different DataTemplates" }
36256
<p>Below is my java code with some complexity,</p> <pre><code>String input; double a; if (null != input &amp;&amp; !input.isEmpty()) { a = Double.parseDouble(input); } else { a = defaultValue; } </code></pre> <p>With Guava, we can compress the code from 5 lines into a 'single' line,</p> <pre><code>a = Doubl...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T09:52:10.247", "Id": "59424", "Score": "0", "body": "What do you want to happen, if the input is not a valid `double`?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T02:07:58.820", "Id": "59801",...
[ { "body": "<p>This is a 'specialized' task, converting an input string to a double value. Whenever I have micro-tasks like this I try to refactor them in to a method which does things <strong>properly</strong>.</p>\n\n<p>As far as I am concerned, neither of the above two systems are valid. You should be validat...
{ "AcceptedAnswerId": "36262", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T02:20:17.207", "Id": "36261", "Score": "4", "Tags": [ "java", "complexity" ], "Title": "Using Guava to reduce code complexity (and possibiliy to improve readability) of null check ...
36261
<p>A little while ago I was fiddling with <a href="/questions/tagged/dependency-injection" class="post-tag" title="show questions tagged &#39;dependency-injection&#39;" rel="tag">dependency-injection</a> and came up with this small WPF application that I can launch with command-line arguments.</p> <p>Not only this was...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T06:37:22.727", "Id": "59394", "Score": "0", "body": "Forgive me if this is a dumb question but should the `[QuietInterfaceArg]` part of `[QuietInterfaceArg] ICommandLineArg quietInterfaceArg` instead be `[QuietInterfaceArgument]`?" ...
[ { "body": "<p><strong>Style</strong></p>\n\n<ol>\n<li>I don't like the name <code>AutoBuildCommandLineHelper</code> for a class which implements an interface like <code>IAutoBuildCommandLineArgs</code>. I would have named it <code>AutoBuildCommandLineArgs</code></li>\n<li>You have made <code>ParamSpecifier</cod...
{ "AcceptedAnswerId": "36279", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T04:23:20.213", "Id": "36264", "Score": "6", "Tags": [ "c#", "strings", "parsing" ], "Title": "First attempt at dealing with command-line args" }
36264
<p>I'm visualizing my stored data in an histogram similar to this one:</p> <p><img src="https://i.stack.imgur.com/Wu3ih.gif" alt="enter image description here"></p> <p>However, I'm sure that my code smells a lot! So I'd like to have your opinion on how to make it better. </p> <pre><code>$listings = array( ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-07-10T02:23:50.303", "Id": "99771", "Score": "0", "body": "Have you seen [`count_array_values`](http://www.php.net/manual/en/function.array-count-values.php)?" } ]
[ { "body": "<p>Your code isn't exactly terrible, but this is code-review, and <a href=\"https://codereview.meta.stackexchange.com/questions/810/guidelines-for-new-users-proposal-tag\">good code review has to be harsh</a>, so please keep in mind that I mean this in the nicest of ways.<br/>\nThat said, there are s...
{ "AcceptedAnswerId": "36274", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T05:06:42.143", "Id": "36266", "Score": "4", "Tags": [ "php", "array", "php5", "pdo", "statistics" ], "Title": "Building a histogram array in PHP" }
36266
<p>I need to merge some large csv files but I feel that the way I am doing it is not optmized. It gets a number of csvfiles and creates one</p> <pre><code>public static void MergeFiles(IEnumerable&lt;string&gt; csvFileNames, string outputPath) { var sb = new StringBuilder(); bool hasHeader = false; foreach...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T13:38:53.670", "Id": "59450", "Score": "0", "body": "In which way you think it's not optimized?" } ]
[ { "body": "<ol>\n<li><p><code>StreamReader</code> is <code>IDisposable</code> and therefor the use of it should be wrapped in a <code>using</code> block like this:</p>\n\n<pre><code>using (TextReader tr = new StreamReader(csvFileName))\n{\n ...\n}\n</code></pre></li>\n<li><p>You are reading all files into me...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T07:41:10.367", "Id": "36273", "Score": "5", "Tags": [ "c#", "csv", "file" ], "Title": "Improve my copying of a CSV file" }
36273
<p>This is roughly what my data file looks like:</p> <pre><code># Monid U B V R I u g r i J Jerr H Herr K Kerr IRAC1 I1err IRAC2 I2err IRAC3 I3err IRAC4 I4err MIPS24 M24err SpT HaEW mem comp Mon-000001 99....
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T12:24:51.317", "Id": "59444", "Score": "1", "body": "I can't reproduce your problem. When I tried it, your program reads the ids from a 31 MiB file in less than a second. So I think there must be something you're not telling us." ...
[ { "body": "<p>If you know that <code>Mon-######</code> IDS will always be in the first part of each line there is no need to <code>.findall(..)</code>, just extract the first 10 characters from the line (granted the <code>Mon-######</code> is never more than 10 characters</p>\n", "comments": [ { ...
{ "AcceptedAnswerId": "36348", "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T07:51:31.623", "Id": "36275", "Score": "4", "Tags": [ "python", "optimization", "array" ], "Title": "Why is this program for extracting IDs from a file so slow?" }
36275
<p>I'm new to jQuery, and am using it to dynamically construct chunks of a page.</p> <p>The created HTML is what I want, but I'm not sure if the way I'm generating it is sensible or idiomatic.</p> <pre><code>function setupIndex() { $(document.body).append($("&lt;img/&gt;", {src : 'logo.png'})); var div = $("&lt;d...
[]
[ { "body": "<p>I know that the following might seem crazy at first but humour me for a minute. The main improvement is so that variables are not reused (which confuses their meaning) and the subtle <code>.appendTo(\"#maintable\")</code> is at the end (which means the document is altered once).</p>\n\n<p>There i...
{ "AcceptedAnswerId": "36617", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T13:41:48.160", "Id": "36287", "Score": "2", "Tags": [ "javascript", "jquery", "beginner" ], "Title": "jQuery to construct elements" }
36287
<p>I have done the following code for testing a web-service.</p> <p>Is my style correct for using OOP in JavaScript?</p> <pre><code>&lt;script&gt; function Ajax() { var Base = { createAjaxInstance: function() { var ajax = null; try { ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T15:17:35.243", "Id": "59462", "Score": "0", "body": "https://gist.github.com/Zirak/3373067" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T15:26:15.020", "Id": "59466", "Score": "0", "body...
[ { "body": "<p>When talking about OOP, there are <a href=\"http://en.wikipedia.org/wiki/Object-oriented_programming#Fundamental_features_and_concepts\" rel=\"nofollow\">several concepts</a> which are common to OOP languages, like encapsulation, dynamic dispatch, polymorphism, and abstraction. Of all these, I can...
{ "AcceptedAnswerId": "36297", "CommentCount": "8", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T15:14:49.510", "Id": "36296", "Score": "2", "Tags": [ "javascript", "object-oriented", "prototypal-class-design", "closure" ], "Title": "Is my JavaScript OOP style correct?...
36296
<p>Got this design for getting rid of checking network availability and informing user of errors. Is it good at all? Please, help.</p> <p>Overall point is to fire server call as short as possible:</p> <pre><code>new DefaultServerCallTask&lt;LoginResponse&gt;(){ @Override protected void onSuccess(LoginRespons...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T15:57:19.233", "Id": "59473", "Score": "0", "body": "What if someone wants to get a `String` response from the server, can he create an `AsyncResult<String>`?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013...
[ { "body": "<p>There are many things that you do well here. Overall the code is fine.</p>\n<p>I have some points that you should seriously consider and some things that you should think about. In the end, this is your code and I don't know everything that you know about it's purpose, usage and further plans.</p>...
{ "AcceptedAnswerId": "36302", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T15:46:20.873", "Id": "36298", "Score": "3", "Tags": [ "java", "android", "asynchronous" ], "Title": "AsyncTask for handling server api calls" }
36298
<p>I'm trying to find all the 3, 4, 5, and 6 letter words given 6 letters. I am finding them by comparing every combination of the 6 letters to an <code>ArrayList</code> of words called <code>sortedDictionary</code>. I have worked on the code a good bit to get it to this point.</p> <p>I tested how many six letter wo...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T17:48:08.603", "Id": "59490", "Score": "1", "body": "Just to be sure: you can't use the same letter twice in a word? Unless some of the 6 letters are themselves duplicates?" }, { "ContentLicense": "CC BY-SA 3.0", "Creat...
[ { "body": "<p>if the number of words in the dictionary is small then you might be better off turning the code around and going over the words in the dictionary and checking if the words there have the 6 letters</p>\n\n<p>disregarding that you recreate the string several times it would be more efficient to keep...
{ "AcceptedAnswerId": "36303", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-28T16:38:07.880", "Id": "36300", "Score": "27", "Tags": [ "java", "array", "strings", "combinatorics" ], "Title": "Finding words of different lengths given six letters" }
36300
<p>With a first official commercial release in 1984, Progress 4GL was initially a procedural language and has since had object-oriented extensions added to the language starting with the OpenEdge 10.1 version. The language offers tight data binding to the Progress OpenEdge database and also runs on the OpenEdge AppServ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T00:02:47.790", "Id": "36316", "Score": "0", "Tags": null, "Title": null }
36316
The Progress 4GL is a multi-platform interpreted language typically used to build business applications and is now known as ABL.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T00:02:47.790", "Id": "36317", "Score": "0", "Tags": null, "Title": null }
36317
<p>From the <a href="https://github.com/baconjs/bacon.js#readme" rel="nofollow">GitHub README</a>:</p> <blockquote> <p>A small functional reactive programming lib for JavaScript.</p> <p>Turns your event spaghetti into clean and declarative feng shui bacon, by switching from imperative to functional. It's like r...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T01:51:39.887", "Id": "36322", "Score": "0", "Tags": null, "Title": null }
36322
Functional reactive programming library for JavaScript.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T01:51:39.887", "Id": "36323", "Score": "0", "Tags": null, "Title": null }
36323
<p>'<a href="http://en.wikipedia.org/wiki/Secure_Sockets_Layer" rel="nofollow">Secure Sockets Layer</a>' was originally a comp.sources Usenet post in the 1980s, using a fairly primitive security protocol. Netscape Communication Corp pioneered the current SSL protocol, in SSL 2.0, the first version deployed, followed by...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T02:26:19.887", "Id": "36325", "Score": "0", "Tags": null, "Title": null }
36325
Secure Sockets Layer (SSL) is a cryptographic protocol that provides communications security over the Internet. The more modern version of this protocol is Transport Layer Security (TLS), specified by the IETF in RFC 2246.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T02:26:19.887", "Id": "36326", "Score": "0", "Tags": null, "Title": null }
36326
<p>Given some cubes, can cubes be arranged such that an input word can be formed from the top view of the cubes?</p> <p>For example: assume an imaginary cube with only 3 surfaces where <code>cube1: {a, b, c}</code> and <code>cube2 {m, n, o}</code>, then word <code>an</code> can be formed but word <code>ap</code> canno...
[]
[ { "body": "<blockquote>\n<p>Verify complexity to be O(n!), where n is the number of alphabets in the word.</p>\n</blockquote>\n<p>Indeed.</p>\n<pre><code> private CubeFind() {}\n</code></pre>\n<p>You don't need this to get a default constructor.</p>\n<blockquote>\n<p>Premature optimization: read that they we...
{ "AcceptedAnswerId": "36350", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T03:15:24.333", "Id": "36328", "Score": "2", "Tags": [ "java", "recursion", "complexity", "matrix" ], "Title": "Given set of cubes can we get a given word?" }
36328
<p>This is a cocoa app that adds a right click menu option to change whether a file is executable. It works by executing the system command <code>chmod</code> on each of the files. But I want to know if there is a better way to change the permission of a file, such as a cocoa function that can change the permission of ...
[]
[ { "body": "<p>The relevant <code>NSFileManager</code> call, in Foundation, is <code>- setAttributes:ofItemAtPath:error:</code>, and it is the same in <a href=\"https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/in...
{ "AcceptedAnswerId": "36333", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T03:29:54.567", "Id": "36329", "Score": "4", "Tags": [ "beginner", "objective-c", "file-system", "osx" ], "Title": "Change whether file is executable" }
36329
<p>So, I have a basic 'contact us' form that i have built, and I do some jQuery checking first (that a phone number is only numbers, email address doesn't contain unneeded characters, etc), but I also wanted to do some sanitization before sending out the email.</p> <p>After reading many questions on SO (such a great s...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T10:17:16.640", "Id": "59555", "Score": "1", "body": "_\"PHP Notice: Use of undefined constant name - assumed 'name'\"_ and _\"PHP Notice: Use of undefined constant email - assumed 'email'_ and so on... edit your ini file, and set ...
[ { "body": "<p><strong>Is it secure?</strong></p>\n\n<p>Let me answer that question with a question, are you using the HTTPS protocol to send the form data from the user to the server? If not, anyone 'listening' on the connection could potentially read the mail-data that the user is sending to the server.</p>\n\...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T02:26:40.550", "Id": "36330", "Score": "2", "Tags": [ "php", "security" ], "Title": "Critique sanitized user email PHP Script" }
36330
<p>I've created a method which is useful for executing multiple queries, and it works perfectly. Is this a good way to handle this? </p> <pre><code>public function foo($rQuery) { try { $this-&gt;done-&gt;beginTransaction(); foreach($rQuery as $val) { $rSql = $this-&gt;done-&gt;prepare(...
[]
[ { "body": "<p>I think this is going to be a first, but <em>yes</em>. If I had to work on a project, and come across this code, I'd be happy. The only thing I'd change, perhaps, is the name of the PDO instance: <code>$this-&gt;done</code> doesn't say <em>I am a DB connection</em>, IMO. The catching of the except...
{ "AcceptedAnswerId": "36337", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T05:40:18.197", "Id": "36332", "Score": "2", "Tags": [ "php", "object-oriented", "mysql" ], "Title": "Class method with begin transaction and return errors" }
36332
<p>This is a console application which takes as an argument either a .cs file or a directory. If it's a .cs file, it scans it; if it's a directory, it scans all .cs files within the directory.</p> <p>A simplified view of a method which chooses whether it's a file or a directory and reports errors is this one:</p> <pr...
[]
[ { "body": "<p>In my opinion, the easiest way would be to <em>embrace</em> exceptions. <code>DirectoryNotFoundException</code> and <code>FileNotFoundException</code> are there for a reason, and actually even calling <code>.Exists</code> might not save you from them - the file might be moved/removed between the <...
{ "AcceptedAnswerId": "36340", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T07:38:19.723", "Id": "36335", "Score": "6", "Tags": [ "c#" ], "Title": "Scanning a .cs file or a directory" }
36335
<p>I am working on coding up a set of models that are based on empirical models. These models tend to be quite complicated. In some cases, the logic used by the equations makes it impossible to compute the results using numpy fast arrays. As a result, I have decided to use list comprehension to do the math. However, th...
[]
[ { "body": "<blockquote>\n <p>These models tend to be quite complicated.</p>\n</blockquote>\n\n<p>Maybe that's standard in your field, but they definitely <em>are</em> complicated, and converting those equations into code will never be pretty (I'm looking at you, <code>calc_ln_resp_ref</code>!).</p>\n\n<blockqu...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T07:52:35.773", "Id": "36336", "Score": "5", "Tags": [ "python", "numpy", "python-3.x" ], "Title": "Organization of complex empirical equations" }
36336
<p>I would like to ask those of you, who are a little bit more expirienced in development. I would like to ask about <code>toString()</code> method usage. In what situations do you use it?</p> <p>I've found some info about it, for example <a href="http://coffeewithcode.com/2011/11/tostring-method-of-object-class-in-ja...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T10:17:44.580", "Id": "59556", "Score": "0", "body": "Post actual code, please. What is the content of 'compInfo'? I'm guessing it's some kind of naming scheme for services. JNDI resource name, etc?" } ]
[ { "body": "<p>You usually place it in your model, so when you invoke <code>.toString()</code> on an object you get a string representation of the object.</p>\n\n<p>How your string representation looks like can be up to you. Here is an example where I return a simple JSON-formatted string representation of my ob...
{ "AcceptedAnswerId": "36345", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T08:11:03.913", "Id": "36338", "Score": "11", "Tags": [ "java", "mvc" ], "Title": "toString() in a model or view layer?" }
36338
<p>I am hoping this is the right place. I was hoping to find someone to try and help me not only learn but have a look at what I have already done on Android.</p> <p><strong>DISCLAIMER: I am a long time (10+ years) script developer (PHP, Perl, Ruby) and am happy with OO but have not really had any experience with Java...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T12:53:00.810", "Id": "59564", "Score": "0", "body": "Code Review is the right place for reviewing code, we are not here to [solve problems](http://www.stackoverflow.com). Most of your question is about reviewing code though so it se...
[ { "body": "<p>Overall your code is good. If I only would say that though, you probably wouldn't learn much, and luckily for you I do have some points that you can improve:</p>\n\n<ul>\n<li><p>Within the (currently unused) <code>doInBackground</code> method in <code>ScoringTask</code>, you are creating a <code>P...
{ "AcceptedAnswerId": "36351", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T12:02:01.160", "Id": "36346", "Score": "4", "Tags": [ "java", "game", "android" ], "Title": "Android GameWatch game for learning/review" }
36346
<p>I'm developing a Java EE project which uses Redis through the Jedis library. I'm retrieving the chat history of a particular channel from the servlet context and if absent, from Redis. </p> <p>The PMD plugin of Netbeans shows me a message that the Cyclomatic Complexity of the code is 15 which is very large. I wish...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T15:01:28.997", "Id": "59578", "Score": "0", "body": "what's up with your indentation?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T15:04:05.450", "Id": "59579", "Score": "0", "body": "Y...
[ { "body": "<p>The easiest, and <em>what I also believe is the best as well,</em> way to reduce cyclomatic complexity is to <strong>extract methods</strong>. Your method suffers from one particular <a href=\"http://en.wikipedia.org/wiki/Code_smell\">code smell</a></p>\n\n<blockquote>\n <p>Long method: a method,...
{ "AcceptedAnswerId": "36493", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T12:41:23.180", "Id": "36349", "Score": "5", "Tags": [ "java", "redis" ], "Title": "Chat logger using Redis" }
36349
<p>I have designed a proxy server which has the feature to manage miniature separate networks. Each network has space to have up to 500 nodes or 500 IPs. The code for getting a new virtual IP is based on a bit flag based approach. I have used an array of DWORD (Blocks) so as to skip entire 32 IP chunks, if the block is...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T16:40:48.773", "Id": "59592", "Score": "0", "body": "Can you add some detail about why you have 500 and not 512 addresses in each block?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T16:45:25.440", ...
[ { "body": "<p>I have performed some benchmarks to get the optimum combination of block and slice sizes using 32-bit and 64-bit compiler. 64-bit because we are also developing an optimized 64-bit implementation on the sidelines. Here are the results for generating 320000 IPs on our server with all the server app...
{ "AcceptedAnswerId": "36404", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T15:32:08.383", "Id": "36360", "Score": "3", "Tags": [ "optimization", "delphi", "networking" ], "Title": "Optimizing an IP generation method" }
36360
<p>This program is supposed to be a player VS player Tic-Tac-Toe game. The computer then checks whether you've won, lost, or tied. The code does work, but I don't want it to work through hacking; I want it to be done the right way.</p> <pre><code>Sub Main() 'Initialise variables Dim StrCoordinate(3, 3) As String Dim...
[]
[ { "body": "<p>You have a big bad block of monolithic code here, stuffed in a does-it-all <code>Main()</code> procedure that is <em>begging</em> to be broken down into smaller, more focused procedures and functions.</p>\n\n<p>You need to first <strong>identify concerns</strong>:</p>\n\n<ul>\n<li><strong>Writing<...
{ "AcceptedAnswerId": "36477", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T15:49:40.390", "Id": "36361", "Score": "6", "Tags": [ "vb.net", "tic-tac-toe" ], "Title": "Player VS player Tic-Tac-Toe game" }
36361
<p>I am currently working on a course project and have been assigned to write a GUI. I've written it and it's about 2000 lines of code. It will be bigger when I add the SQL codes and new panels. So, I've successfully divided it into different classes for each screen. My question is: how do I improve that solution? He...
[]
[ { "body": "<p>Typically with Swing (and other GUI) applications the way to do it is to make your smaller class extend the component you are working on. For example, your <code>PassScreen</code> class should rather be something like:</p>\n\n<pre><code>class PassPanel extends JPanel {\n public PassPanel(....) ...
{ "AcceptedAnswerId": "36367", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T17:10:02.823", "Id": "36363", "Score": "5", "Tags": [ "java", "swing", "gui", "user-interface", "awt" ], "Title": "Splitting the GUI into smaller classes" }
36363
<p>Up until now, I've been using a 14-pixel reset in my theme's main CSS file, but after looking online, I see that a lot of web developers prefer a 10-pixel reset;</p> <p><strong>Here is what I'm currently using:</strong></p> <pre><code>/* reset.css */ * { font-size: 1em; } /* dark-theme.css */ body { font-size: 0....
[]
[ { "body": "<p>The answer is <em>neither</em>. The idea that 1em = 16px is only true in two scenarios:</p>\n\n<ul>\n<li>The browser's default font-size is 16px and the user has not adjusted it</li>\n<li>The user has specified that they want a default font-size of 16px because the browser's default was something...
{ "AcceptedAnswerId": "36370", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T17:17:58.630", "Id": "36364", "Score": "3", "Tags": [ "css" ], "Title": "Which is the more preferable font size reset?" }
36364
<p>I've started learning Python recently and I wanted to test myself. So, can you tell me how many I would get out of 10 and how I could improve my future coding?</p> <pre><code>import random import time print('Welcome to Rock, Paper, Scissors') print(' '*25) wins = 0 loses = 0 draws = 0 point= int(input('How many ro...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T15:51:25.437", "Id": "59742", "Score": "5", "body": "The purpose of code review is to improve the quality of the code, not to evaluate the coder, so I would hope that no-one actually starts giving marks out of ten." } ]
[ { "body": "<ul>\n<li><p>There is no overall structure to this program, just an undifferentiated mass of code.</p></li>\n<li><p>There is a lot of redundancy to the 'if... elif... elif...' structure which could be pulled out into a function; better yet, find a way to structure the decision-making regularities as ...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T18:11:12.013", "Id": "36368", "Score": "4", "Tags": [ "python", "beginner", "game", "python-3.x", "rock-paper-scissors" ], "Title": "Rock paper scissors" }
36368
<p>I want to read multidimensional double array from file into a single pointer variable. The number of rows and columns are not known and need to be determined when reading the file in order to allocate memory for the array. I wrote the following code and it works fine with me. I want to know if someone has more effic...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T19:35:24.327", "Id": "59616", "Score": "2", "body": "1. Harmonize your coding style! This especially includes the positions of braces and the number of spaces contained in one indention level (2 or 4?). 2. [Do **not** cast the resul...
[ { "body": "<p>You have written everything in one function (<code>main</code> probably) but it is better\nsplit into its components. Essentially what you want to do is:</p>\n\n<pre><code>open input file\nget column count\nget line count\nrewind file\nallocate memory for the array\nread array data\n</code></pre>...
{ "AcceptedAnswerId": "36384", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T19:06:03.753", "Id": "36372", "Score": "2", "Tags": [ "c", "array" ], "Title": "Read multidimensional array from file in C" }
36372
<p>I want to check the existence of various API endpoints by doing serial URL request. If the first one fails, I want to try the second one, if the second fails I want to try the third one, etc.</p> <p>Here is some code I use to do this:</p> <pre><code>self.apiEndpoint = kApiAjaxEndpoint; [self testEndpointWithBlock:...
[]
[ { "body": "<ol>\n<li>Create several instances of <code>NSOperation</code></li>\n<li>Set dependencies so that one runs after another.</li>\n<li>Add to a private <code>NSOperationQueue</code>. </li>\n<li>Cancel all operations in a queue if a match is found.</li>\n</ol>\n", "comments": [ { "Conte...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T19:34:29.770", "Id": "36373", "Score": "5", "Tags": [ "objective-c", "api", "ios", "url" ], "Title": "Multiple serial URL requests in Objective-C / iOS" }
36373
<p>I'm trying to get my head around C-string processing. I've decided to try my hand at making a dirt-simple magnet link generator. The format that a magnet link needs is</p> <pre><code>magnet:?xt=&lt;hash&gt;&amp;tr=tracker1url&amp;tr=tracker2url&amp;....&amp;tr=trackerNurl </code></pre> <p>This program takes a has...
[]
[ { "body": "<p>Your code is nicely written and you have checked for errors well. It\nis perhaps a little over-commented, many of the comments explaining\nthe obvious (and hence being just 'noise').</p>\n\n<p>String handling in C is messy and there are always many ways of\nachieving the same thing. There's noth...
{ "AcceptedAnswerId": "36417", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-29T22:42:25.280", "Id": "36380", "Score": "2", "Tags": [ "c", "strings", "beginner" ], "Title": "C String Processing -- magnet link example" }
36380
The tool called "make" is a build manager which compares the last modification times of various files and performs user specified actions (commands) when the "target" files are found to be older than their dependencies.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T00:34:34.140", "Id": "36386", "Score": "0", "Tags": null, "Title": null }
36386
<p>I was wondering if there's any way I can improve this code's execution. I want to use it on a 9*9 grid, but it takes too long to solve this as 4*4. This program takes as input a 4*4 matrix represented as a 1D matrix and returns the solution to the puzzle in the variable solution. Any comments?</p> <pre><code>sub...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T00:49:51.037", "Id": "59623", "Score": "1", "body": "Just so you know, sudoku is a 9x9 grid ... ;-) just saying." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T00:56:57.753", "Id": "59624", "...
[ { "body": "<p><sup>Well, copying my answer from SO.</sup></p>\n\n<p>Think about the number of outputs of subset/4, if every cell of Solution is unbound in the beginning. There are 4<sup>4*4</sup> = 4,294,967,296 outputs. Now you might know why your code is so slow.</p>\n\n<p>You should call valid/1 inside of su...
{ "AcceptedAnswerId": null, "CommentCount": "11", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T00:38:31.707", "Id": "36387", "Score": "4", "Tags": [ "performance", "sudoku", "matrix", "prolog" ], "Title": "Prolog Sudoku solver taking too long" }
36387
<p>I'm working on my framework constructor. First I tried to look into jQuery and understand it, but it's so out of my league. Instead I googled and put this code together. Though there aren't many posts about creating a framework. Anyway, since I'm not a guru I might be doing it the wrong way or missing things. Can I ...
[]
[ { "body": "<p>First of all, nice effort for the code. But I highly go against it because there's <a href=\"http://jquery.com/\" rel=\"nofollow\">jQuery</a>. And if you don't like jQuery because it's heavy, then I suggest going for <a href=\"http://sizzlejs.com/\" rel=\"nofollow\">Sizzle</a>.</p>\n\n<p>But anywa...
{ "AcceptedAnswerId": "36390", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T00:58:01.670", "Id": "36388", "Score": "3", "Tags": [ "javascript", "constructor", "framework" ], "Title": "Framework constructor" }
36388
<p>I need to prepend N spaces to a string to make it 10 characters in length. I came up with the following method, but since it is going to be called often, I want to ensure it is optimized. Could this be made more efficient?</p> <pre><code>public static string PrependSpaces(string str) { StringBuilder sb = new St...
[]
[ { "body": "<p>If you need to prepend a number of characters to a string you might consider <a href=\"http://msdn.microsoft.com/en-us/library/system.string.padleft(v=vs.110).aspx\" rel=\"nofollow noreferrer\">String.PadLeft()</a>.</p>\n\n<p>For example:</p>\n\n<pre><code>string str = \"abc123\";\nConsole.WriteLi...
{ "AcceptedAnswerId": "36393", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T02:38:08.293", "Id": "36391", "Score": "13", "Tags": [ "c#", "strings" ], "Title": "Adding N characters to a string" }
36391
<p>The following is a program that lets a Human play "Rock Paper Scissors Lizard Spock" against the computer... (almost playable at: <a href="http://ideone.com/EBDlga" rel="nofollow noreferrer">http://ideone.com/EBDlga</a>)</p> <p><strong>Note</strong> I have <a href="https://codereview.stackexchange.com/questions/364...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T04:39:22.393", "Id": "59648", "Score": "1", "body": "Ha! Mine says \"Spock vaporizes Rock. You lose!\" +1 anyway :)" } ]
[ { "body": "<p>I suggest that you get rid of most of the static methods, and then refactor this code using MVC design to allow the code to be the model of any type of view you desire, be it Swing, console, SWT, Android, or what have you.</p>\n", "comments": [], "meta_data": { "CommentCount": "0", ...
{ "AcceptedAnswerId": "36423", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T04:20:06.170", "Id": "36394", "Score": "11", "Tags": [ "java", "game", "community-challenge", "rock-paper-scissors" ], "Title": "Rock Paper Scissors Lizard Spock as a code-...
36394
<blockquote> <p>"Scissors cuts paper, paper covers rock, rock crushes lizard, lizard poisons Spock, Spock smashes scissors, scissors decapitate lizard, lizard eats paper, paper disproves Spock, Spock vaporizes rock. And as it always has, rock crushes scissors." </p> ...
[]
[ { "body": "<p>We could perhaps do away with the bulk of the children class code by implementing a bit of logic in the base class.</p>\n\n<p>A starting point for discussion would be something along the lines of:</p>\n\n<pre><code>public abstract class SelectionBase : IComparable&lt;SelectionBase&gt;\n{\n priv...
{ "AcceptedAnswerId": "36402", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T04:38:09.980", "Id": "36395", "Score": "42", "Tags": [ "c#", "game", "dependency-injection", "community-challenge", "rock-paper-scissors" ], "Title": "Rock-Paper-Scisso...
36395
<pre><code>import javax.swing.JOptionPane; public class DividedBy10v2{ public static void main( String[] args ){ int block[][] = new int[3][3]; int DetermineRow = 0; // The variable assigned for counting rows int DetermineColumn = 0; // The variable assigned for counting columns ...
[]
[ { "body": "<p>I think, when I run your program, that the combination of text-console and swing user input leads to a bad experience.</p>\n\n<p>Really, given that you have the GUI input boxes, why do I have to type the row/column that you want entered? Why not present me with a grid of buttons, and I have the nu...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T14:54:46.513", "Id": "36409", "Score": "5", "Tags": [ "java", "game" ], "Title": "Game divide by 10" }
36409
<p>I've done this piece of code for creating all possible samples without repetitions, but I think that it is a so heavy algorithm because every time I call this recursive function I create a new vector that is passed to it. What means create any samples without repetitions? it means creating every combination given a ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T16:51:29.593", "Id": "59664", "Score": "2", "body": "Related to, but not complete duplicate of [*Better way to create samples*](http://programmers.stackexchange.com/q/219918/60357) on *programmers*. Many points outlined in my answer...
[ { "body": "<p>Your solution requires that you create a new Vector for every combination. You are right that there is no better algorithm. The way you have it implemented though, is not as efficient as it should be.</p>\n\n<p>Float should be a primitive.... <code>float</code>. Using a Float object instead of the...
{ "AcceptedAnswerId": "36427", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T15:22:22.680", "Id": "36410", "Score": "3", "Tags": [ "java", "recursion", "combinatorics" ], "Title": "Better way to create samples" }
36410
<p>Last night I made this image uploading class. It was the first time I made a file uploader to be used on a real site, so I thought I would share it here and <a href="https://github.com/simon-eQ/BulletProof/blob/master/BulletProof.php" rel="nofollow noreferrer">on Github</a> to get some reviews, hoping if I can perfe...
[]
[ { "body": "<ul>\n<li><p>Using static methods is not appropriate if your only good reason for doing so is performance. I can confidently say that outside of a benchmark, neither you nor anyone else will ever notice the difference in performance.</p></li>\n<li><p>HTTP_ACCEPT tells you what the <em>client</em> ac...
{ "AcceptedAnswerId": "36457", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T15:56:12.643", "Id": "36411", "Score": "1", "Tags": [ "beginner", "php", "security", "static", "network-file-transfer" ], "Title": "Secure image upload class" }
36411
<h3>The Challenge</h3> <p><a href="http://chat.stackexchange.com/transcript/message/12408541#12408541">Create an implementation</a> of "Rock - Paper - Scissors - Lizard - Spock".</p> <p>The rules:</p> <blockquote> <p>Scissors cuts paper, paper covers rock, rock crushes lizard, lizard poisons Spock, Spock smashes s...
[]
[ { "body": "<p><code>ItemPlayer</code> is a really good idea. Keeping the logic and score centralized in an abstract class for the AI and Human player is a good design, but, you have not taken the idea far enough.</p>\n\n<p>The abstract class should have a <code>name</code> field, and a constructor that takes th...
{ "AcceptedAnswerId": "36414", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T15:59:20.840", "Id": "36412", "Score": "12", "Tags": [ "java", "game", "community-challenge", "rock-paper-scissors" ], "Title": "Another Rock Paper Scissors Lizard Spock im...
36412
<p>I have an algorithm that evaluates in input <code>byte[]</code> with a source <code>byte[]</code>. Several conditions can be encountered:</p> <ul> <li>Match found</li> <li>No match found</li> <li>End of input array</li> <li>End of source array </li> <li>Input wildcard (*) matches against any source byte</li> </ul>...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T20:46:47.667", "Id": "59698", "Score": "0", "body": "Could you explain what exactly should the method return? Especially in the “end of array” cases." } ]
[ { "body": "<ol>\n<li><p>If I understand this correctly, your code doesn't work. This is because when some characters match and then you find a character that doesn't match, you can't continue checking with the current character, you need to go back to the second character of the current partial match.</p>\n<p>A...
{ "AcceptedAnswerId": "36431", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T17:33:31.770", "Id": "36418", "Score": "8", "Tags": [ "c#", "algorithm", ".net", "array" ], "Title": "Simplification of byte array comparison algorithm" }
36418
<p>I have the following MySQL <code>SELECT</code> statement. It is working fine except that the code is too long. I have been looking throughout the Internet to figure out how I can make it shorter.</p> <pre><code> SELECT regd, Subject, Section, date, SUM(CASE WHEN (Name_of_exam = 'First Unit Exam' OR Name_of_exam...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T17:19:54.307", "Id": "59757", "Score": "3", "body": "this Query appears to be untested and not working correctly, if it is working correctly please show results, table schema, etc so that we can set up a [SQLFiddle](http://www.sqlf...
[ { "body": "<p>This kind of expression</p>\n\n<pre><code> (Name_of_exam = 'First Term Weekly Test'\n OR Name_of_exam = 'Second Term Weekly Test'\n OR Name_of_exam = 'Third Term Weekly Test'\n OR Name_of_exam = 'Final Term Weekly Test') \n</code></pre>\n\n<p>can usually be shortened to an IN clause.</p>\n\n<pre><...
{ "AcceptedAnswerId": "36424", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T17:42:15.957", "Id": "36421", "Score": "5", "Tags": [ "mysql", "sql" ], "Title": "Exam score query for many types of exams" }
36421
<p><strong>This post is following-up on <a href="https://codereview.stackexchange.com/questions/36395/rock-paper-scissors-lizard-spock-challenge">Rock-Paper-Scissors-Lizard-Spock Challenge</a></strong></p> <p>I had a gut feeling that I was somehow abusing <code>IComparable&lt;T&gt;</code>, @svick's answer confirmed th...
[]
[ { "body": "<ol>\n<li><blockquote>\n <p>I chose an Evaluate factory method with a private constructor</p>\n</blockquote>\n\n<p>I think that <code>GameResult.Evaluate()</code> doesn't logically make much sense, this logic belongs to a method in <code>Game</code>, which means the constructor of <code>GameResult</...
{ "AcceptedAnswerId": "36433", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T19:44:31.807", "Id": "36426", "Score": "11", "Tags": [ "c#", "game", "dependency-injection", "community-challenge", "rock-paper-scissors" ], "Title": "Rock-Paper-Scisso...
36426
<p><a href="http://meta.codereview.stackexchange.com/a/1066/23788">How to deal with Follow-up questions</a></p> <p>A follow-up question should <strong>clearly state</strong> that it is a <strong>follow-up question to a previously-asked question.</strong></p> <p>A <strong>good</strong> follow-up question should includ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T19:53:50.453", "Id": "36428", "Score": "0", "Tags": null, "Title": null }
36428
Use this tag when posting a question that is a follow-up of a previous post. State which question you're following-up on, what has changed, and why a new review is needed.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T19:53:50.453", "Id": "36429", "Score": "0", "Tags": null, "Title": null }
36429
<p>This script works for what I need it to do, but I'm not all that proficient with Python yet, so I was wondering if any of the more seasoned python veterans would go about it differently.</p> <pre><code>import os import string import re '''This script will take in an input list of strictly stellar IDs, and compare ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T16:05:35.743", "Id": "59747", "Score": "0", "body": "As written I don't believe `pullLines` does what you expect. Because there is no call to the line's member `item.split`, and even if there was its return would be ignored, it appe...
[ { "body": "<p>This is the sort of thing that Python is really good at. Your code seems like it functions, but it will be very inefficient for large data sets. For each input value you have to check every line in the the master list -- and the way you have it set up here you're going to read the master list off...
{ "AcceptedAnswerId": "36439", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T20:41:33.033", "Id": "36432", "Score": "2", "Tags": [ "python" ], "Title": "Comparing a list of known animals to a master list of animals" }
36432
<p>I'd like a review on anything including optimizations, corrections, suggestions for robustness, adherence to good coding practices, etc.</p> <p>I also request verification of the complexity: O(n<sup>n</sup>), where <em>n</em> is the row length or column length.</p> <pre><code>public final class Sudoku { priva...
[]
[ { "body": "<p><strong>Private constructor</strong></p>\n\n<p>It is considered good style throw an error in a constructor if they are not supposed to be called, even not from within the class where a private instructor could be invoked from:</p>\n\n<pre><code>private Sudoko() {\n throw new AssertionError();\n}\...
{ "AcceptedAnswerId": "37120", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T21:31:41.543", "Id": "36434", "Score": "2", "Tags": [ "java", "sudoku", "matrix" ], "Title": "Java: Sudoku solver" }
36434
<p>Here's my take at the <em>Rock-Paper-Scissors-Lizard-Spock</em> challenge. The outcomes are as follows:</p> <blockquote> <ul> <li>Scissors cuts paper</li> <li>paper covers rock</li> <li>rock crushes lizard</li> <li>lizard poisons Spock</li> <li>Spock smashes scissors</li> <li>scissors decapitate liza...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T16:33:53.663", "Id": "59751", "Score": "0", "body": "If you reordered your enum to { Rock, Spock, Paper, Lizard, Scissors } you could use modular arithmetic to determine the winner." }, { "ContentLicense": "CC BY-SA 3.0", ...
[ { "body": "<p>A few minor things:</p>\n\n<ol>\n<li><p>If you add a new weapon you have to remember to adjust the input loop</p>\n\n<pre><code>while (weapon &lt; ROCK || weapon &gt; SPOCK)\n</code></pre>\n\n<p>A solution to this problem is to have a <code>LAST</code> enum as well and new weapons should be insert...
{ "AcceptedAnswerId": "36444", "CommentCount": "8", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T21:39:58.303", "Id": "36435", "Score": "18", "Tags": [ "c++", "game", "c++11", "community-challenge", "rock-paper-scissors" ], "Title": "Rock-Paper-Scissors-Lizard-Spoc...
36435
<p>Can anyone review my program and state where I could improve it, even in terms of comments, validation, etc?</p> <pre><code>package assessed_practical_2; //Importing Resources (Random) import java.util.Random; //Importing Resources (Scanner) import java.util.Scanner; public class Assignment2 { /** * Sc...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T22:30:30.310", "Id": "59701", "Score": "1", "body": "Have you handed in this homework yet?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T22:36:23.740", "Id": "59704", "Score": "0", "body...
[ { "body": "<p>First thoughts:</p>\n\n<p>You have this whole thing as all static. That's fine for a small simple program like this, but it might be better practice for you to make most of the methods into instance methods, and then in <code>main()</code>, instantiate it and call a driver method on that class. St...
{ "AcceptedAnswerId": "36437", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T22:07:56.580", "Id": "36436", "Score": "6", "Tags": [ "java" ], "Title": "Review of \"Menu program\"" }
36436
<p>Continuing the spirit of the recent Weekend Challenge, here is a revised version of the RPSLS game.</p> <p>This is a follow up to my previous submission:</p> <p><a href="https://codereview.stackexchange.com/questions/36394/rock-paper-scissors-lizard-spock-as-a-code-style-and-challenge">Rock Paper Scissors Lizard S...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T10:33:38.630", "Id": "59843", "Score": "0", "body": "Who is supposed to listening the `Player`s?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T11:39:39.080", "Id": "59848", "Score": "0", ...
[ { "body": "<ul>\n<li><p>Love the way you're using <code>HashMap</code> to provide the strings for the items. But in the UI, how would it look if you pick Spock and computer picks Lizard? Does it swap the positions for you? Or should it say \"Spock <em>gets poisoned by</em> Lizard\"? (I'm not sure of what's the ...
{ "AcceptedAnswerId": "36455", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-11-30T23:59:58.257", "Id": "36438", "Score": "14", "Tags": [ "java", "game", "community-challenge", "rock-paper-scissors" ], "Title": "Rock Paper Scissors Lizard Spock Revisited"...
36438
<p>Time is very important from times immemorial. Doing great things and making it happen in less time is more important as it can mean less effort. So I really like to know which way is faster and more efficient in the following codes, and I would happy to know any other way we can achieve the same code: </p> <pre><co...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T12:00:20.047", "Id": "59727", "Score": "5", "body": "write a script, use `$start = microtime(true)` and then `microtime(true) - $start` to get a rough idea of the time each approach takes, and you have your answer. Do try with a lar...
[ { "body": "<p>Like I said in my comment: If you want to know which is faster, write a benchmarking script, it's <em>that</em> easy:</p>\n\n<pre><code>$start = microtime(true);\n//if-hell approach\n$ifs = microtime(true) - $start;\n$start = microtime(true);\n//switch\n$switch = microtime(true) - $start;\n$start ...
{ "AcceptedAnswerId": "36450", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T11:57:23.090", "Id": "36447", "Score": "1", "Tags": [ "performance", "php", "datetime", "comparative-review" ], "Title": "Translating month number into month name" }
36447
<p>I know that there are several ways to handle exceptions and probably a good way is to keep the handling consistently and use the pattern which feels comfortable for himself, but I would like to get some advice or hints, what would you do in following situation or how I could improve such a case.</p> <p>I created a ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T19:50:29.553", "Id": "59775", "Score": "1", "body": "You may want to wrap `is.close()` in a `try-catch` to separate important I/O errors while reading vs. those you can ignore when closing the stream." } ]
[ { "body": "<p>For Java 7 source code type You could use multicatch.\n<a href=\"http://www.baptiste-wicht.com/2010/05/better-exception-handling-in-java-7-multicatch-and-final-rethrow/\" rel=\"nofollow\">http://www.baptiste-wicht.com/2010/05/better-exception-handling-in-java-7-multicatch-and-final-rethrow/</a></p...
{ "AcceptedAnswerId": "36465", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T12:03:11.717", "Id": "36448", "Score": "7", "Tags": [ "java", "exception-handling", "error-handling" ], "Title": "Exceptions handling, what would you do?" }
36448
<p>I have created a class that has many methods for sorting an ArrayList of objects. Each method is somewhat similar in that they employ some kind of sort on an ArrayList and then return the arrayList. They are different in that some have different methods of comparison and they also call different get methods for the ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T13:35:51.383", "Id": "59732", "Score": "1", "body": "I strongly doubt that some of your methods work the way you intended. `certainItem` for example. Do you get the return that you expected from that method?" }, { "ContentLi...
[ { "body": "<p>It is better to <strong>declare</strong> your variables as <code>List&lt;Something&gt;</code>, and <strong>instantiate</strong> with <code>new ArrayList&lt;Something&gt;()</code> to allow other implementations of <code>List</code>. Like this:</p>\n\n<pre><code>List&lt;Something&gt; someList = new ...
{ "AcceptedAnswerId": "36454", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T13:23:10.627", "Id": "36452", "Score": "5", "Tags": [ "java", "sorting" ], "Title": "Trying to cut down redundancy in my code" }
36452
<p>I have written a tool for encrypting string using the AesCryptoServiceProvider in .NET. The folllowing parameters are used:</p> <ul> <li>Block Cipher Mode: CBC</li> <li>Initialization Vector: 16 bytes (randomized per encryption operation), stored in last 16 bytes of final message</li> <li>Key/Block size: 128 bit Pa...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T17:26:33.267", "Id": "59758", "Score": "0", "body": "Base64 or Hex. Hex coding (with 'smart' algorithms) is slightly faster to encode/decode than Base64, but is about 25% bigger for IO. Base64 encoding/decoding is almost as fast as ...
[ { "body": "<ol>\n<li>You can simplify it by replacing all those streams with a call to <code>encrypter.TransformFinalBlock</code>.</li>\n<li>You don't have a MAC, so an attacker who can send a modifier message to the decrypter can probably exploit a padding oracle to decrypt the message</li>\n<li>Why ask the ca...
{ "AcceptedAnswerId": "36458", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T13:48:55.690", "Id": "36453", "Score": "6", "Tags": [ "c#", ".net", "security", "cryptography", "aes" ], "Title": "AES Encryption C# .NET" }
36453
<p>Lil' preparation before the interview. This is my solution to the problem in title. The code is pretty straight forward. Requesting suggestions for improvement and also verification of complexity, which I guess is O(26<sup>n</sup>)</p> <pre><code>public class CatToDog { static Set&lt;String&gt; dictionary;...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T20:20:53.460", "Id": "59779", "Score": "2", "body": "I certainly hope the complexity is not O(26^n) ...." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T21:18:45.923", "Id": "59784", "Score": ...
[ { "body": "<p>I'm not sure about the exact complexity, but it is certainly huge! One-letter edits are fine to <a href=\"http://norvig.com/spell-correct.html\" rel=\"nofollow\">spell check one word given a large dictionary</a>, but does not work if you only have a few words and the edit distance can be arbitrari...
{ "AcceptedAnswerId": "36495", "CommentCount": "7", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T19:57:32.490", "Id": "36463", "Score": "5", "Tags": [ "java", "strings" ], "Title": "Shortest distance from one word to another. eg: cat -> cot -> dot -> dog" }
36463
<p>This is my first attempt at putting the conceptual knowledge I've gained about graphs into code. When searching for examples they all seem overly complicated, and searching for a tutorial or introduction leads to conceptual information. So here I am trying to code a very simple graph and this is what I have. The ver...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2015-05-27T18:28:29.410", "Id": "166894", "Score": "0", "body": "You should return 0 for success-- not 1." } ]
[ { "body": "<p>You're using pointers to local variables. If this were being done in a subroutine as opposed to in <code>main</code>, you'd probably end up pointing at objects that were no longer alive.</p>\n\n<p>Even if you let <code>Graph</code> copy the vertices, you couldn't reliably put them directly in a <...
{ "AcceptedAnswerId": "36490", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T19:59:07.727", "Id": "36464", "Score": "14", "Tags": [ "c++", "graph", "pointers" ], "Title": "Coding and printing a graph" }
36464
<p>I am trying to add parallelism. The following function works. For testing purposes, calculating <code>chunckLength</code> is fine. However, when I allocate more cores, it seems to slow down significantly which seems due to massive overhead. The visualisation shows the average core utilisation during execution. Each...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T16:33:34.403", "Id": "59879", "Score": "1", "body": "I think there isn't enough information here: add your full code, including the test cases and what parameters did you use." } ]
[ { "body": "<p>Have you tried <em>not</em> using explicit chunk sizes? <code>Parallel.For</code> does some fancy chunking (range-splitting) and load-balancing under the hood, which usually gives very good performance on it's own.</p>\n\n<p>In other words, try a simpler solution first, e.g.,:</p>\n\n<pre><code>le...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T20:35:56.143", "Id": "36467", "Score": "2", "Tags": [ "optimization", "performance", "beginner", "f#", "task-parallel-library" ], "Title": "parallel.For function" }
36467
<p>I'm reading <a href="http://www.cs.nott.ac.uk/~gmh/monparsing.pdf" rel="nofollow">monadic parser combinators</a>. On the page 23, they leave an exercise for defining a Gofer block comment parser, and I try to implement it in Haskell.</p> <p>My code is here:</p> <pre><code>import Control.Monad import Data.Char impo...
[]
[ { "body": "<p>I have figured out a better way of writing the code.</p>\n\n<p>Here I have 2 improvements:</p>\n\n<h1>1. Implementing <code>notCommentEnd</code></h1>\n\n<p>Reconsidering my first attempt, the problem is that <code>notParser</code> does not consume anything but <code>many</code> are expecting a par...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T21:33:39.327", "Id": "36468", "Score": "1", "Tags": [ "haskell", "parsec" ], "Title": "block comment parser implementation for \"monadic parser combinators\"" }
36468
<p>I'm currently implementing an interner in the style of Guava's <a href="http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/collect/Interner.html" rel="nofollow"><code>Interner</code></a>, where:</p> <ol> <li>an intern pool is maintained for an immutable class</li> <li>whenever ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-20T09:31:36.840", "Id": "62874", "Score": "0", "body": "nice little lib :) Maybe you could make it thread-safe, by synchronizing access to intern_pool with a mutex ? also I think the same functionnality could be achieved using a gem li...
[ { "body": "<p>I can't see much I'd change. It's a pretty neat concept, well done. I wouldn't change much. First, the minor things.</p>\n\n<p>I would consider changing the name of the argument to <code>Interner.extended</code> from <code>obj</code> to <code>klass</code>.</p>\n\n<p>Being a member of the \"lots...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-01T22:31:41.960", "Id": "36470", "Score": "3", "Tags": [ "ruby", "meta-programming" ], "Title": "Ruby 1.9 interner" }
36470
<p>The users get permissions to do specific things for a specific group of employees. These employee groups have a self reference. So an employee group (C) can be a child of group (B), and group (B) is child of (A). The user is granted permission to employee group (A), so if I want to check if the permission is granted...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T19:44:30.970", "Id": "60092", "Score": "0", "body": "It seems that my question is seriously bad :/" } ]
[ { "body": "<p>No. I don't think your question is bad. It's only hard to answer on, since there are so many different ways to solve the problem your method addresses. And if they are better or not is kind of subjective. With that said here are some comment on your method:</p>\n\n<p>Your method is too long and do...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T00:40:36.980", "Id": "36478", "Score": "1", "Tags": [ "c#", "security", "recursion" ], "Title": "Checking user permission, where permission is granted for specific EmployeeGroup t...
36478
<p>I went with what I know and can use well, not what I know and can't figure the syntax out to make it look good.</p> <p>So please enjoy the code and prepare to school me (probably in the basics) in C#</p> <pre><code>public static void Main (string[] args) { /* Here are your rules: "Scissors cuts paper, ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T10:11:55.840", "Id": "59837", "Score": "4", "body": "I actually like gestures be just a list of strings. Later if/else spaghetti kills the appetite though. ChrisWue is right in pointing out that you are using magic constants all ove...
[ { "body": "<ol>\n<li><p>Some minor syntax detail: C# has collection initializers so one can write:</p>\n\n<pre><code>List&lt;string&gt; listOfGestures = new List&lt;string&gt; {\n \"rock\", \"paper\", \"scissors\", \"lizard\", \"spock\" \n}\n</code></pre></li>\n<li><p>You use magic strings for the gestures a...
{ "AcceptedAnswerId": "36491", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T02:58:05.340", "Id": "36482", "Score": "19", "Tags": [ "c#", "beginner", "game", "community-challenge", "rock-paper-scissors" ], "Title": "RPSLS Game in C#" }
36482
<p>I am somewhat new to Java. I want to know if this is the proper way to share text with other Android applications, and if I am properly determining if the text is selected. Is there a better way to share the selected text? Is my decision statement proper? The app works just fine.</p> <pre><code>package com.kyle...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T10:19:16.170", "Id": "59839", "Score": "1", "body": "While Code Review does focus on reviewing working code, I think this specific question would be better answered by Android programmers, it's more about correctly using the API." ...
[ { "body": "<p>Honestly I believe you have answered this question yourself: <strong>The app works just fine.</strong></p>\n\n<p>From what I can see, you are using the intent <a href=\"http://developer.android.com/training/sharing/send.html\" rel=\"nofollow\">exactly as you are supposed to</a>. You are also using...
{ "AcceptedAnswerId": "36575", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T03:34:13.663", "Id": "36483", "Score": "3", "Tags": [ "java", "android", "beginner" ], "Title": "Android sharing selected text to other apps" }
36483
<p>Say I have the following SQL:</p> <pre><code>SELECT amount, amount*.1, (amount*1)+3, ((amount*1)+3)/2, (((amount*1)+3)/2)+37 FROM table </code></pre> <p>Instead of repeating that identical code every time, I really want to be able to do something like this:</p> <pre><code>SELECT amount, ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T04:42:12.527", "Id": "59809", "Score": "0", "body": "Not with T-SQL - From: http://technet.microsoft.com/en-us/library/ms176104.aspx ` < select_list > The columns to be selected for the result set.` and `A`, `B`, and `C` are not col...
[ { "body": "<p>You could define intermediate views using common table expressions. That would eliminate the redundancy of the calculations, but redundantly introduce a different kind of redundancy.</p>\n\n<pre><code>WITH ATable AS (\n SELECT amount, amount*.1 AS A FROM table\n), BTable AS (\n SELECT amoun...
{ "AcceptedAnswerId": "36528", "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T04:31:25.297", "Id": "36485", "Score": "5", "Tags": [ "sql", "sql-server" ], "Title": "Remove duplication in SELECT statement" }
36485
<p>I need some opinion if my code below is proper for an async process. This code only reformats text. Please let me know if this implementation is not proper or needs some improvement.</p> <pre><code>static void Main(string[] args) { Task.Factory.StartNew(() =&gt; ReadCharacter("File 1.txt")); Task.Factory.St...
[]
[ { "body": "<p>Well, you start two <code>Task</code>s each reading and writing a file but not the same. So basically it should be ok. Some remarks:</p>\n\n<ol>\n<li><p><code>Task.Factory.StartNew</code> returns a <code>Task</code>. You probably want to wait until the tasks you have started are finished before yo...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T05:01:27.887", "Id": "36487", "Score": "6", "Tags": [ "c#", "asynchronous" ], "Title": "“Proper” Asynchronous implementation" }
36487
<p>Review this code regarding optimization, cleanup, and best practices.</p> <pre><code>final class EdgePrims&lt;T&gt; { private final T source, target; private final int distance; public EdgePrims(T node1, T node2, int distance) { this.source = node1; this.target = node2; this.dis...
[]
[ { "body": "<ol>\n<li><p><code>public EdgePrims(T node1, T node2, int distance)</code> - What are <code>node1</code> and <code>node2</code>? From reading the source one can see they are source and target node - so they should be named accordingly. The names of the parameters of a function are an important piece ...
{ "AcceptedAnswerId": "36494", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T05:58:30.170", "Id": "36488", "Score": "5", "Tags": [ "java", "algorithm", "tree", "graph" ], "Title": "Prims algorithm implementation" }
36488
<p>In my code's package, I have a flag such as:</p> <pre><code>public static final boolean LOGS_VERBOSE = false; </code></pre> <p>And in worker classes (multi threaded <code>Runnable</code> jobs), I have code like:</p> <pre><code>if(XYConstants.LOGS_VERBOSE){ logger.debug("some state info var 1:" + var1 + ", var...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T03:59:46.447", "Id": "59938", "Score": "0", "body": "Any particular reason why `trace()` is not used, considering there are some debug messages that should always be shown (proper debugging?), and there are those with this boolean c...
[ { "body": "<p>This type of practice is common, and works well.</p>\n\n<p>The Java JIT compiler will identify the <code>LOGS_VERBOSE</code> as being a constant, and will know that it is always false, and thus will <code>compile-out</code> the logging entirely.</p>\n\n<p>There is a slight performance hit on any c...
{ "AcceptedAnswerId": "36502", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T13:09:43.117", "Id": "36501", "Score": "5", "Tags": [ "java", "performance", "logging" ], "Title": "log4j 1.2 - own check for verbose logs?" }
36501
<p>The next bit of code does exactly what i want it to do, but it is 'rather' unelegant and unpythonic, so the question is quite simple: how can this code be changed into something more elegant </p> <pre><code>import numpy from scipy.stats import nanmean A = [[1, numpy.nan, 2],[2,3,4], [2,3,4], [numpy.nan, 5, 5]] A1 =...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T14:19:58.973", "Id": "59865", "Score": "0", "body": "yeah, i know, but i just gave the 3x3 sample to make it easier ofc-" } ]
[ { "body": "<p>You can use <code>d2[:, dnan]</code> to select the wanted columns. (I'm assuming you want to process all rows unlike your current code)</p>\n\n<pre><code>def dosomething(d2):\n dnan = ~numpy.isnan(d2.sum(axis=0))\n validcols = d2[:, dnan]\n normalized = numpy.transpose((d2.T - numpy.mean(...
{ "AcceptedAnswerId": "36526", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T13:17:51.007", "Id": "36503", "Score": "1", "Tags": [ "python", "numpy" ], "Title": "Elegantly avoid columns containing NaNs?" }
36503
<p>I was given a task:</p> <blockquote> <p><strong>Given any integer</strong> - <strong>write a program, which</strong>:</p> <ol> <li><p>finds all digits of the integer</p></li> <li><p>writes odd and even digits from the integer</p></li> <li><p>finds the biggest even and smallest odd digit</p></li> <li>...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T13:58:09.660", "Id": "59857", "Score": "2", "body": "You mean better, more object-oriented and in line with best practices, or just *shorter*? Right place for the former, http://codegolf.stackexchange.com/ for the latter :)" }, ...
[ { "body": "<p>towards the end of your code you have :</p>\n\n<pre><code>for(i=0; i&lt;n; i++)\n{\n s=s*10+d[i];\n}\nfor(i=0; i&lt;n1; i++)\n s1=s1*10+nl[i];\n</code></pre>\n\n<p>these are two different coding styles that can confuse a programmer in a large set of code, you should have written the second t...
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T13:55:36.103", "Id": "36505", "Score": "5", "Tags": [ "c++", "algorithm" ], "Title": "Finding odd and even digits from an integer" }
36505
<p>I would like your opinion on the following subject. I have to provide icons in different sizes and states. The sizes will be <code>16*16</code>, <code>24*24</code> and <code>32*32</code>.</p> <p>The states bright, dark, disabled and link.</p> <p>Because of browser support we decided for <code>.png</code> instead o...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T14:08:48.853", "Id": "59862", "Score": "0", "body": "Is the class `.fx-icon.fx-icon-larger` part of the spec or was it just left out in your introduction?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-...
[ { "body": "<p>Yes, it's the right approach. You could use a CSS preprocessor to avoid mistakes due to repeating yourselves. Using PNG icons is a good idea because <a href=\"https://developer.apple.com/library/mac/documentation/userexperience/conceptual/applehiguidelines/IconsImages/IconsImages.html#//apple_ref/...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T14:02:07.417", "Id": "36507", "Score": "4", "Tags": [ "css" ], "Title": "Iconography - How would you improve this?" }
36507
<p>There doesn't seem to be anything really wrong with this method. But it has a little smell to me. Does the name make sense (do what you think it would do). Is there some logic I could use to make the enabler a bit more elegant?</p> <pre><code>private void tryEnableCRUD(bool tryEnable = true) { bool enable = fal...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T15:21:33.687", "Id": "59870", "Score": "1", "body": "please show the entire code in addition to the question. leave what you have but add the rest of the code, you don't want to negate the answers already given" }, { "Cont...
[ { "body": "<p>I would replace the <code>if</code>-<code>else</code>-part:</p>\n\n<pre><code>private void tryEnableCRUD(bool tryEnable = true)\n{\n bool enable = (_securityLevel &lt; 3);\n\n tsbDelete.Enabled = enable;\n tsbReplace.Enabled = enable;\n tsbUpload.Enabled = enable;\n}\n</code></pre>\n\n...
{ "AcceptedAnswerId": "36550", "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T15:07:39.343", "Id": "36514", "Score": "4", "Tags": [ "c#" ], "Title": "Improving readability of enabling method" }
36514
<p>The <em>weekend challenge</em> problem must be solvable with a relatively short solution that can be posted in anyone's favorite programming language.</p> <p>After the community <a href="http://meta.codereview.stackexchange.com/questions/1201/cr-weekend-challenge">has agreed on a problem for the weekend challenge</...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T15:15:09.280", "Id": "36515", "Score": "0", "Tags": null, "Title": null }
36515
Reviewing code is fun! Every now and then the community decides on a problem to solve; solutions are posted as questions to be peer reviewed. Use this tag to mark your question as a weekend challenge entry.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T15:15:09.280", "Id": "36516", "Score": "0", "Tags": null, "Title": null }
36516
<p>I initially thought that this was just an architecture issue so I placed it on programmers as <a href="https://softwareengineering.stackexchange.com/questions/219960/thoughts-on-refactoring-a-generic-dao">Thoughts on refactoring a generic DAO</a>. Then I asked on codereview meta <a href="https://codereview.meta.stac...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T16:44:22.723", "Id": "59880", "Score": "1", "body": "I strongly urge you to check out [Datanucleus](http://www.datanucleus.org/) and [Hibernate](http://www.hibernate.org/) before trying to roll-out your own [ORM](http://en.wikipedia...
[ { "body": "<p>I'll leave the actual generic DAO discussions out of this answer for now, and just offer my two cents on coding styles...</p>\n\n<ol>\n<li><p>You can use better method names instead of <code>getPojo</code>... Pojo is well-understood but still quite an informal term, and you'll probably attract equ...
{ "AcceptedAnswerId": "36548", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T15:18:02.870", "Id": "36519", "Score": "21", "Tags": [ "java", "design-patterns", "reinventing-the-wheel" ], "Title": "Generic DAO written in Java" }
36519
<pre><code>open System type Date = System.DateTime type SafeDate = | WorkingDate of Date | InvalidDate of Exception let dateAttempt (x: int, y:int, z:int) = try let returnDate = Date(z,y,x) WorkingDate returnDate with ex -&gt; InvalidDate ex let rnd = System.Random(4) let r...
[]
[ { "body": "<p>One way to work around invalid dates is not to generate them in the first place: find the number of days between the boundary dates, generate a random integer from this range and then add that number of days to the start date:</p>\n\n<pre><code>let generateDate (min : Date) max =\n let totalDay...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T16:00:49.433", "Id": "36521", "Score": "4", "Tags": [ "random", "f#", "datetime", "functional-programming" ], "Title": "is there a more functionally idiomatic way of generatin...
36521
<p>I have been writing the application. I meant to implement a repository pattern with Unit of Work. Is it correctly done? Can you make a code review? I use <code>SQLite</code> wrapper <code>sqlite-net</code>.</p> <h3>IFeedRepository:</h3> <pre><code>internal interface IFeedRepository&lt;T&gt; : IDisposable where T :...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T18:47:52.603", "Id": "59900", "Score": "2", "body": "From http://msdn.microsoft.com/en-us/library/b1yfkh5e%28v=vs.110%29.aspx#finalizable_types: `AVOID making types finalizable. Carefully consider any case in which you think a fina...
[ { "body": "<p>Your <code>IUnitOfWork</code> interface has mixed concerns with <code>IFeedRepository</code>; I don't think the <code>GetFeedData</code> methods belong in there. The way I understand UoW, it should be looking something like this:</p>\n\n<pre><code>public interface IUnitOfWork\n{\n void Commit()...
{ "AcceptedAnswerId": "36531", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-02T16:53:38.663", "Id": "36523", "Score": "8", "Tags": [ "c#", "sqlite", "mvvm" ], "Title": "Unit of Work with Generic Repository Pattern MVVM" }
36523
<p>Is this a <strong>valid</strong> and <strong>safe</strong> use of .NET's <a href="http://msdn.microsoft.com/en-us/library/system.threading.spinlock(v=vs.110).aspx" rel="nofollow"><code>System.Threading.SpinLock</code></a>?</p> <blockquote> <p><strong>Why am I doing this?</strong></p> <p><code>Random</code>'s...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T03:08:15.127", "Id": "59933", "Score": "3", "body": "Jon Skeet took care of `Random` and threading issues: http://msmvps.com/blogs/jon_skeet/archive/2009/11/04/revisiting-randomness.aspx" }, { "ContentLicense": "CC BY-SA 3.0...
[ { "body": "<p>I'll be humbly honest, understanding exactly what <em>useMemoryBarrier</em> does is way, <strong>way</strong> beyond my current understanding of C#, multithreading and memory management, so I'll leave that part to other answerers.</p>\n\n<p>I'm not sure this test is valid, but I ran it several tim...
{ "AcceptedAnswerId": null, "CommentCount": "8", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T01:41:37.573", "Id": "36542", "Score": "6", "Tags": [ "c#", "thread-safety", "random", "singleton", "lock-free" ], "Title": "Singleton SpinLock: Making Random Thread-Safe"...
36542
<p>I have an array where each element is either one less or one greater than the preceding element \$\{x_i = x_{i-1} \pm 1\}\$. I wish to find an element in it in less than \$O(n)\$ time. I've implemented it like this:</p> <pre><code>public int searchArray(int[] arr, int i, int elem) { if (i &gt; arr.length - 1 |...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T06:58:38.127", "Id": "59961", "Score": "0", "body": "Does `searchArray({2, 1, 2}, 0, 4)` terminate? `diff` will be `2` which calls again with `i = 2`, then `i = 0`, then `i = 2`, ad infinitum. If that's the case, you'll need to keep...
[ { "body": "<p>Here's some generic advice first:</p>\n\n<ul>\n<li><p>Avoid single-letter parameter names. For small loops <code>i</code> is fine, but it shouldn't leak into method signatures--especially when <code>index</code> is only four more letters.</p></li>\n<li><p>Be consistent with <code>if-else</code>. Y...
{ "AcceptedAnswerId": "36570", "CommentCount": "14", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T05:18:49.320", "Id": "36547", "Score": "50", "Tags": [ "java", "algorithm", "interview-questions", "search", "complexity" ], "Title": "Searching in an array in less th...
36547
<p>Continuation of this question: <a href="https://codereview.stackexchange.com/questions/36523/unit-of-work-with-generic-repository-pattern-mvvm">Unit of Work with Generic Repository Pattern MVVM</a></p> <p>I have made some modifications:</p> <ul> <li>Interfaces aren't forced to implement IDisposable</li> <li>Remove...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-04T20:50:19.207", "Id": "60225", "Score": "1", "body": "If SQLite-net works like EF, then you don't need a `LastInsertId` method - it should just update your POCO *automagically* :)" } ]
[ { "body": "<p>This new code looks much more cohesive, well done!</p>\n\n<pre><code>this._feeds = _db.Table&lt;T&gt;().ToList();\n</code></pre>\n\n<p>This is <em>eager-loading</em> the table content into your repository class, whenever you instantiate it. What you want is <em>lazy-loading</em>, and that's a diff...
{ "AcceptedAnswerId": "36577", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T10:07:38.017", "Id": "36561", "Score": "1", "Tags": [ "c#", "sqlite", "mvvm" ], "Title": "Unit of Work with Generic Repository Pattern MVVM, vol. 2" }
36561
<p>I have been building a site using php and would like advice to improve the structure of my site and the best way to lay out my code for SEO. I'm also a little concerned about echoing large chunks of HTML and how SEO will work with my structure.</p> <p>Ok here's my structure...</p> <p>My site contains many pages wi...
[]
[ { "body": "<p>I would not recommend using functions and echo-ing large chunks of HTML. You could just require the files. There is no need for functions. Also, use names instead of ID's</p>\n\n<pre><code>if (in_array($_GET['page'],array('home','contact','test')){\n require_once 'pages/'.$_GET['page'].'.php';\...
{ "AcceptedAnswerId": "36574", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T10:32:25.227", "Id": "36563", "Score": "2", "Tags": [ "php", "html" ], "Title": "Is this a good structure for my website?" }
36563
<p>I've made a Regex to find any URL on site, which uses PHP:</p> <pre><code>Reg = new System.Text.RegularExpressions.Regex("((http|https)://([a-zA-Z0-9-]{1,}[/]?))?[/]?([a-zA-Z0-9-]{1,}[.](php|html))((/[a-zA-Z0-9-]{1,}){1,}[/]?){0,}([?]([a-zA-Z0-9]{1,}=[a-zA-Z0-9\"&gt;&lt;();/.,]{1,}&amp;?){1,})?"); </code></pre> <p...
[]
[ { "body": "<p>Using regex to match a URI is never a good solution... as you have discovered, you now have <strong>two</strong> problems (the base problem, and the regex problem).</p>\n\n<p>In this case, you should use the language features to help you.... (<em>bear in mind I am a Java person, so I may have some...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T12:39:28.497", "Id": "36571", "Score": "2", "Tags": [ "c#", "regex", "url" ], "Title": "Finding PHP URL" }
36571
<p>I have a method that checks to see if a hash of given items should have discounts applied and if so, determines and returns the discount:</p> <pre><code>def get_discounts @items.each do |name, attr| @specials.each do |special| while name == special.sale_item &amp;&amp; attr[:quantity] &gt;= special.quan...
[]
[ { "body": "<p>I agree with both of your suspected issues:</p>\n\n<ul>\n<li><strong>Pointless iteration through <code>@items</code> hash:</strong> As you suspected, iterating through all entries of a hash defeats the purpose of a hash. That takes O(<em>I</em> * <em>S</em>) time — the number of items times the n...
{ "AcceptedAnswerId": "36595", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T13:17:05.587", "Id": "36573", "Score": "5", "Tags": [ "ruby", "e-commerce" ], "Title": "Calculating shopping cart discounts" }
36573
<p>The current code solves the issue I had when trying to use property injection.</p> <p><strong>Problem</strong>: Every module must use constructor injection because of a circular reference that occurs when not using constructor injection with my factories and trying to use property injection</p> <p><strong>Reason</...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-07T20:41:18.127", "Id": "60663", "Score": "0", "body": "Each DI has its pros and cons. Ninject, although very popular, may not be the best option for your situation. Have you tried any others?" }, { "ContentLicense": "CC BY-SA ...
[ { "body": "<p>Your question isn't crystal-clear about what it is exactly that your code is supposed to be doing. We have to infer the functionality from this block of code:</p>\n\n<pre><code>public void Start()\n{\n List&lt;Network&gt; networks = context.Networks.ToList();\n\n foreach (var network in netw...
{ "AcceptedAnswerId": "43278", "CommentCount": "6", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T14:19:10.763", "Id": "36578", "Score": "11", "Tags": [ "c#", "dependency-injection", "ninject" ], "Title": "How can I solve my constructor injection code architecture?" }
36578
<p>This looks pretty messy (need to reduce nesting I feel). I need a check an input for a seat, but I can't guarantee it has a value (one may not be chosen for example). If the seats aren't in a certain color it goes to seat basic (1), otherwise seat premium (2).</p> <pre><code> var seat = $("input[id*=" + seatPrefix...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-13T17:20:20.890", "Id": "76810", "Score": "0", "body": "Sorry to ask, but didn't you mean `typeof seat == 'undefined'` instead of `seat == 'undefined'`? `typeof` will check if the variable is undefined, while you do check if it is a s...
[ { "body": "<p>I'm not into <a href=\"/questions/tagged/javascript\" class=\"post-tag\" title=\"show questions tagged &#39;javascript&#39;\" rel=\"tag\">javascript</a>, so I'm not sure this would be legal, but I'd reduce nesting like this, by reverting the conditions and returning immediately:</p>\n\n<pre><code>...
{ "AcceptedAnswerId": "36587", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T15:54:09.240", "Id": "36582", "Score": "8", "Tags": [ "javascript", "jquery", "null" ], "Title": "null/undefined checking for checking seats" }
36582
<p>There is a user login, and the requirements are the following:</p> <ul> <li>The login must start with a Latin letter. </li> <li>The login must finish with either a Latin letter or a digit.</li> <li>There may also be digits, dots, and minus signs in the login.</li> <li>Min. login length is 1.</li> <li>Max. login le...
[]
[ { "body": "<p>That regex does not meet the requirements of your rules... so ... No, it is not OK.</p>\n\n<p>The missing aspect is that the regex requires at least two characters, but the rules say one char is OK.</p>\n\n<p>Also, I don't like that the last group has the <code>+</code> on it. While it is accurate...
{ "AcceptedAnswerId": "36593", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T17:35:10.727", "Id": "36591", "Score": "7", "Tags": [ "java", "regex" ], "Title": "A regex in Java. Latin letters, digits, dots, and minus signs" }
36591
<p>I'm rather new to jQuery but managed to get some social links to open in a new controlled window instead of new tab. I have a few functions that do the same thing, and this works, but there is always a better method.</p> <p>I did review the question and answer <a href="https://codereview.stackexchange.com/questions...
[]
[ { "body": "<p>First of all, make sure you declare your variables using <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var?redirectlocale=en-US&amp;redirectslug=JavaScript/Reference/Statements/var\" rel=\"nofollow\">var</a>:</p>\n\n<blockquote>\n <p>assigning a value to a...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T18:49:54.717", "Id": "36596", "Score": "2", "Tags": [ "javascript", "jquery" ], "Title": "Opening social media links in a new window" }
36596
<p>I just learned the quicksort algorithm and tried to implement it, but it feels dirty:</p> <pre><code>#include &lt;iostream&gt; void quicksort(int list[], int low, int high) { if(low &gt;= high) return; else { int pivot = low, i = low, j = high; while(i &lt; j) { ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T19:18:08.937", "Id": "60088", "Score": "0", "body": "Is this just C++? The only C here are some of the libraries." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T19:19:47.680", "Id": "60089", ...
[ { "body": "<p>There are three things I can see which can improve (but this is a far from complete answer... there may be more)..</p>\n\n<ol>\n<li>You can start <code>i</code> at <code>low + 1</code>, which will save you a comparison on each pivot.</li>\n<li>Your <code>i</code> loop should be terminated at <code...
{ "AcceptedAnswerId": "36607", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T19:16:14.637", "Id": "36598", "Score": "3", "Tags": [ "c++", "optimization", "algorithm", "quick-sort" ], "Title": "I feel as if my quicksort can be made more efficient, bu...
36598
<p>I'm looking for any and all feedback on quality, style and efficacy of the code. If there's a simple way to get the header put in, I'd love to hear that.</p> <p>The code is used to take zip codes from a csv file and and spit back out the city and state where available.</p> <pre><code>import sys import os import cs...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-04T01:51:03.673", "Id": "60119", "Score": "0", "body": "Just curious from someone in the beginning stages of python, but why pass in your main method but instead put everything inline?" }, { "ContentLicense": "CC BY-SA 3.0", ...
[ { "body": "<p>First, a few general comments about the 'main function' in Python. The <code>__name__ == '__main__'</code> idiom is a way to distinguish between simply importing a module and launching one. You may want to simply import the module you just wrote to reuse the <code>checkZips</code> function elsewhe...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T20:20:54.733", "Id": "36601", "Score": "2", "Tags": [ "python", "csv" ], "Title": "get city and state using zip code, scrape in Python" }
36601
<p>I've just created a winform that exports a datagrid to Excel. Originally the file was never shown, but I was asked to give the option. So I put in a checkbox and modified the code.</p> <p>Is my if/else statement at the end enough or should I go about it a different way?</p> <pre><code>private void buttonExport_Cli...
[]
[ { "body": "<p>Yes, I'd say the <code>if..else</code> is enough, but it's a little wordy. <code>Button.Checked</code> is already a <code>Boolean</code> value, so comparing it to <code>true</code> is superfluous. There's also a lot of shortening of code you can do with the judicious use of <code>using</code> dire...
{ "AcceptedAnswerId": "36609", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T22:06:23.247", "Id": "36605", "Score": "5", "Tags": [ "c#", "winforms", "excel" ], "Title": "Winform that exports a datagrid to Excel" }
36605
<p>I've written a code snippet that will get a (max.) 14 character string from the user input, and while the user is typing, simultaneously echo it out to the screen.</p> <p>It seems a bit long and ugly, so I was wondering if any of you would happen to have ideas on how to shorten, and generally optimize this.</p> <p...
[]
[ { "body": "<p>c++ isn't really my language, but I believe this would be an identical loop:</p>\n\n<pre><code>for(int i = 0; i &lt; 15; i++)\n{\n char npt = _getch(); // Get input\n\n if(npt == '\\r')\n break;\n else if(npt == '\\b')\n {\n if(!name.empty())\n name.erase(std::prev(name.end()));\n ...
{ "AcceptedAnswerId": "36641", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T22:14:49.757", "Id": "36606", "Score": "1", "Tags": [ "c++", "strings", "windows", "console" ], "Title": "Getting limited user input, with echo" }
36606
<p>This is probably horribly sloppy, but here it is! This is a section from a large (imo) GUI program I am making. The below code is what triggers when a specific button is pressed. </p> <pre><code> def calc_platenumber(self): customer_firstname = str(self.customer2_entry.get()) customer_lastname = str(self.cu...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T23:15:22.760", "Id": "60109", "Score": "1", "body": "Clean code is good just for the habit of writing clean code." } ]
[ { "body": "<p>You're opening the files more than once like:</p>\n\n<pre><code>infile = open('used_license_numbers.txt', 'r')\nused_license_numbers = infile.readlines()\ninfile.close()\n</code></pre>\n\n<p>Instead write it like this:</p>\n\n<pre><code>with open('used_license_numbers.txt', 'r') as infile:\n us...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-03T22:42:45.700", "Id": "36608", "Score": "5", "Tags": [ "python", "python-3.x" ], "Title": "Copying data to a .txt, but making it look nice?" }
36608
<p>One of my colleagues told me that you can use <code>streambuffer</code> for <code>std::string</code>, and instead of using <code>string id</code> in the <code>for</code> loop, you can declare it outside.</p> <p>I am not sure whether this will make any difference or not.</p> <pre><code>void getRecord(uint64_t curre...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-04T05:14:03.587", "Id": "60132", "Score": "1", "body": "I would not care about optimizing the string code (write it in the most easy way to read and thus maintain). Be far the slowest part of that code is the line: `Cassandra::execute_...
[ { "body": "<p>This looks like incomplete code to me.... what do you do with <code>result</code> once you have it?</p>\n\n<p>Still, I look at what your code does, and can't help but think your priorities are wrong in this instance.....</p>\n\n<p>sure, <code>streambuffer</code> may hypothetically be faster than y...
{ "AcceptedAnswerId": "36618", "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-04T00:47:58.650", "Id": "36614", "Score": "4", "Tags": [ "c++", "optimization", "strings" ], "Title": "Streambuffer and string manipulation" }
36614
<p>I am developing a WPF application that requires me to get an Access Token from <a href="https://developers.facebook.com/docs/reference/dialogs/oauth/" rel="nofollow" title="Facebook Login Dialog">Facebook using oAuth</a>. After much searching online, I came to the following conclusions:</p> <ol> <li>OAuth must be d...
[]
[ { "body": "<p>I don't know much about Facebook or OAuth, so I'm not going to comment on that.</p>\n\n<ol>\n<li><pre><code>this.Loaded += (object sender, RoutedEventArgs e) =&gt;\n</code></pre>\n\n<p>When you have a lambda that's this long, it's usually better to write it as a normal method. And when you do that...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-04T07:02:30.093", "Id": "36623", "Score": "2", "Tags": [ "c#", "wpf", "facebook", "oauth" ], "Title": "Facebook OAuth in WPF" }
36623
<p>I would like to develop a kind of template or canonical implementation for a concurrent subclass of <code>NSOperation</code>.</p> <p><strong>Edit:</strong> there is a related request which implements the <a href="https://codereview.stackexchange.com/questions/107659/canonical-implementation-for-a-concurrent-subclass...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-04T12:23:20.880", "Id": "60146", "Score": "0", "body": "Are you satisfied that your code is working? Are there problems you need to resolve or is the code ready for a review?" }, { "ContentLicense": "CC BY-SA 3.0", "Creatio...
[ { "body": "<pre><code>- (id)initWithCount:(int)count completion:(completion_block_t)completioHandler;\n</code></pre>\n\n<p>There's a typo here, a missing \"n\" in the last argument.</p>\n\n<hr>\n\n<pre><code>- (id)initWithCount:(int)count completion:(completion_block_t)completionHandler\n{\n\n- (id) result {\n\...
{ "AcceptedAnswerId": null, "CommentCount": "12", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-04T11:32:45.890", "Id": "36632", "Score": "10", "Tags": [ "objective-c", "ios", "osx" ], "Title": "Canonical Implementation of a Subclass of NSOperation" }
36632
<p>How can I shorten and optimize this code which displays then hides a <code>DIV</code>?</p> <pre><code>setTimeout(function () { $('.updateNotification').show().addClass('heightener'); callback(); },2000) function callback() { setTimeout(function() { $( '.updateNotification' ).fadeOut(); }, 10000 ); ...
[]
[ { "body": "<p>I'm not sure how you would shorten this code. However I think that <code>callback</code> is a <em>terrible</em> name for a function that fades a CSS class. Remember that a function signature should represent what a function does and with that said I would rename it to something like <code>fadeUpda...
{ "AcceptedAnswerId": "36644", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2013-12-04T15:11:15.913", "Id": "36642", "Score": "3", "Tags": [ "javascript", "performance", "jquery" ], "Title": "jQuery function that modifies a DIV" }
36642