Design in programming is the act of making particular choices about how best to structure a program, to achieve goals of reliability, maintainability, correctness or ease of use.

learn more… | top users | synonyms

2
votes
3answers
119 views

What is the potential risk with this code?

I am trying to implement a distinct counter to detect if all tasks that is added to the ThreadPool has completed and want to use it as a barrier. So, when a function that is added to the ThreadPool is ...
1
vote
1answer
38 views

PHP “web service” and jQuery ajax

I've been writing classic ASP.NET web services for a while now, and this is my first time writing a PHP based web service. I'm rather new to PHP as well. In ASP.NET, you directly call the web method ...
1
vote
2answers
65 views

How's my and my father's java ODE Solving and Graphing Program?

At the request of my father, I've adapted some C# code he wrote which uses a timer to display the true and approximate solutions of the ODE y' = -lambda*y in real time to do the same in java and then ...
0
votes
2answers
45 views

Making each module expose an interface

Is this a good/correct way to write a robust C program? //File1 => Module1.c static int Fun(int); struct{ int (*pFn)(int) }Interface; static int Fun(int){ //do something } Interface* ...
4
votes
1answer
85 views

Critique my Stack Overflow schema

I'm learning DB design. How would you change the following schema which tries to replicate Stack Overflow's functionality: create_table "questions", :force => true do |t| t.text ...
1
vote
2answers
165 views

Designing an EventHandler in C++

I am writing a simple event handling class in C++, to avoid having delegate registration and calls cluttering the rest of the code. I have a design that seems to do the job, but it has a couple of ...
2
votes
0answers
50 views

Parallel Job Consumer using TPL

I need to provide a service (either a Windows Service or an Azure Worker Role) which will handle the parallel execution of jobs. These jobs could be anything from importing data to compiling of ...
2
votes
4answers
97 views

What are the drawbacks of this “multi-key” dictionary?

