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

0
votes
0answers
27 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
81 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
71 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 ...
-1
votes
0answers
22 views

If an object is needed by a two classes (outer and inner), what's the best way to share the object? [closed]

Lets say: Class A has a B which has a C which has a D which has an E. Class A and class Z both have a Z. In an instantiated case, A and E need to share the same Z. What's the best way to get the Z ...
3
votes
1answer
149 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
51 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
85 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. ...
0
votes
1answer
89 views

Python Adventure RPG Inventory Code (Text)

I am trying to make a text-based rpg in Python, Pygame, and i need a way to manage my inventory slots. Currently, i have no way to find out what is currently equipped, and can only overwrite it, even ...
2
votes
1answer
76 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
20 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
207 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
58 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
30 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
91 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
70 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
148 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 ...
0
votes
2answers
56 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
102 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
108 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
244 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
101 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
90 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
47 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
110 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
53 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
207 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
32 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
528 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
40 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 ...
2
votes
1answer
90 views

How to create a simple stateless cache class in PHP

i need to create a cache class to avoid making the same calculations more than needed. My idea was something really basic like class transient_cache { static private $cache = array(); static ...
6
votes
2answers
243 views

python: design of a simple game

I am trying to code Battleship. It should be a text one-player game against computer where computer and human player take turns in shooting at opponent's ships. I decided to start implementation with ...
1
vote
1answer
37 views

Designing a RESTful API for a 3D Printer

I'm implementing a REST API to manage a 3D printer, it will add a layer to the system so instead of sending GCode commands (the language the controller understands) directly to the controller (an ...
1
vote
2answers
68 views

A Generic NHibernate wrapper with transactionality

My team and I wrote the following Nhibernate wrapper which gives generic retrieval and save/update functions and a possibility to send a function as a paramater which may contain several save/update ...
6
votes
2answers
141 views

Generic wrapper for equality and hash implementation: Is there a way I can make it more efficient?

I was writing an answer in another thread and came across this challenge. I'm trying to have a generic class so that I can delegate the routine (and tiring) Equals and GetHashCode implementation to it ...
1
vote
1answer
66 views

How to simplify code for display member functions?

For my display functions in my Blackjack game, I want to control each player's stats output based on whether a turn is in progress or has ended. Normally, you could only see one card that your ...
2
votes
1answer
140 views

Is this implementation of Kruskal's algorithm maintainable and efficient?

Update I've posted some updated code and included the definition of Vertex and Edge to try to answer as many questions as I could. To summarize what's changed: I've followed the advice here to ...
0
votes
3answers
122 views

I need help improving this design for easy unit testing - C#

I am very new to unit testing, I only read a few chapters from 'Art of Unit Testing' and know how to write basic unit tests. I have a deadline for a project so I plan to read 'Professional Test Driven ...
2
votes
1answer
94 views

Improve Program Design

I am new to C++ and looking to expand my knowledge. Below is a simple program that I made. I would like to know how it could be improved, in any way. The introduction of new ways to do things is what ...
1
vote
0answers
34 views

How do I structure my entities for easier persistence?

I am learning ORM using Hibernate by creating a movie rental application. Currently, I have the following three entities for persistence: User Movie Rental (composite element for many-to-many ...
3
votes
1answer
362 views

asp.net (vb.net): handling of open database connection and calling shared function from web api

I'm working on an ASP.NET project using VB.NET that uses Dapper and the code as implemented so far runs fine with just me testing. In the example below, Dapper calls a stored proc. But my I am ...
0
votes
3answers
50 views

Implementation of an UniqueIdentifier class

I have a requirement to implement a generic UniqueIdentifier which can cover identifiers like OrderId, TrackingID, scannableId and other Ids. The ids, as they are now, are either Long or String. Below ...
6
votes
2answers
213 views

Efficent way of synchronizing between data

I'm currently working on a project where I have a punch of raw data and multiple components that use that data for various tasks. I would like to separate the raw data from the components as much as ...
1
vote
0answers
25 views

Is this a good approach for a BayeuxClient class?

Is this a good approach for a BayeuxClient class? Reading cometd reference book, Chapter 6 Java Libraries, I created this BayeuxClient class. As a newbie to cometd, I would like to know if this ...
1
vote
2answers
129 views

Multi-threaded Winforms Conventions for Main()

I'm trying to find a good pattern for new applications (and for refactoring old ones). Maybe it's just me, but I dislike spawning my main logic thread from inside my main form thread (so far I always ...
1
vote
2answers
174 views

Database calls with Python Flask and SQLAlchemy

I am creating a Python Flask webservice and this is basically how I am doing all of my database calls if a webservice needs to interact with the database: @event.route("/somepath/<value>", ...
5
votes
4answers
259 views

Command line Contact Management

Can you please review the following code and give any suggestions for improvment? Class ContactList.java import java.io.*; import java.util.*; public class ContactList { public static void ...
0
votes
1answer
61 views

Appropriate separation of concerns for this case?

This is a method that calls a web service, it uploads an audio file and fetches metadata back. While the advantage is that there is only one method to call there are a few concerns about it : There ...
8
votes
1answer
317 views

Thoughts on my brain fart interpreter?

Had some free time this weekend and I hacked together a small Brainfuck interpreter, with the sole intention of explaining PHP's flavour of OO to a friend. This is a bit over-engineered on purpose, ...
1
vote
2answers
81 views

Simple SPI Master

I wrote a simple SPI Master implementation to send characters to a LCD screen. Only the output is actually implemented in this so there is no rx register. This only sends a character out when write is ...
2
votes
1answer
54 views

Is there a better way to translate a string into methods?

So I create 3D tree like structures using L-systems. Basically this means I generate a string like this: "FFFFFFFF-[[FFFF-[[FF-[[F-[[X]+X]+F[+FX]-X]+F]]]]]" This string is then interpreted by a ...

1 2 3