Best-practice questions generally involve a short excerpt of code with a question of general interest, usually focused more on maintainability concerns than the algorithm to solve the task at hand. Note that questions must include a real code excerpt and sufficient context for reviewers to make ...

learn more… | top users | synonyms

1
vote
0answers
21 views

Wrote a package in Go. What did I do wrong? What did I do right?

I wrote a Player package in Go. It builds correctly, but I would love a review on what I did and did not do "the Go way". I'm new to coding in the language, although I've gotten about halfway through ...
1
vote
0answers
46 views

Providing core functionality orthogonal to business logic in Dart

Below is a simple Trade class with minimal business logic: primarily a method to get market value associated with the trade. But the trade needs the following pieces of core functionality, orthogonal ...
6
votes
4answers
250 views

Identify Java Callback

I have this common design in my application: ...
3
votes
0answers
119 views

Purposely raising exceptions to use catch [migrated]

For a typical if...else wrapped with exception handling, is something like the following example a recommended practice to avoid code duplication? ...
6
votes
1answer
40 views

Bash script to convert NIST vectors to debug scripts

TL;DR: The Bash script (below) is converting a published, somewhat-structured text file into a format usable by my testing infrastructure. It's slow, I think it's ugly -- although it is fully ...
0
votes
2answers
108 views

Tic-Tac-Toe implementation where computer should not lose

I have implemented Tic-Tac-Toe so that human can play with the computer, where the computer should never lose. I did a simple analysis before implementing, and I found out that there are certain ...
8
votes
5answers
408 views

Similar methods using loops

Is it recommended to combine two similar methods into one? ...
6
votes
2answers
166 views
7
votes
2answers
70 views

Python Port Scanner 2.1

I made lots of changes to the script presented in my previous question. I was tempted to edit that one with the new code, but it would invalidate @200_success's helpful answer. It was also ...
3
votes
1answer
42 views

Python Port Scanner 2.0

A few months ago I put up a port scanner for review. Now, I've updated it with some new Python knowledge and integraing the feedback I got. Some things I specifically think might be wrong with it or ...
12
votes
4answers
957 views

Prime Number Generator - Are the conventions proper?

I am slowly learning C and C++, and decided after a few lessons to dive in myself without any help. I developed this Prime Number generator. It seems fast, but I'm wondering if I'm following the best ...
1
vote
0answers
51 views

Getter Setter conventions [closed]

In C# I am creating properties in different ways. Like this: public Dimension X { get; set; } and like this: ...
5
votes
2answers
100 views

Is this a decent first Objective-C project, and can others learn from it?

This isn't my first time coding in Objective-C, but I do sometimes fantasize about there being a de facto standard "practice" project. I'm toying around with this code, and I'd like your input. ...
3
votes
0answers
38 views

jQuery Plugin - HTML5 History State

I've built this small jQuery plugin to work with HTML5 History State functions. It's my first jQuery plugin, so I'm not sure if it's up to the best practices, or what could be done better. Keeping it ...
7
votes
3answers
374 views

Implementation of stack using pointers

Please review my code and let me know how I can possibly improve it. ...
3
votes
2answers
80 views

Check quotient and division by zero [closed]

Please evaluate this code and tell me if it is standard C++ coding: ...
0
votes
1answer
32 views

Is it in bad form to use “Model” as a model class suffix? [closed]

I have the following setup but I'm worried that using Manager and Model as a suffix might be frowned upon to other developers. I, personally, like it because it makes everything clear, visually, when ...
2
votes
0answers
24 views

OpenMP parallel for critical section and use of flush

The following is my code. I am not sure about the place where flush should be used (if it is used at all here). ...
2
votes
1answer
54 views

LRU Cache with a static variable for garbage value

I have tried to implement a Least Recently Used cache with only C++ STL containers. The main thing that I keep asking my self the static variable called ...
4
votes
2answers
71 views

Checking endianness at compile-time

I've tried to make a portable way of ensuring endian-specific code gets generated at compile time using C++11, however I only have a computer with Windows on it to test at the moment. Because of this, ...
2
votes
1answer
100 views

Is this right structure for MVC / MVP application?