I was making a relatively large-scale project in Python as a learning experiment, and in the process I found that it would be useful to have a map (or, in Python, I guess they're called dictionaries) ...
3
votes
1answer
77 views

Parallel Job Consumer

Edit: A second iteration of this problem here. I need to provide a service (either a Windows Service or an Azure Worker Role) which will handle the parallel execution of jobs. These jobs could be ...
2
votes
1answer
25 views

“specific case” object that stands for “any object” : is it a good idea ?

I got tired of doing (more or less) this in my rails controllers : class ThingsController < ApplicationController def index @category = Category.find( params[:category_id] ) if ...
1
vote
2answers
37 views

Ruby OO design : how to handle inconsistent state in a mutable class?

Abstract I'd like to have advice on how to : implement methods that rely on a state, when the instance is mutable and may be in an inconsistent state, in such a way that the methods either ...
5
votes
1answer
64 views

Can I get some tips for improving my tokenizer design?

I need some tips on how to improve the design of the following code. Everything works correctly in the program. It takes a string and shows each token the only tokens being numbers and operators. The ...
3
votes
2answers
74 views

Method Of Retrieving Random Value Depending on Type

I was wondering what would be the most appealing way of achieving this goal. I have a blackbox. I give it a supported type and it returns a random value base off of the type. For my supported types, ...
2
votes
1answer
110 views

Do I need to delete a vector?

I want to make a graph from input from a text file in the format: vertex1 vertex2 cost time where vertex1 and vertex2 are strings that form an edge and cost and time are the properties of that ...
1
vote
2answers
43 views

Design class to handle calls for support functions

For the following problem statement, I design following classes. Can you please tell me if this is the correct implementation or if there can be a better one? Let's say there is call center with ...
3
votes
2answers
88 views

Initializing complex constant in Constants interface

I'm being forced to use the common anti-pattern of a public interface Constants which many classes in this project implement. Long story short, I need to have a List constant which is pre-populated ...
2
votes
2answers
160 views

Python Pig Latin Translator

This is only my second Python script, so let me have it! If anything seems off in style or implementation, please nit pick away. I want to learn. I know it could've been done in less lines of code ...
2
votes
2answers
125 views

Implementing a Scheduler(something that implements a given schedule)

I am trying to implement a class that implements a given schedule. I am trying to design this Scheduler class so it can be paused and everything. I have just written some example code so I can better ...
2
votes
1answer
138 views

How to separate code into smaller classes using SOLID principles

I have a console application that basically retrieves xml content, writes to the xml file and sends the file to sftp site. This may seem long post but I believe it is simple stuff that need advise on ...
1
vote
1answer
142 views

Class Design - Excel Report

I am working on a C#.Net application that will generate an Excel report from a template. Although the code's not in the app yet, it will pull data from a SQL Server database to populate the report. ...
1
vote
1answer
70 views

Programming a simple clock

Here's the beginnings of some code for a clock that can display in 24 and 12 hours. What could be added to it ? How could I can apply notions such as OOP, model and Enums here ? P.S: Will edit later ...
3
votes
1answer
65 views

Newest approach to deck of cards project

As this new approach differs from my previous revisions, it shouldn't need references to them. After receiving much guidance from CR chat, I ended up utilizing these things: enums for the Rank and ...
0
votes
0answers
47 views

How to design a robust class for Packet Capturing tool

I need to design a class for packet capture tool. Class should provide service to start and stop a dumpcap packet capture. Class should be capable of accepting all sorts of inputs which includes ...
1
vote
1answer
94 views

Comparison with a range

I'm developing a class to compare prices. For example, give me products which price are above 50 or under 50. Here's my API: var indicator = new PriceIndicator(PriceComparison.Above, 50); var actual ...
2
votes
2answers
77 views

Deep iterations with side effects

Suppose I need to process a list of list of list of many objects, where the data usually comes from third party APIs. For the sake of an example, lets assume we have many users, and for each user we ...
3
votes
1answer
167 views

How to improve my programming skills through improving this code?

It is usually inefficient to find bugs in a longer code. Unfortunately, after spending too much time in debugging my code, I realize that a good programming habit is important. Please give me some ...
2
votes
1answer
53 views

Problem to find the right structure for my application

first of all some words about the task I'm dealing with. I have three different types of XML-Files (Structure) which I would like to import into a database. Every hour a cronjob calls my import.php ...
0
votes
2answers
202 views

Printing out all the subsets of a set. Am I unnecessarily creating new objects?

1) I am concerned about the creating too many objects in my code. 2) Am I using duplicate code? Can I cut down on the number of lines of code? Note: I only want to use recursion to solve this. ...
1
vote
1answer
529 views

Text-based adventure RPG inventory code

I am trying to make a text-based RPG in Python and Pygame. I need a way to manage my inventory slots. Currently, I have no way to find out what is currently equipped. I can only overwrite it, even ...
2
votes
1answer
106 views

Too much abstraction/indirection hurting simplicity

I made an android app which utilizes SSDP for automatic device discovery. Because I didn't need the whole UPnP functionality, I wrote my own independent SSDP component. It works well, but I feel ...
0
votes
1answer
26 views

javascript: data and vtables vs. objects and methods

I present a bunch of grids of data to the user, and want to sum certain columns in some of the grids. // for one such grid: rows = [{id: 0, name: "Alice", age: "23"}, {id: 1, name: "Bob", ...
6
votes
3answers
244 views

Clean way to call functions based on string value

I'm receiving a certain string value over the network and I need to call a function based on that value. So this is more or less what I have at the moment: String methodName = ...
0
votes
2answers
77 views

Extending a simple Python console program with external code. Did I handle this correctly?

I'm a hobbyist Python programmer with not much experience. I wrote some code for a solution to a Tic Tac Toe AI problem on the internet. Then yesterday I wrote a simple console Tic Tac Toe game for ...
0
votes
1answer
31 views

Best way to manage a device information class

