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

learn more… | top users | synonyms (1)

2
votes
1answer
183 views

Beginner Facade Pattern Example

I came across this article: http://didawiki.cli.di.unipi.it/lib/exe/fetch.php/magistraleinformatica/tdp/dp-l10a-facade2014.pdf At the end, it has a question asking: One common problem ...
1
vote
2answers
80 views

C# Subject Observer Architecture question

I'm making a C# application using the Subject Observer design pattern in a slightly different way. I am passing the Provider Class, implementing IObservable (this has the OnNext() method that ...
1
vote
2answers
74 views

Pattern for validating rules having different signatures

I have a class in charge of responding to an input event and maybe triggering another event. To decide, it has several rules to check. I'm trying to get away from a class looking like this: public ...
0
votes
0answers
24 views

Accessing intermittently available resources with transactions and post-access cleanup in a generalized, functional, composable way

The following psuedo-code illustrates what I'd like to be able to do. Is there a way to accomplish something like this in Scala?: trait IntermittentlyAvailableResource trait ...
3
votes
3answers
126 views

Development Time: sql in UI code vs domain model with datamapper

First, sorry for my English guys. Currently this is my first programming job. I am labeled as the most incompetent programmer in my company that's because they measure the performance and ...
0
votes
2answers
92 views

Beginner Decorator Pattern Question

I came across this article: http://sourcemaking.com/design_patterns/decorator After reading it, I am having a little bit of difficulty understanding a concept. If you look in the Structure section in ...
0
votes
0answers
72 views

To KISS or not when coding? [duplicate]

I don't consider myself "ninja" but I don't think I'm bad dev either. Anyway, after many years of development I tend to keep it simple more ofthen than before. For small projects there is no need to ...
0
votes
1answer
80 views

Multiple method calls in the constructor and dependency injection

I was asked to refactor some almost ureadable spaghetti code into object-oriented architecture. I have some doubts regarding a class that I designed. Here is the class' skeleton: require_once ...
0
votes
1answer
81 views

Can you refer to the callback function as an API?

A system design is decoupled into two layers say layer A and layer B. The interaction between layer A and layer B occurs through an interface that is exposed by layer B in form of an API. This ...
0
votes
0answers
53 views

Abstracting the data in a relational database. [duplicate]

While working with data, which is in a relational database I came up with this issue. At first, I was just writing helper functions to retrieve A SPECIFIC data I needed for the current problem but it ...
0
votes
0answers
58 views

Angular Architecture

I have been developing a few prototype apps in Angular, with various backends, including firebase and php/mysql. I'm pretty sure I'm not using a good organization pattern for development because of a ...
1
vote
2answers
87 views

Rich Domain Models, Encapsulation, and the Problem of Constructor Over-Injection

I am refactoring an e-commerce web-application, currently working on the UserBasket class, which will have to handle adding or removing items, changing their quantity, getting total amount, total ...
2
votes
2answers
94 views

For a concrete SQL Repository, should I encapsulate the SQL logic inside or outside the repository methods?

If I have a concrete repository based on SQL data access, should I pass in SQL to the repository methods or encapsulate them within the methods. I feel if I pass them in, then I am coupling my ...
-2
votes
2answers
59 views

What should I call my repository methods? [closed]

In my database, I have 2 tables (ColorHeader and ColorDetail) and I have two views, one for each table (ColorHeaderView and ColorDetailView). I insert/update/delete into my tables and read from my ...
6
votes
1answer
163 views

Should I build undo stack in model or its wrapper?

I am building an application (Python/PyQt). The first-order item will be a tree view/model with many helper functions to add new items, move them around in the tree, etc.. Then I will have a main ...
0
votes
1answer
28 views

Tags DB structure - tags table using one join and GROUP BY, or pivot (join) table using two joins?

I'm implementing tags into my question and answer application. Users will be limited to the tags available by the app, so they can't choose their own. So maybe only 30-50 tags will be available. This ...
0
votes
1answer
111 views

