A design pattern is a general reusable solution to a commonly occurring problem in software design.
0
votes
0answers
39 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
164 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 ...
0
votes
1answer
35 views
How to present a stable data model in a public API that allows internal data structures to be changed without breaking the public view of the data?
I am in the process of developing an application that allows users to write C# scripts. These scripts allow users to call selected methods and to access and manipulate data in a document. This works ...
2
votes
1answer
128 views
Is there a Design Pattern for preventing dangling references?
I was thinking about a design for custom handles. The thought is to prevent clients from copying around large objects. Now a regular handle class would probably suffice for that, but it doesn't solve ...
0
votes
0answers
78 views
What's the best way to expose a Model object in a ViewModel?
In a WPF MVVM application, I exposed my model object into my viewModel by creating an instance of Model class (which cause dependency) into ViewModel. Instead of creating separate VM properties, I ...
-2
votes
1answer
54 views
Is there a name for trying out different strategies until one accepts? [on hold]
I occasionally think about a problem as trying out a list of different strategies until one succeeds. For example, in loading data, the first strategy might try to load a piece of data from a local ...
2
votes
4answers
178 views
Callbacks: when to return value, and when to modify parameter?
When writing a callback, when is best to have the callback return a value, and when is it best to have the callback modify a parameter? Is there a difference?
For example, if we wanted to grab a list ...
1
vote
0answers
41 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 ...
36
votes
2answers
3k views
What is the “Free Monad + Interpreter” pattern?
I've seen people talking about Free Monad with Interpreter, particularly in the context of data-access. What is this pattern? When might I want to use it? How does it work, and how would I implement ...
1
vote
1answer
33 views
Handling Types for Real and Complex Matrices in a BLAS Wrapper
I come from a C background and I'm now learning OOP with C++. As an exercise (so please don't just say "this already exists"), I want to implement a wrapper for BLAS that will let the user write ...
0
votes
1answer
75 views
Does my use of the strategy pattern violate the fundamental MVC pattern in iOS?
I'm about to use the 'strategy' pattern in my iOS app, but feel like my approach violates the somehow fundamental MVC pattern.
My app is displaying visual "stories", and a Story consists (i.e. has ...
4
votes
4answers
98 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 ...
0
votes
0answers
17 views
Many ui panels needs interaction with same object
I am developing a tool for simulating systems like the Gray-Scott model (That is systems where spatial distribution depends on time). The actual model is loaded from a DLL or shared object and the ...
-1
votes
2answers
152 views
Help with MVC design pattern? [on hold]
I am trying to build a java program for user login but I am not sure if my MVC design is accurate. I have the following classes:
LoginControl - servlet
LoginBean - data holder java class with ...
0
votes
2answers
172 views
How to design console application with good seperation of UI from Logic
Is it considered an overkill for console application to be design like MVC , MVP or N tier architecture? If not which is more common and if you can link me to simple example of it.
I want to ...
5
votes
3answers
182 views
How to refactor my design, if it seems to require multiple inheritance?
Recently I made a question about Java classes implementing methods from two sources (kinda like multiple inheritance). However, it was pointed out that this sort of need may be a sign of a design ...
1
vote
1answer
187 views
Confused about implementing Single Responsibility Principle
Please bear with me if the question looks not well structured.
To put you in the context of my issue:
I am building an application that invoices vehicles stay duration in a parking. In addition to ...
0
votes
2answers
98 views
What are the benefits of using a 'decorator factory' that decorates objects?
In a project I decided to implement the Decorator pattern.
I have a class Thing with methodA(), and a class AbstractDecorator that inherits from Thing and that all decorators inherit from: ...
-1
votes
0answers
39 views
Single or multiple return statements in a function [closed]
When writing a function that can have several different return values, particularly when different branches of code return different values, what is the cleanest or sanest way of returning?
Please ...
19
votes
4answers
2k views
Builder Pattern: When to fail?
When implementing the Builder Pattern, I often find myself confused with when to let building fail and I even manage to take different stands on the matter every few days.
First some explanation:
...
1
vote
2answers
120 views
Flags with deferred use
Let's say I have a system. In this system I have a number of operations I can do, but all of these operations have to happen as a batch at a certain time, while calls to activate and deactivate these ...
9
votes
2answers
202 views
Using packages (gems, eggs, etc.) to create decoupled architectures
The main issue
Seeing the good support most modern programming platforms have for package management (think gem, npm, pip, etc), does it make sense to design an application or system be composed of ...
6
votes
1answer
89 views
Restructuring a large Chrome Extension/WebApp
I have a very complex Chrome Extension that has gotten too large to maintain in its current format. I'd like to restructure it, but I'm 15 and this is the first webapp or extension of it's type I've ...
2
votes
1answer
170 views
Best practice to collect information from child objects
I'm regularly facing following pattern:
public abstract class BaseItem
{
BaseItem[] children;
// ...
public void DoSomethingWithStuff()
{
StuffCollection collection = new ...
0
votes
0answers
30 views
NCurses, scrolling of multiline items, “current item” pointer and “selected items”
I am looking for hints/ideas for the best (most effective) way on how to scroll multi-line items as well as emphasizing of the "current item" and "selected items" such as:
1 FOO ITEM
1 Foo sub-item
...
0
votes
0answers
71 views
Is this considered an implementation of the Template Method design pattern?
Please consider a StringBank class. This class holds a list of Strings and can return them to the client.
It's code (irrelevant stuff omitted):
abstract class StringBank{
List<String> ...
3
votes
1answer
140 views
Does this Decorator implementation violate the Liskov Substitution Principle?
Please consider the following implementation of the Decorator design pattern:
WordBank objects store strings and return them to the client through the method getWords().
The decorator class, ...
1
vote
2answers
165 views
global try-catch in presentation layer
I have a 3-layered app structured as follows.
Presentation Layer (ASP.NET MVC project)
Business Logic Layer (Services for controllers in PL)
Data Access Layer (Repositories)
Each Controller in PL ...
-2
votes
0answers
90 views
What design patterns should be used when trying to design a database like system? [closed]
I have a project that requires me to simulate a database using files and the scope is to prove knowledge of design patterns.
The fact is that i have found uses for mvc pattern (general pattern), ...
2
votes
1answer
289 views
A small project but I want to use design patterns to do it right
I've got a project coming up, a very a small system, but one that needs to be extended in the future.
Here's how I've designed it so far.
It's 3-tier: presentation, business and data.
For the ...
0
votes
2answers
210 views
Why don't we completely de-couple frontend JS frameworks and backend APIs? [closed]
Whenever we implement a frontend framework in the likes of Backbone, AngularJS etc. there's an integration process involved with the backend technologies like NodeJS, Rails, Yii etc. (like setting up ...
1
vote
2answers
207 views
Correct way to inject dependencies in Business logic service?
Currently the structure of my application is as below
Web App --> WCF Service (just a facade) --> Business Logic Services --> Repository -> Entity Framework Datacontext
Now each of my Business logic ...
0
votes
0answers
52 views
Is this an acceptable implementation of the Adapter pattern? [migrated]
I've used the UK Plug -> US Socket and US Plug -> UK Socket analogy. I've also made it possible for UK plug to use a UK socket and a US plug to use a US socket. The output of the SSCCE below is
...
-1
votes
0answers
39 views
Design Suggestion on Project as given below [closed]
I am battling with too many thoughts to design a Project code Architecture.
Technology: Microsoft.NET- MONO.
Project Details:
This is having a UI layer which has not much but Simplistic UI. I am ...
-2
votes
1answer
43 views
Real world example of Strategy or this uses a Factory instead? [closed]
I have a class RoleStrategy which would assign a role to the employees depending upon the authorization of that employee. Let there are three roles in the system - ManagerRole, TeamLeadRole, ...
0
votes
7answers
325 views
Using a Simple/Static Factory vs. instantiating directly: new Thing() vs. factory.createThing() - what's the benefit?
Here are two ways to instantiate an object:
Option 1:
Thing thing = new Thing();
Option 2: (the factory is a Static Factory, but it could also be a Simple Factory).
Thing thing = ...
0
votes
1answer
58 views
Algorithmic Forecasting and Pattern Recognition
Say a user could enter project data into my software. Each project has 2 variables "size" and "work" and they're related but the relationship is not known. Is there a way to programmatically determine ...
-1
votes
1answer
133 views
Correct pattern for Worker Processes involving Queues & Tables
Edit:
OK, so, people said it is unclear what I am asking. I am asking for feedback on this design. Here is an example user story:
As a group admin on the website I want to be notified when a user in ...
0
votes
1answer
41 views
Restricting object types that can be added to each other using the Composite Pattern
The Situation: I am building a custom PHP application framework. I have implemented a composite pattern so I can build a object tree representing the page to be rendered. Example:
abstract class ...
-4
votes
1answer
99 views
How is the Decorator Pattern actually used in practice? [closed]
I understand completely how to implement the Decorator pattern, and I also understand what it's intent is.
The Decorator is used in one of two cases:
As an alternative to subclassing - when there ...
0
votes
2answers
131 views
Is using interfaces on internal code a good idea? [duplicate]
I'm working on a set of automated tests that we use internally at work. Lately, we've been designing classes that implement interfaces in addition to inheritance.
As I understand it, interfaces in ...
0
votes
1answer
135 views
pattern to share objects between API and application
I'm having serious doubts about the design for my Web application.
I wanted to separate the business logic from the interface so I made a Web API that handles all the requests to the database.
It's ...
2
votes
1answer
131 views
Adapter Pattern: Design Patterns
So far as I know, there are two forms of the Adapter Pattern: the class adapter and the object adapter. Could someone please explain to me the following limitation of the class adapter and why it is ...
0
votes
0answers
18 views
Organizing an image processing pipeline for on-the-fly video analysis
I'm trying to design a system that performs image analysis on video streams from the internet. I have a few rudimentary ideas for how to organize such a system, and I was hoping you guys could ...
3
votes
1answer
76 views
Access items of a container with a pattern
I've two C++ classes with a relation: a container class which has a list of items. For example a library has got many books. The classes are the library and the book.
Now from the external world I ...
2
votes
1answer
83 views
What's the right OO way to create a counter/inventory class that works for both differentiated and undifferentiated countables?
You are writing a videogame about trading beans. Red beans, black beans, pinto beans, you name it. As everybody knows all beans are the same. You write the "Inventory" class for a trader in that ...
0
votes
0answers
57 views
Build a map with city blocks and road
Is there a design pattern or well known algorithm to build a simple map with roads and city blocks?
To have an idea of what's my target i describe some of the constraints and the context:
a matrix ...
2
votes
1answer
17 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 ...
2
votes
2answers
203 views
What do I gain by using the Strategy pattern in this case?
I wrote a program with Java that plays simple music. Currently chords have only one way ('strumming pattern') to be played. I want to expand this and create different 'strumming patterns' that chords ...
0
votes
1answer
64 views
MVC: Where should I store interchangeable algorithms used by the Model (whose names also need to be accessible to the View)?
Please consider a program, where the user chooses an algorithm from a list, and the Strategy pattern is utilized to set this algorithm as the model's operation.
For example, an image procession ...