I have written a code for an application/website that I wanted to be structured similarly to MVC design pattern (but I think it's rather MVP based on comparison I read). This functions as a kind of ...
3
votes
1answer
31 views

System for tracking stock information

Background: I'm designing a system (VB/WinForms) that uses a database(MS SQL Server 2008 R2) to track people, their stock account #'s, which stocks they are investing in, and the payout of those ...
6
votes
2answers
221 views

Pythonic way to dynamically generate Strings (or other variables)?

I've got a Python script which is meant to launch several other shell scripts with the appropriate setup and parameters. I construct the file paths from other variables so that it's easier to change ...
9
votes
1answer
65 views

Processing C++ comments

Here's the first functional version of my Python 2 script for processing comments in C++ source files. It's a personal project, I expect to expand it later with more advanced options (mainly about ...
0
votes
0answers
8 views

Performance consideration and code reduction for Templates [migrated]

I'm trying to decide if this might be a good idea to help reduce the size of some of my xaml resource dictionaries on a large project. Except I'm concerned about any potential performance issues going ...
9
votes
4answers
298 views

Tic-Tac-Toe feedback requested

I just started learning coding about 4 months ago, I think Tic-tac-toe was the first application that I've ever written in C# not counting the mandatory "Hello, World!". So for me, I really wanted ...
3
votes
2answers
36 views

How to reformat this code so I don't use 'Exit Try' and 'Exit For'?

I use SonarQube to help me try and become a better programmer to program along with 'best-practice' standards. There are business rules when a user is submitting data they enter in a datagridview ...
9
votes
2answers
99 views

Optimizing “simplifier”

Basically, I'm trying to make a Simplifier that can take inputs in the form of a String and print out the solution step-by-step. Now that I've got it working, I ...
7
votes
3answers
490 views

Does my reversal program in C follow the common practices?

I sometimes hear people say how they can distinguish between good and bad coders of a certain programming language or even programming in general simply by looking at the code they write. I'm ...
5
votes
2answers
44 views

Proper action when a Java program fails

I have a program that has to initialize a few big things (connect to a few databases, parse some XML) and without the initialization being successful the program would not be able to continue. Right ...
10
votes
1answer
138 views

Refractoring OOP vs. Functional Programming Approach

I am writing a python script that will call mandrills export activity api for every blog on a worpress mu install except for the main site. The script is designed to be called from a cron job on a ...
5
votes
2answers
62 views

Where to define constants?

I have a program that accesses a certain io controller using memory mapped io. Currently I store the base address of this controller in a const variable. This leads to a code structure something like ...
10
votes
3answers
229 views

Avoiding code duplication and retaining const correctness

Sometimes I run across the problem of having two member function overloads that only differ in the constness of this (and the return type, but that is less ...
3
votes
2answers
56 views

Diving into Python sequences: analyze an access.log

As a first little python exercise, I wrote an analyzer/summarizer for my nginx accesslogs. The code works fine but I'm not sure if I used the different types of sequences properly or made some other ...
5
votes
1answer
113 views

How is OOP achieved with configuration files in PHP?

Someone asked if their singleton is good for OOP: Using a singleton class to get and set program wide settings. However, the answer just provides tweaks to his existing code - but the question ...
5
votes
1answer
328 views

Mini mind reader

Here is a code that guesses the number chosen by the user. I know that using goto is a bad practice, but it seems unavoidable here. that's because using do while ...
2
votes
0answers
61 views

Domain modelling with Repository [closed]

I've been struggling with some architectural problems which I'm having a hard time figuring out myself. Im trying to construct a basic structure of a project with the domain model and repository ...
6
votes
1answer
207 views

Checking web-page repeatedly

I have a program that gets 5 random dice throws from random.org over and over. In order to avoid doing getaddrinfo() over and over with the exact same data, I moved ...
4
votes
1answer
179 views

Concerned with Enums, JSON, and ASP.NET MVC

I am writing an application that uses ASP.NET MVC for its front end, and for the back end, it uses RavenDB to store data. This ...
4
votes
1answer
58 views

How to properly detect multiple devices failure?

My software has multiple devices connected before starting. I must be sure these devices are working and are well connected. every device has different error ID code so we can see every component that ...
6
votes
2answers
129 views

Improving a number-to-word converter to better match Pythonic standards

I just finished creating a simple Python module that converts a number to words (done to death, I know). It's basically something that I thought of earlier today while teaching my 2-year old daughter ...
10
votes
3answers
168 views

Review of PHP prepared statements from security viewpoint

I received a ton of help from 200_success once again here. Since then, I decided to go with OOP Style and prepared statements, and so far I like it a lot more than the procedural style. Much more ...
5
votes
2answers
105 views

PHP framework building: Sessions Managment Class

I am building a PHP framework and would like to get some feedback on a few different sections of the project so far. I consider myself still a neophyte in PHP so I would like to ask if I'm going about ...
5
votes
1answer
86 views

Console monster battle game

This code currently works, but I'm new to Objective-C from a Python/PHP background. How can I improve it/make it more Objective-Cesque? Header File/Interface ...
7
votes
1answer
309 views

Simple example of N-Tier, entity framework, unit of work, repository, business logic layer

I've been studying C# for about 6 months and am trying to make a simple example for an n-tier application. I want to learn to do things in the most proper and professional way. This example uses a ...
10
votes
3answers
115 views

Windows socket class

I need some advice to see if my simple Windows socket class is good enough to be used in a simple chat application. ...
5
votes
2answers
133 views

Do I have any SQL leaks?

This is a Windows service that will run on about 600 machines. It is used to track the job server that a user is connected to (pushed through some kind of load balancer, not my area). I store this ...
9
votes
2answers
152 views

Value formatters (for entities like price, currencies so on)

I am looking over some existing code (see below). The problem of grouping in the same place the presentation logic of some fields (like price, currency) was solved as extension methods on ...
2
votes
1answer
88 views

Two methods for finding a sprite in sprite sheet C++, which is better?

I have two snippets of code that I would like you to look at. I can't figure out which of the two is most efficient (or better practice, if applicable). I'm currently finding the row and column of a ...
3
votes
1answer
41 views

.get() for multiple unique files

I'm using jQuery's .get() method to load content from external HTML files into my main index file. I created 25 different functions, function ...