A design pattern is a general reusable solution to a commonly occurring problem in software design.

learn more… | top users | synonyms (1)

4
votes
1answer
53 views

How to prevent multiple form submissions when user reloads the page

I'm currently working on a project which requires that we integration a 3rd party SOAP API to handle a number of basic CRUD type operations. Our current implementation allows us to leveraging the ...
-1
votes
2answers
87 views

Advantages of these recommendations in ooprogramming using Java

Below are the recommendation from section 5.1 of this essay. While Java is not a pure object-oriented language, it is possible to program in a pure object-oriented style by obeying the following ...
1
vote
1answer
43 views

DTOs vs Domain Models and invoking Command Handlers directly

I was just hoping someone might be able to answer a few questions I have regarding the proper design of DTOs and Domain Models. I'm currently working on a project which involves leveraging a SOAP API. ...
1
vote
1answer
34 views

Is this a Model or a ViewModel?

In a login screen, a user may expose his username and password data. The same way, in a user list screen, it may expose user name, age, and phone. But none of this views may expose any other user ...
1
vote
2answers
81 views

Joshua Bloch Enum Singleton and Third Party APIs

In the book Effective Java he give the best Singleton pattern implementation in his, that is implement by a Enum. I have doubt to how to implement this pattern with a third party API. I'm using an ...
1
vote
1answer
33 views

How to use DataMapper pattern methods, when loading data from database?

How do I use DataMapper Pattern? I can use it as a glorified Database Access Object, aka TableGateway (loading a single class from a single database table), or I can use it more to drive business ...
3
votes
1answer
75 views

Creating an interface just to decouple from third party libraries

I'm currently developing the Authorization module on a framework of mine. I have the following class so far: public interface IAuthorizationManager<C> where C : ...
0
votes
1answer
67 views

How to authenticate against an API?

In a enterprise distributed system, a user of a web portal can sign into one site, be redirected to a federation provider. Once they log in with, for example, a facebook account, that user is ...
2
votes
1answer
88 views

Python Classes and Design Questions

What is the best way to design a class to see if an update occurs on a property? I have a whole bunch of classes, and current am going through a re-design of the python package I created. ...
-4
votes
0answers
31 views

Best design for a SQL API - no antlr please [closed]

As a programming exercise, I'd like to explore creating a simplified sql like api to query csv files. Parsing the files is no problem. My concern is with design. What's the best way to design the SQL ...
4
votes
2answers
197 views

Is this too much work for a Gateway to do?

I'm writing a Gateway class that wraps access to a web service which provides information about a player's item inventory in a video game. This web service returns a variety of information, however I ...
3
votes
1answer
154 views

Single source of truth within an enterprise distributed system

Within an enterprise distributed system I have many services - an ecommerce service, a CRM, support desk, finance, billing. Many of these services share common data, such as Customer data. These ...
2
votes
2answers
112 views

Does it break SRP to have concerns of data handling and object mapping inside a single class, as part of the DataMapper pattern?

Summary I want to look into separating the concern of "creating a populated object from database", to use inside my application. DataMapper pattern seems to be doing just that for me. DataMapper ...
-1
votes
3answers
112 views

What design pattern is this? [duplicate]

I'm struggling to come up with the name of a design pattern that I need to write about. I've been lead to think it was abstraction but apparently not. Let's say I had a driver class which has a Drive ...
9
votes
4answers
313 views

Reducing boilerplate in class that implements interfaces through composition

I have a class: A that is a composite of a number of smaller classes, B, Cand D. B, C, and D implement interfaces IB, IC, and ID respectively. Since A supports all the functionality of B, C and D, A ...
3
votes
1answer
130 views

Design: .NET web app architecture problem

I'm taking my first foray into .NET and I'm designing a web app that's heavy on other web services right now. I'm intending to do the following: Take user input (a USDOT number) Request data from a ...
1
vote
1answer
111 views

