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

learn more… | top users | synonyms (1)

2
votes
2answers
366 views

Repository pattern implementation that knows nothing 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 ...
20
votes
8answers
2k views

How did separation of code and data become a practice?

Please read the question carefully: it asks how, not why. I recently came across this answer, which suggests using a database to store immutable data: It sounds like many of the magic numbers you ...
0
votes
2answers
128 views

Is there a better way to load objects?

I have always kept the code to load an object within the object itself. That way no matter what method is creating the object, it always has access to the method to load the object. However this does ...
4
votes
5answers
2k 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 ...
1
vote
5answers
225 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
682 views

What is a helper? Is it a design pattern? Is it an algorithm? [closed]

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 ...
2
votes
1answer
147 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 ...
2
votes
2answers
82 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
93 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 ...
41
votes
5answers
3k views

When is Singleton appropriate?

Some hold that the Singleton Pattern is always an anti-pattern. What do you think?
4
votes
3answers
99 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
77 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 ...
2
votes
1answer
374 views

What is the good way of sharing specific data between ViewModels

We have IAppContext which is injected into ViewModel. This service contains shared data: global filters and other application wide properties. But there are cases when data is very specific. For ...
36
votes
11answers
5k 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 ...
6
votes
1answer
1k 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
105 views

Use adapter pattern for coupled classes

I need (for unit testing purposes) to create adapters for external library classes.ExchangeService and ContactsFolder are Microsoft's implementations in its' EWS library. So I created my adapters that ...
1
vote
0answers
382 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
212 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 ...
2
votes
1answer
367 views

Javascript Implementation Patterns for Server-side MVC Websites

I'm looking for information on common patterns for initializing and executing Javascript page by page in a "traditional" server-side MVC website architecture. A few months ago, my development team ...
1
vote
1answer
106 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 ...
0
votes
0answers
11 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
2answers
94 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 ...
51
votes
2answers
5k views

Are there any OO-principles that are practically applicable for Javascript?

Javascript is a prototype-based object oriented language but can become class-based in a variety of ways, either by: Writing the functions to be used as classes by yourself Use a nifty class system ...
2
votes
1answer
226 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
1answer
54 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 ...
4
votes
3answers
525 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 ...
2
votes
3answers
631 views

design practice for business layer when supporting API versioning

Is there any design pattern or practice recommended for business layer when dealing with multiple API version. For example, I have something like this. http://site.com/blogs/v1/?count=10 which ...
1
vote
1answer
322 views

Android design advice - services & broadcast receivers

I'm in the process of learning the Android SDK and creating some projects to get a grasp on the system. The current project I'm working with works just fine but I'd like to get some advice about ...
0
votes
2answers
169 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
86 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 ...
3
votes
2answers
277 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
30 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 ...
0
votes
0answers
32 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
168 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 ...
7
votes
6answers
1k views

Should I extract specific functionality into a function and why?

I have a large method which does 3 tasks, each of them can be extracted into a separate function. If I'll make an additional functions for each of that tasks, will it make my code better or worse and ...
0
votes
1answer
151 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 ...
6
votes
8answers
2k views

How to split large, tightly coupled classes?

I have some huge classes of more than 2k lines of code (and growing) that I would like to refactor if possible, to have some more light and clean design. The reason it is so big is mainly because ...
2
votes
2answers
329 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 ...
0
votes
1answer
164 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 ...
2
votes
1answer
169 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
4answers
262 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 ...
4
votes
5answers
136 views

Preferred way for dealing with customer-defined data in enterprise application

Let's say that we have a small enterprise web (intranet) application for managing data for car dealers. It has screens for managing customers, inventory, orders, warranties and workshops. This ...
1
vote
0answers
80 views

Processing a list of atomic operations, allowing for interruptions

I'm looking for a design pattern that addresses the following situation: There exists a list of tasks that must be processed. Tasks may be added at any time. Each task is wholly independent from all ...
0
votes
2answers
140 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
0answers
35 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 ...
1
vote
1answer
87 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 ...
2
votes
2answers
339 views

How to avoid duplication of code related to shared entities in the repository pattern?

I'm building a repository for a large CRM schema that has a high number of relations between entities. Some of the entities are referenced by almost all entities, e.g. Person and Company. Where I ...
1
vote
1answer
67 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
68 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 ...
2
votes
1answer
88 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 ...