This is probably a really simple question. An embedded device I'm working with will store the device information in an xml file. In my code, I want to read this xml file and freely reference to it ...
2
votes
1answer
96 views

Is this nested class design ineffective for my Deck class?

Previous review of this project: Proper use of multiple classes and member-accessing with one header? I'm nearly finished with my deck of cards project, and this time I made changes to hide the Card ...
1
vote
2answers
108 views

What Data Annotations need to be shared/different between my Model & ViewModel to keep seperation of concerns?

I read this question and answers, about if Display Annotations on model properties violates the separation of concerns between view and model. And my interpretation of their answer was "No, not if ...
5
votes
2answers
155 views

Design for a protocol based software in C++

I want a good design to implement a master-slave protocol. The protocol is proprietary and similar to cctalk. We have: Master: HEADER [ DATA ] CHECKSUM Slave: HEADER [ DATA ] CHECKSUM My choice was ...
1
vote
2answers
93 views

Custom template iterator on CSV reading class

I made myself this code to read CSV files as I want to delve into machine learning. I do think that my code design is poor but I can't quite see why. The syntax of it does not feel right. I want to be ...
3
votes
1answer
158 views

Very simple implementation of observer pattern in C++

I'm reading on design patterns for a software engineering class. I am doing small implementations of some I find the most interesting / applicable to better understand them. I'd like a code review on ...
3
votes
2answers
110 views

Looking for a better solution to my OO code

I would like if this could be kept to a post providing concrete examples of how I could solve my problem better, and not about which one would be "best" as such :) I would simply love some insight to ...
8
votes
2answers
320 views

Aimbot for an open source FPS game. Any suggestions?

I am actually quite new to C++, although I have previously programmed in Java. Do you see any ways I can improve readability, maintainability and performance, and make it more object-oriented? The ...
3
votes
2answers
109 views

Does this violate the SRP?

I just finished (re)reading Clean Code, and one of the ideas I learned was the SRP. However, I am not quite sure on what defines a "Single Responsibility." In the piece of code below, I have a Note ...
3
votes
1answer
143 views

framework design review (SOLID)

I'm developing a php framework for educational purposes, I have learned a big deal about design patterns and MVC. I've been thinking a lot on how to have a nice design and so far I've come up with ...
0
votes
0answers
73 views

How to implement MVC on the application scale?

I'm developing a simple conferencing app with a Swing standalone client which connects to enterprise java beans. Users can create "sessions" (conferences) on the server, and then can join those ...
2
votes
2answers
154 views

How to design interface of deep-copy behaving pointer containers?

I want to make a container which manages big objects. which performs deep copies on copy construction and copy assignment. I also like the interface of the std containers, so I wanted to implement it ...
2
votes
1answer
84 views

Applying DocumentListener on multiple JTextField

Say I have 5 JTextField: jTextField1, jTextField2... Now I want them to behave the same on DocumentListener, so I decided to make only one DocumentListener and set it to the 5 components. Meanwhile ...
1
vote
1answer
405 views

A database schema for an online rental store

I am creating an online rental store using the following: JSF 2.1 Hibernate 4.2 Spring 3.2 MySQL 5.5 Below is my database schema design: Link in case image not displayed. The rental user has ...
1
vote
0answers
39 views

Skeleton SASS Feedback and Review

recently I have been developing a SASSified version of Dave Gamache's Skeleton CSS front-end framework. I have publicly posted the code on github which can be found here as well as a live demo. What ...
7
votes
3answers
532 views

Which of these two java class designs is better and why?

Example 1: public interface Adder { public int getSum(); } public class AdderImpl implements Adder { private int v1; private int v2; public AdderImpl(final int v1, final int v2) { ...
1
vote
0answers
42 views

Design issue with decoder class

I'm designing a C++ Decoder class for decoding a format, and would like some feedback on my design choice: I want the user to be able to provide input to the decoder by either supplying an array, a ...