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

learn more… | top users | synonyms (1)

1
vote
1answer
81 views

Choosing between the view and the controller for my code

I'm aware there are a lot of topics about MVC design but it's hard to find good explanations: what I should do, what are the consequences of the different possibilities... So I'm working on an ASP ...
-1
votes
0answers
34 views

Basic PHP Factory Pattern code review

I have an object, KbArticle, that originally in it's constructor, would try to return null if the SQL query that retrieves the data for its required properties came up with 0 rows. A friend told me ...
5
votes
5answers
1k views

Is this a good practice or not?

I have a colleague who has come up with a way of 'genericizing' information from a database so that all his web application's drop-down lists can share the same object in his MVC.NET C# code and ...
2
votes
2answers
61 views

subclass reference to another subclass

Imagine I have the following code: class A: pass class B(A): pass class C(A): def __init__(self): self.b = B() Is the above code correct in terms of correct inheritance? I ...
2
votes
1answer
76 views

What is a good strategy to develop apps that run in console and as API?

I develop quite often scripts that are primary used as a console application but later they are used in other scripts, webservices and other things where it is very convenient, to just import the ...
1
vote
5answers
154 views

Coupling business logic with class definitions

Perhaps it is my scripting background, but my perspective is that the purpose of an object should be to contain data. Classes are necessary in that they provide templates and standard ways to classify ...
4
votes
3answers
414 views

What is a helper? Is it a design pattern? Is it an algorithm?

Maybe a little tongue-in-cheek, but as I can't find this answer anywhere through Google, so to ensure Programmers Stackexchange has the answer: What is a helper? I see the name being used everywhere ...
1
vote
1answer
82 views

Repository pattern implementation that knows nothing (Jon Snow) about the database table and column names

I've seen around the Internet and Github, implementations for the design pattern Repository that knows about database table and column names. I was think, if I want to work with the database as a ...
0
votes
1answer
68 views

Confused on how to properly employ a Repository Pattern with Service/Business Layer on top

I'm building a ASP.NET Web Api 2 solution for learning purposes, and I've hit a snag. I was wondering if anyone could tell me what exactly it is that I'm missing. My Web Api solution has 4 Layers: ...
1
vote
1answer
53 views

Adding new functionality to all of shelve.Shelf's subclasses in Python

In order to avoid the overhead associated with the shelve module's writeback option I'm interested in putting together a shelf class that only accepts hashable values, with hashability being a proxy ...
0
votes
0answers
74 views

Result Object vs. Exceptions

Related to this question I posted earlier: Returning results of method on batch list? I stumbled across an interesting idea at: https://www.braintreepayments.com/docs/java/general/result_objects ...
4
votes
3answers
67 views

Returning results of method on batch list?

The title is a bit vague so I'll try to elaborate. I have a function makeFoo(int bar) -> returns Foo or throws Exception. I also have a batch version of this makeFoos(int[] bars) -> ...
1
vote
1answer
89 views

Freeing Memory: Observer Pattern?

I am building a scientific application in matlab which handles several hundred large matrices (large as in 'very few of these will fit into ram'). Each matrix is contained within a dedicated object to ...
1
vote
0answers
94 views

MVC content management framework with an admin panel

I've lately been developing my own MVC content management system using PHP and, at least in my mind, am a little stuck with the system design. I believe this would apply to building a content ...
1
vote
1answer
69 views

Implement Generic DataSet Builder with C#

I want to create a data access library that can build a DataSets with relations which can easily be written to XML with dataset.WriteXML(). This is a get to know C# endeavor that will hopefully gain ...
0
votes
0answers
74 views

How to design extension mechanism for java app

I have an application where I have a set of core features. The application itself HAS to work in core only mode. I would also want to make the application extensible such that, when certain ...
-5
votes
0answers
94 views

Real world Programming [closed]

When starting a new project are design patterns useful way of coding for rapid prototyping (small scale projects) or are they for production (full blown projects) or for all cases?
0
votes
2answers
83 views

Select design pattern - user stage

I'm struggling to point a finger into the right design pattern. I have a web site which user can register and interact with the system. I want to add the following abilities to a user: Each user ...
0
votes
0answers
7 views

Select design pattern - user stage [duplicate]

I'm struggling to point a finger into the right design pattern. I have a web site which user can register and interact with the system. I want to add the following abilities to a user: Each user ...
0
votes
1answer
22 views

Store Arbitrary values related to mysql record

I have created an app that manages a Data cleansing workflow. Each row imported needs to store an arbitrary number of key value pairs in addition to our standard mysql schema. The key values need to ...
2
votes
3answers
434 views

Functional programming strategies in imperative languages

I've been convinced for awhile now that some strategies in functional programming are better suited to a number of computations (i.e immutability of data structures). However, due to the popularity of ...
0
votes
1answer
70 views

DTO - service layer - statelessness best practices interfering with each other

I am designing a REST API coupled with a service layer that takes DTOs as input and produces them as output. This works fine for most service calls where the DTO is used to access an underlying ...
2
votes
1answer
182 views

Design Patterns for creating tasks

I am developing software where each action in my entities need create tasks that will be execute in my infrastructure. When I create a task it is only records in the database. Afterwards, a windows ...
0
votes
2answers
143 views

Good architecture for passing data to multiple APIs

I have a hypothetical scenario where I need to pass data to APIs from multiple different providers, depending on the 'vendor identity' provided by one of the pieces of data. If I have the data as ...
0
votes
1answer
66 views

Implement RPC via SIP

Look at the following use case. I have a client (Java) application, which wants to get/set the state of another, remote application (C). The communication between them is done via SIP, which is run ...
0
votes
0answers
25 views