How to avoid tying these two methods together with global mutable state?

I'm in the process of reading Code Complete 2 and learned that using global state is a no-no. What can I do to avoid using global state in this situation? Some background information: I have two ...
1
vote
1answer
112 views

Design Pattern - Adding features to a class

I'm finding myself unable to solve a design problem. For the sake of my simplicity, I'm going to use C# (Web API). Let's say I have an abstract class RestController: public abstract class ...
0
votes
0answers
64 views

Pattern to share fields in inheritance

I'm trying to figure out the best way to solve a design issue. I have to be able to clone (I'm cloning them to Apache HttpClient) different types of HttpServletRequest (POST, GET...) and then send ...
3
votes
0answers
36 views

Android: Pattern for checking requirements at startup?

My app's launcher activity checks a bunch of requirements like whether GPS is enabled, there's a network connection, the app has device administrator privileges, etc. Some of these checks display ...
1
vote
1answer
33 views

Filtering additions to a list

Hopefully Iʼm posting this in the right SX, and Iʼve tagged it correctly. I have a legacy system that Iʼm making additions to which contains a custom list object. This list object can contain two ...
1
vote
3answers
75 views

Design question concerning extensibility

I am constructing a new class which handles deciding which class should process the requests from a web service. I'm looking for a solution for a problem that I am having regarding extensibility with ...
4
votes
2answers
72 views

Returning a slimmed down domain entity from your view model

I'm wondering how to handle a ViewModel in the traditional sense, which includes both properties and methods, and another "view model" which is simply just the properties -- perhaps the ViewModel ...
1
vote
0answers
92 views

What design pattern best suits managing handles to objects, without passing handles or Manager around?

I'm writing a game in C++ using OpenGL. For those that don't know, with the OpenGL API you make a lot of calls to things like glGenBuffers and glCreateShader etc. These return types of GLuint which ...
4
votes
1answer
101 views

Separate interface for mutation methods

I've been working on refactoring some code, and I think I may have taken the first step down the rabbit hole. I'm writing the example in Java, but I suppose it could be agnostic. I have an interface ...
2
votes
4answers
152 views

Design Pattern for retry and error handling

I'm trying to find a good design pattern, or perhaps series of patterns, for injecting error handling and retry handling when getting data from a webservice. For instance, I have: do { //get the ...
3
votes
1answer
98 views

Nested POJOs, exposing collections, detecting changes

I have a couple plain object classes to represent data read from a file. They look something like this: public class Command { private String name; private List<Message> messages; } ...
3
votes
0answers
47 views

When applying the interface segregation, should you separate interfaces for regular setters and mathematical operations?

When applying the interface segregation, should you have separate interfaces for a straightforward setters and interfaces that perform an operation before setting? For example, say you have a class: ...
5
votes
1answer
88 views

PHP: Injecting the same database connection into multiple objects

Suppose that there are two classes that define objects of vastly different function such that in the datastore, the information they require is divided into two separate databases. For example, the ...
0
votes
1answer
50 views

Efficient way to handle foreign keys

I am building a script that checks a large network of sites for invalid links. The idea is to flag links that continuously show as not available so that they can be cleaned by the administration team. ...
2
votes
2answers
167 views

Has-A or Is-A or some strategy pattern?

I am developing a web based application which is about tracking Fleet units. Actually i have already developed the system but in the last six years things changed a bit. Ordinary the software ...
2
votes
1answer
74 views

Expandable alternative to Visitor pattern for tree traversal?

I have a tree containing various subtypes of the my base node class. I now want to traverse this tree and do something with the nodes depending on their type. The most straightforward idea is to just ...
1
vote
1answer
79 views

OO Design: Algorithm changing State (Information Flow Question)

I have a class Context, which contains an instance of an abstract class State, which has multiple concrete subclasses (this is an implementation of the State Pattern). Each State subclass executes a ...
1
vote
0answers
32 views