How much to encapsulate when objects being dealt with are pretty similar

As I have been answering questions related to object-oriented design and how to go about reducing the amount of classes to make sure that there is not a lot of "class clutter" and code repetition I ...
1
vote
1answer
149 views

What is better repository design?

I have tables that I insert, delete and update, but I read from views. At times, I may read from the tables as well. What is a better generic interface for a Repository: public interface ...
0
votes
1answer
54 views

How can I refactor this c# repository code? [closed]

I have a couple questions on how to create my repository classes. I will give an example of the type of data that I am working with. I am considering using Dapper or PetaPoco, but that shouldn't ...
1
vote
2answers
81 views

Class design for JSON serialization

I've been stuck for some time on a circular reference issue with JSON serialization. I have a card game that I'm pickling to a redis store. As I retrieve the Game state from redis I'm trying to ...
4
votes
1answer
105 views

What is the preferred way to approach this problem in object-oriented design? - virtual disks abstraction

I am writing a program that manipulates encrypted virtual disks and encrypted flash drives (eg. importing disks into my application, mounting/unmounting, changing passwords etc.). I am still new to ...
-1
votes
0answers
44 views

Flux pattern for .net [closed]

I'm learning React JS, which is a javascript library created by Facebook. For larger scale applications, it is highly recommended to use the Flux pattern/architecture. The issue is that all the ...
4
votes
2answers
229 views

What principle is violated by having a button do two radically different things or screens act radically different depending on the situation

I've come upon a situation several times in my career when previous developers have done something funny. They will make a control (button) function radically different depending on how the screen ...
0
votes
0answers
59 views

What is the design pattern name for a class that handles 2nd level caching? [duplicate]

I have a system where I want to start introducing some 2nd level caching. I want to abstract data access a bit and allow some type of other class to do the dirty work of fetching a DTO; it will check ...
3
votes
3answers
502 views

How to model state of leaving/entering home

I have two sensors: One detecting if the door is open or closed, another if movement has been detected in the corridor. I want to detect if the person has left or entered home. Usually the person has ...
0
votes
0answers
63 views

Plugins with code that runs only once [closed]

I don't know exactly how to ask or define this question so it may be a duplicate but I haven't found anything yet. I'm working on a project in Javascript (browser extension) that requires plugins, ...
16
votes
5answers
3k views

Do enums create brittle interfaces?

Consider the example below. Any change to the ColorChoice enum affects all IWindowColor subclasses. Do enums tend to cause brittle interfaces? Is there something better than an enum to allow for ...
3
votes
3answers
211 views

How granular should we get with repositories?

Is it better to have a repository per model (this could be a class that represents a table from the database) or should just have one big repository for all data access methods? I have done the ...
5
votes
2answers
159 views

Sharing state with dependencies - Object-Oriented Design

Suppose that I define two interfaces below: public interface IReader { void Read(string bookName); } public interface IWriter { void Write(string bookName); } Now I want to implement ...
-1
votes
1answer
58 views

How is the UnitOfWork pattern related to Monadic programming?

Looking over the definition of the Unit of Work pattern it seems very much like what a programmer would get if they implemented a Monad such as an IO or Transaction Monad. What makes the unit of work ...
3
votes
1answer
67 views

Do conditional delegation or different member types break the Composite pattern?

Here's how I understand the composite pattern: In the composite pattern, a root object is composed of objects which may be further composed. Moreover, to be considered composite, all those objects ...
-1
votes
1answer
26 views

Extracting client specific code. refactoring possibilities required

I am facing a Design problem. I have a set of classes which writes data in XML,JSON or HTML formates for different clients. I have a class which receives Data and a XML, JSON or HTML writer as it ...
0
votes
0answers
14 views

Extracting client specific code. refactoring possibilities required [duplicate]

I am facing a Design problem. I have a set of classes which writes data in XML,JSON or HTML formates for different clients. I have a class which receives Data and a XML, JSON or HTML writer as it ...
1
vote
1answer
152 views