API providing function to be run in a thread vs. thread that runs this function

I'm writing a Python library which exposes a certain event listener interface. The user can register callbacks to handle different types of events. There is also a function which handles the actual ...
3
votes
2answers
229 views

Is the Java Integer cache a realization of the object pool pattern?

One of the best-known examples of a full-fledged object pool is the JDBC connection pool. Main reasons: objects in the pool are expensive to create and relate with external resources each object in ...
0
votes
0answers
28 views

update methods in simple factories

I have simple factory class with differently named methods which create the same object but differently. These created objects are persisted to db. These are then retrieved from the db elsewhere and ...
-1
votes
1answer
144 views

All programming functions always return to the If or If/Else statement? [closed]

After learning, coding, and coding even more than ever now, I have noticed a trend in a lot of programming which I do. The trend is that the majority of my functions are if{} or if{} else{} statements ...
3
votes
1answer
47 views

Pattern to use to relate multiple data sources to different user data widgets

I have an client x server intranet application the basically gets data from the server, format it and send that data to the client for display. At the server we are using ASP.NET C# running on IIS ...
2
votes
1answer
147 views

Working with a large, messy object [duplicate]

I have been handed a very cluttered, "One Ring" object (one object to rule them all). The OR class has 40 fields. These fields map to 16 different objects (the OR has all the fields from the 16 ...
2
votes
2answers
246 views

Reduce number of if statements through design pattern

I had a loop through object Process, each process instance can be of a different type, derived from Process base class (e.g.: Process1, Process2,...). Each derived type of Process has different ...
-2
votes
4answers
224 views

What is the name of this design pattern? [closed]

I have been using this "design pattern" (may or may not be an "official" design pattern) for a while and I wanted to know if it had a name (so that I could name my classes after it). Example in PHP ...
0
votes
1answer
135 views

Why is the “app” folder now a (more) common pattern in web projects?

It might be related to the Yeoman project, or they might have adopted this from somewhere else, but it seems to be the default for all of their generators. Aside from Yeoman generators I've also ...
1
vote
1answer
50 views

PHP - Repository matrix pattern?

I'm trying really hard to refactor some of my legacy code in the project using best practices and design patterns + DDD so I'd love some feedback on an issue I'm currently having. Let's assume that I ...
1
vote
0answers
30 views

How do I differentiate between old and new data in backbone collections?

A common pattern I come across is a backbone collection which is initially seeded from a database. However, the user can also add to the collection. When the user does add to the collection, these ...
35
votes
11answers
4k views

Are error variables an anti-pattern or good design?

In order to handle several possible errors that shouldn't halt execution, I have an error variable that clients can check and use to throw exceptions. Is this an Anti-Pattern? Is there a better way to ...
0
votes
2answers
132 views

Expected error handling

Let's say I have a social media website. On this website, users can upload several pieces of information about themselves, including their phone number. To implement this, I have a class called ...
1
vote
1answer
72 views

Should state machine with synonym states be shown explicitly?

I am new to state machine modeling and while trying to model a system, I have a question. An example will explain it better: Considering a system that does calling (probably a customized cell phone ...
0
votes
1answer
140 views

Technical example of modeling a domain with OOD?

Considering favoring composition over inheritance and looking at various design patterns there are multiple approaches to modeling a domain. Say you have some Entities which are very similar in some ...
1
vote
1answer
64 views

Need to provide an interface (for plugins) for taking input Type A, and returning output Type B

public interface IMyInputProviderPlugin { IMyOutput Provide(IMyInput data); } This is an interface I need to provide so that I can dynamically load the dlls and not have them bound to my ...
0
votes
0answers
46 views

How to cleanly write a multi step process with user feedback and multiple callback

When you have some process that has several steps and you multiple entry points the code gets ugly pretty fast. I encountered this with Facebook integration in my mobile app: User wants to share ...
0
votes
1answer
60 views

delegating program logic to lower-level objects

I'm writing a library for use in scientific computing and ran into a bit of a quandary. The types at work here are a class M which consists of some data and a reference to a container class C. There ...
2
votes
1answer
80 views

Testing complex compositions

I have a rather large collection of classes which check and mutate a given data structure. They can be composed via the composition pattern into arbitrarily complex tree-like structures. The final ...
0
votes
0answers
53 views

Android From Local DB (DAO) to Server sync (JSON) - Design issue

I sync data between my local DB and a Server. I'm looking for the cleanest way to modelise all of this. I have a com.something.db package That contains a Data Helper and couple of DAO classes that ...
0
votes
0answers
37 views

What should a domain object's validation cover?

I'm trying to figure out how to do validation of domain objects that need external resources, such as data mappers/dao Firstly here's my code class User { const INVALID_ID = 1; const ...
5
votes
1answer
305 views

Why use Android Fragments?

I have read the documentation and some other questions' threads about this topic and I don't really feel convinced; I don't see clearly the limits of use of this technique. Fragments are now seen as ...
2
votes
1answer
87 views

How do you show the exception handler in a class diagram?

I have one exception handler class. I want to show this class in the uml -- class diagram. But, I do not know how to represent relationship between class <X> and exception handler class. How can ...
0
votes
0answers
60 views

does class reference itself static anti pattern in prism

I have an application and my desing approach look like this: class Manager { public int State; static Manager _instance = null; public static Manager Instance { get { return ...
3
votes
3answers
205 views

is it valid that a state machine can have more than one possible state for some transition?

I have a requirement for a workflow which I am trying to model as a state machine, I see that there is more than one outcome of a given transition(or activity). Is it valid for a state machine to ...