Adding fields a good use case for EAV? [duplicate]

Is being able to add fields quickly to a system a good use case for EAV? What would be the frequency or number that would justify using an EAV model?
2
votes
2answers
41 views

WCF service with methods to fetch data

I'm planning on building a WCF service that will fetch data entities from a Sql Server database. And I'm currently struggling with best practices issues. The thing is that there's a few different ...
2
votes
0answers
47 views

What's the best pattern to validate a conditional entity? [duplicate]

I'm developing an ASP.NET MVC 5 website and I have a view with a grid. In this grid I have a column which represents an URL property. This url is a link to download some files, but this url should be ...
0
votes
0answers
45 views

Whats the best way to implement DataMapper design pater and lazy loading (ghost object)

I'm doing a small project and I wanted to keep it simple to mantain. It is a renting management software. To keep it clean I decided to implement the data mapper patern, to keep the domain objects in ...
4
votes
4answers
163 views

Using a one-shot class to store not-quite-global variables

I sometimes find myself writing classes (in Python, in my case) that are used like this: MyClass(some_args).go() In other words, there's only one method in the class that any external code would ...
2
votes
1answer
169 views

Injection, strategies and OO

I'm working on refactoring a project. The business logic looks very much like using the Strategy pattern would be very beneficial, because depending on the values of three properties (let's say age, ...
6
votes
6answers
686 views

What are the most used pattern to manage a lot of interconnected parameters?

I recently start to work on an application that drive different measurement device. Before the user start a measure, she sets the parameters of it. Actually, considering all measurements type there ...
1
vote
2answers
117 views

A Factory could be replaced by a key on the web.config? How would be the trade-offs of each approach?

The Problem We had a Environment class which would choose whether or not to use a webservice (it was set by a web reference) for our authentication methods by reading the host environment and if it ...
2
votes
2answers
118 views

Abstract Property In Base Class To Force Programmer To Define It

I'm coding with a state pattern for an embedded device. I have a base/abstract class called State and then each discrete(concrete) state class implements the abstract State Class. In the State Class ...
4
votes
3answers
147 views

Should dependency inversion be used only with Adapters everywhere?

As I understand the purpose of DI is that I can easily swap a lower level implementation. But it forces the lower level abstraction to be defined inside the higher level. A lower level becomes ...
0
votes
0answers
26 views

Graph curve and actual curve plotted on screen implementation patterns

I'm implementing a graph plotter. There are Curve objects, that contains points of actual XY data. When I plot to screen, I need to calculate the XY points on screen, resulting a PlottedCurve. This ...
1
vote
2answers
380 views

Class becoming God Object what pattern to use

I am developing Android app and my MainActivity is becoming God Object. By the way native Activity class implementation is some sort of God Object already. The problem is that my activity class is ...
0
votes
2answers
104 views

in trouble making a card game with pygame

I am designing a card game playable against the computer. The rule is very simple Both player and CPU gets 10 cards of 1 to 10. Player and CPU plays a single card at the same time, every round. The ...
5
votes
3answers
153 views

Design Pattern - DLL per Strategy

I usually found myself designing my application in the following way: One DLL containing interfaces for a desired subsystem. For example, Company.Framework.Persistence.dll. One new DLL per each ...
1
vote
1answer
152 views

Best solution to switch between new and deprecated code

We have a feature that is currently implemented, let's call it implA. ImplA works but can't do many things. So we have decided to rewrite it. But we can't just replace it right away, so we will need ...
0
votes
0answers
46 views

Command Pattern for Logging/Backup/Testing

I need your input guys on this concept I intend to implement: Use the Command Pattern to record everything in my app. It should encapsulate every single user action and micro-action as a Command and ...
1
vote
1answer
76 views

Design pattern for mapping data fields

I have seen this problem a few times and never can come up with a solution i like. System A Sales Order Entity order_id created line_items_count System B Sales Order ...