Is SICP still relevant? [closed]

Today, I came across this book entitled:The Structure and Interpretation of Computer Programs I read the Table Of Contents and it really interests, me. It seems to be exactly what I've been looking ...
0
votes
1answer
67 views

Are there any strong reasons to use DI for sub-classes that are known to be tightly coupled to their parent containers?

I have Product classes for Products A through Z. And each Product class has its own set of product-specific subclasses, which I'd say are tightly coupled to them, like so: //specific product class ...
1
vote
2answers
71 views

Is there a better pattern for a form object populating itself in 3 different ways?

So I'm writing a form object that deals with a specific thing - price - which is going to be included in several different underlying resources. (The Price is a separate model that may or may not need ...
0
votes
1answer
45 views

designing domain model that can handle large number of data filters?

I'm currently working on a project that I came into several years after it was built. The code is mostly procedural with a few objects that act more like buckets of functions than anything else. I ...
14
votes
6answers
3k views

Is logging next to an implementation a SRP violation?

When thinking of agile software development and all the principles (SRP, OCP, ...) I ask myself how to treat logging. Is logging next to an implementation a SRP violation? I would say yes because ...
0
votes
0answers
74 views

What is the relationship between “flux” and pure functional reactive programming?

Flux, as far as I understood, is a technique about dealing with the dataflow of an application unidirectionally, keeping state isolated from the rest of the program in read-only, self-contained ...
1
vote
1answer
120 views

Decorater pattern or strategy pattern

I'm constructing a c# serverside application and I'm trying to do this in a way it can easily be maintained aswell as extended if needed. So what we have is 4 different requests that need to be done ...
5
votes
3answers
408 views

Is Functional Programming a viable alternative to dependency injection patterns?

I have recently been reading a book entitled Functional Programming in C# and it occurs to me that the immutable and stateless nature of functional programming accomplishes similar outcomes to ...
0
votes
1answer
35 views

Client-Server Application Object with child Objects

Actually I'm going to build an Client Server Application, at the Login I recive the User Object from the Server. An user has a List of tasks, but I don't want to load them at the Login. So what would ...
2
votes
3answers
344 views

When do programmers use code first approach?

This is just not related to asp.net mvc but rather related all the mvc frameworks that support code first approach. One of the advantages I often see on asp.net mvc and tutorial blogs is that it ...
0
votes
1answer
116 views

Where should the following business logic be written?

I have a C# console application. This application has many different projects/C# class files, each of them dedicated to parsing a certain kind of XML and creating an object, called 'Response'. Now, ...
7
votes
4answers
547 views

Is the Single Responsibility Principle applicable to functions?

According to Robert C. Martin, the SRP states that: There should never be more than one reason for a class to change. However, in his book Clean Code, chapter 3: Functions, he shows the ...
0
votes
1answer
137 views

Program to look at the first say 5 characters of a word and return a string if that string is actually the first 5 characters of a word?

For example, say I have a string and it has the letters: RDNAL This is not an actual English word or it doesn't start an actual english word, so the program would skip this string and would avoid ...
1
vote
2answers
140 views

Implementing an anti-corruption layer with domain logic

I'm building an application that compiles a single PDF document from multiple source PDF documents as follows: it takes the first page of each source document, stamps certain information on top of ...
0
votes
2answers
78 views

Class design and object references

Here is a very basic example of what I am trying to do. In reallity there are more relations but not something extreme or memory heavy. public class ClassA : ISomething { public double property ...
14
votes
5answers
2k views

If Else - Repeated Code Logic

My boss gave me a project with a particular logic. I have to develop a web page which has to lead the navigator through many cases until he/she arrives at the product. This is the path scheme of the ...
0
votes
2answers
101 views

Definition of the NHibernate Mapping by Code / EF Code First pattern?

Sub-questions: Does this pattern have a formal definition? Who invented it? Is it considered a DSL? The reason why I am asking is because I would like to better assess its applicability to ...