FAQ Database Discussion Community


“is not abstract and does not override abstract method java” using Decorator Pattern

java,design-patterns,override,decorator
public abstract class AdicionalesCpd extends Cpd{ public abstract int getCpu(); public abstract int getRam(); public abstract int getDisco(); public abstract String getCadena();} This my abstract class for the decorator pattern, and I have this problem when it compiles: **error: Cpu is not abstract and does not override abstract method getCadena()...

How to set data context of ViewModela View's xaml?

c#,listview,design-patterns,mvvm,windows-universal
I'm trying to set the data context of a View to the list contained in it's ViewModel. But when I've tested the current set up, it seems the data context between the ViewModel and View is set incorrectly. To debug this issue I set up a message box in the...

What are the differences between Flyweight and Object Pool patterns?

design-patterns
It seems to me that Flyweight and Object Pool patterns are very similar. Both have pools of objects leased to clients. What are the differences?

Pattern / best practice for accessing connection that has undeterministic set time

java,design-patterns
Below code attempts to get a connection every 5 seconds. The getConnection method returns true or false depending on random double and is for illustrative purposes. The time it takes to get a connection cannot be guaranteed so if fail to initially get connection, wait 5 seconds and try again....

Bounded Contexts Rules Orchestration

design-patterns,domain-driven-design,business-rules
My banking core domain has divided into 2 distincts bounded contexts BC1 and BC2. These BCs deal with very specific business rules and processes (custom agreement for debt recovery, and administrative indebtedness with legal obligations). BC1 and BC2 are accessed through WebServices from a CRM. A client can't have both...

How to Implement Singleton Pattern without Nullable

design-patterns,singleton,hhvm,hacklang
I am trying to implement the Singleton pattern in Hack. However, I keep running into issues with Nullable. <?hh //strict class Foo { private static Foo $foo; public function __construct() { // Do stuff here. } public static function theFoo(): Foo { if (null === self::$foo) { self::$foo = new...

Builder pattern where to apply [closed]

java,design-patterns
Hi I have a doubt on builder design pattern.From the pluralsight videos I understood that this pattern is used to avoid the complexity of telescopic constructors in mutable classes. Some other sites explain it as a way to develop or construct complex object by keeping builder as a composition.I am...

React Flux dispatcher vs Node.js EventEmitter - scalable?

node.js,design-patterns,reactjs,flux,eventemitter
When you use Node's EventEmitter, you subscribe to a single event. Your callback is only executed when that specific event is fired up: eventBus.on('some-event', function(data){ // data is specific to 'some-event' }); In Flux, you register your store with the dispatcher, then your store gets called when every single event...

Java sharing objects by multiple threads - design pattern needed

java,multithreading,oop,design-patterns,sharing
I would like to get some advice on a simple multithreading system I am designing. The idea: The application is capturing frames and displaying them in 1st imageview. These captured frames are also being processed (by MyHandDetectionThread) and then displayed in 2nd imageview. My solution: public class VideoManager { private...

Javascript chaining and passing arguments

javascript,jquery,design-patterns
I have read a lots about chained functions in JavaScript, somehow I am really confused if it is possible to pass an argument across the chain. My main goal is to recreate a "jQuery like" behavior passing the first argument of a function when on chain. Here is a rough...

Interpretation of an interface driven implementation of the observer pattern in Java

java,swing,java-ee,design-patterns,observer-pattern
I am studying the observer pattern implemented in Java and I have some doubts about how the tutorial implementation exactly works. I know that this pattern is used in all the situation that expect the user interaction with a GUI (for example the user click on a button) or all...

Avoiding use of instance of:

oop,design-patterns
I'm writing a simple game where we have a collection of objects where a player moves around on a grid, collecting coin and avoid monsters. My class structure looks as follows. Game Controller - Responsible for spawning coins and tracking game state Grid - A class which stores the objects...

Construct the name of the method to be called at runtime

java,design-patterns,reflection
I'm learning Java and I'm fairly new to this. Here is my problem with some pseudocode: public void objectCaller(int objectNumber) { switch(objectnumber) { case 1: object1.setFill(color.RED); break: case 2: object2.setFill(color.RED); break; . .and so on } } Is there a way to replace it in a way with something like...

Design Pattern for handling interrupt data

c,design-patterns
I am developing a firmware application implemented in C, and I want to know what is a good design pattern for this kind of problem: In main loop, I will get interrupt when I received data from a device using UART communication I would send a AT command and wait...

Request Aggregator / Middle-tier design pattern for costly requests

java,c#,multithreading,design-patterns,zeromq
I'm working on a program that will have multiple threads requiring information from a web-service that can handle requests such as: "Give me [Var1, Var2, Var3] for [Object1, Object2, ... Object20]" and the resulting reply will give me a, in this case, 20-node XML (one for each object), each node...

IOC containers: de-duplicating the configuration code

java,spring,oop,design-patterns,inversion-of-control
I am using spring framework for 2 different applications. Let's say both of the applications talk to one single MongoDB database. Following is how I configure MongoDB in both the applications: @Configuration @PropertySource("file:/etc/x/y/mongodb.properties") public class MongoConfiguration { @Autowired private Environment env; @Bean public UserCredentials mongoCredentials() { String mongoUserName = env.getProperty("mongodb.username");...

Keeping track what the state parameters are

c#,design-patterns,flags,states
I'm refactoring software that is created by my predecessor. The software can communicate over the can-bus. At this moment all devices are hardcoded in the software and my job is to make every deviceType configurable. (Saved in serialized classes and creatable with a Model creator). With the software, the devices...

lisp: dynamic scope vs explicit parameter passing

design-patterns,coding-style,common-lisp,anti-patterns,dynamic-scope
I see two different patterns for "output" functions in (common) lisp: (defun implicit () (format t "Life? Don't talk to me about life!")) (defun explicit (stream) (format stream "This will all end in tears.")) (defun test-im-vs-ex-plicit () (values (with-output-to-string (stream) (let ((*standard-output* stream)) (implicit))) (with-output-to-string (stream) (explicit stream)))) Is using...

Patterns for decorating private methods of a class

c#,design-patterns,decorator
In the below class I have a public method called ProcessMessage. This method is responsible for processing the incoming messages. Processing a message involves different stage. I want to decorate this class in such a way that I can publish performance counter values from each stage of the message processing....

Writing a test data builder with syntax

c#,.net,design-patterns,builder-pattern
Is it possible to write a TestDataBuilder which follows a given syntax? So for example: I know how to write a basic builder for a car that's not the problem. But how can I achieve, that I can only add new windows to a door? So this is allowed: var...

undo / redo software pattern for split merge

design-patterns,software-engineering
I have a somewhat complex piece of genomics software where I allow undo and redo operations. If I have an element A, I can move it to A0, A1, A2, A3, etc. and move it around to any point in its history. This is easy. What I'm trying to figured...

DTOs with different granularity

java,spring,hibernate,design-patterns,dto
I'm on a project that uses the latest Spring+Hibernate for persistence and for implementing a REST API. The different tables in the database contain lots of records which are in turn pretty big as well. So, I've created a lot of DAOs to retrieve different levels of detail and their...

Some doubts related this Swing MVC implementation. Opening a database connection should be a Controller task?

java,swing,design-patterns,model-view-controller,architecture
I am following a Java tutorial related to the implementation of the observer pattern (using Swing) and I have some doubts. My doubts are not related to the observer pattern but about the architecture of this tutorial application (that is based on something like an MVC logic) So it contains...

event driven pattern for writing chunks to a file - JS

javascript,design-patterns,file-io,webrtc,event-driven-design
I'm trying to transfer a file over WebRTC, and I'm struggling to figure out a good pattern for writing data as it's coming in. Since file chunks will be coming in at an unknown rate, I need to be able to write each chunk as it becomes available; this means...

variable global const “macros” in C++ and optimal design patterns

c++,design-patterns,mfc,const,global
I inherited some 10 year old code I have to complete. The code is in MFC (C++). There's a .h file where the custom data structures are written and some const variables are in there as Globals. Some of these are used for MS Office file extensions, of type CString,...

replace simple factory using polymorphism

java,design-patterns,refactoring,factory-pattern
I am trying to replace the simple factory StatsCreatorFactory.java class in order to delete the stink multiple use of switch case statements. This is my situation: StatsServlet.java public class StatsServlet extends HttpServlet{ private static final long serialVersionUID = 1L; protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { StatsContext...

Seperating interfaces and making them more generic

c#,.net,design-patterns
I have an interface to define my records\models public interface IStockItem { string Code { get; set; } string Description { get; set; } decimal FreeStock { get; set; } } Is it best to put the actions into another interface? public interface IStockExport { IEnumerable<IStockItem> GetAll(); IEnumerable<IStockItem> GetStockByCode(string code);...

Segmentation fault in list of objects

c++,design-patterns,vector,segmentation-fault,copy-constructor
I didn't thought that this would be so hard, but I have the following program: In a multithreaded environment (using the ACE-Framework and OpenMP) I use the Observer pattern. In the init-routine of the Observer-controller-thread (ActiveObject) I create a vector of ConcreteObservers (for notifying them with their discrete job) like...

Static Constructor and singleton

c#,design-patterns,singleton
My friend told me that the following is one of the ways to create singleton design pattern in C# public class class1{ public static class1 Obj { get; private set; } static class1() { Obj = new class1(); } } He told me that the static constructor runs only one...

Does getInstance() denote a singleton according the singleton pattern?

java,design-patterns
Having worked with C# before, I have considered Calendar cal = Calendar.getInstance(); to be a singleton method according the GoF Singleton pattern (Wikipedia) and I wondered how to create two calendars, since Dateis somewhat deprecated. From the documentation Gets a calendar using the default time zone and locale. and the...

JavaFx table view, table gateway pattern and join

java,design-patterns,javafx
For working with data from database I implemented table data gateway. So, I have two tables: CREATE TABLE student ( id INT, id groupId, name VARCHAR(100), surname VARCHAR(100) ); CREATE TABLE group ( id INT, name VARCHAR(100) ); And I have two DTO. It's strictly that one DTO for one...

Assigning methods to object at run-time - Design Pattern

c#,.net,design-patterns,properties,lazy-loading
I have created an architecture in my C# code which does exactly what I want, but seems it would be very difficult to maintain in the long-run and am hoping there's a design pattern / better architecture I could be pointed towards. I have created an object Test which, again,...

Design Pattern for Context-sensitive representation

java,design-patterns
Question Is there a design pattern that allows me to create a context-sensitive representations of classes? Definition Representation: the available getters, and the values they return. Context: the request context of the object. Example A site publishes houses for sale. A guest user has House.getPrice(), which returns 100,000 for house...

Java immutability when defining members in a function called by constructor

java,class,design-patterns,design,immutability
I have class like this: abstract class Parent { protected Parent(Raw rawData) { deserialize(rawData); } protected abstract void deserialize(Raw rawData); } class Child extends Parent { final byte firstByte; public Child(Raw rawdData) { super(rawData); } protected void deserialize(Raw rawData) { firstByte = rawData.getFirst(); } } So basically any child class...

Swift - Issue trying to access to Singleton object

swift,design-patterns,ios8,singleton,apple
This is my first question on StackOverflow, I'll try to be specific. I am trying to implement the Singleton pattern on my app, without success so far. When I try to access to my Singleton, it seems that the program is not accessing the real singleton, but a copy of...

How to return result while applying Command query separation (CQS)

c#,design-patterns,cqrs,command-query-separation
I am separating my query and command on service side like this: public class ProductCommandService{ void AddProduct(Product product); } public interface ProductQueryService{ Product GetProduct(Guid id); Product[] GetAllProducts(); } Command Query Separation accepts that a method should change state or return a result. There is no problem. public class ProductController: ApiController{...

Sharing controller between views

python,design-patterns,model-view-controller
I have a frame which holds 2 views. I want to use a common controller for both of them but not instantiate 2 controllers. How do i achieve this? Singleton? Send the controller as an argument? Note, the controller will hold temporary data (bad idea?) that will be sent away...

Triggering events from async/await functions in the right order

c#,events,design-patterns,asynchronous,async-await
I have problems ensuring the order of events in my asynchronous task. The class from which other async tasks inherit has the following functions and takes the EventHandlers (ExecutionProgress, ExecutionStarted, ExecutionCompleted) in the constructor arguments: public abstract Task Operation(IProgress<EventArgs> progress); public virtual void Execute() { ExecuteAsync() } private void ReportProgress(EventArgs...

Is it possible to set up KVO notifications for static variables in objective C?

ios,objective-c,design-patterns,key-value-observing
I have class A, with instance variables deriving attributes from cached data, this cached data is represented as a singleton and is part of A (it's essentially a NSDictionary). From time to time, this cache is modified. When this happens, I would like to have all A instances pull new...

J2EE Outdated Design Patterns

java-ee,design-patterns
I'm writing a paper for my master degree on JEE Design Patterns. I'm using with it the solutions that Spring gives us. I was searching for any info on the web but didn't got to much of info, probably someone with more experience would be of any help? If anyone...

How to override some property in the class under test during unit testing

c#,unit-testing,design-patterns
I have a class that I would like to test with Unit tests. It has some logic to look for some values in the local xml file, and if the value is not found it will read some external source (SqlServer DB). But during Unit testing I don't want this...

How to handle this cycle dependency?

javascript,design-patterns,design
I have an design like this: UI Layer Component Layer. The idea is all event handlers like click, painting the dom will be hitting UI layer, which will call the corresponding component layer. Now imagine on click of a button, the ui layer calls component layer, so the dependencies looks...

What's the cost of using private class data pattern?

c++,oop,design-patterns,private-members
I used to have this as a TimeUnit declaration in a library: Solution1: typedef boost::posix::ptime TimeUnit; TimeUnit createTimeUnit( int hours, int minutes ); std::string toString( const TimeUnit& timeUnit ); Let's say I'd like to move this to something more object-oriented: Solution2: class TimeUnit : public boost::posix::ptime { public: TimeUnit( int...

Value Object vs Data Transfer Object

java,design-patterns,serialization,domain-driven-design,data-transfer-objects
I was a part of one of the project where we were producing java webservice and publishing into server. Some other java application was consuming the web service through extjs. In that producer application was following Domain Driven Design. We were using two types of pojos , Domain Objects and...

Design Pattern to only return certain LDAP attributes in an object

java,design-patterns,ldap
Let's say I have the following class, with many instance variables and corresponding getters and setters: public class Foo { private String a; private int b; ... private List<String> z; public String getA() { return a; } public void setA(String a) { this.a = a; } public int getB() {...

Developing a Swift iOS app “The Right Way”

ios,iphone,swift,design-patterns,solid-principles
Recently, I've learned Swift and the basics to develop an iOS app. Now, I want to develop a real application by my own, but I'm very concerned about writing good code, so I've looked up for "best practices", "design patterns" and "the right way" to achieve it. On my search,...

Converting ASP.NET MVC Standard application into N-Tier Application

c#,asp.net-mvc,design-patterns
I was working on a application for which i was using ASP.NET MVC. Then i came to know about n-tier architecture which i think gives more flexibility to the applications so i started converting my standard mvc project into n-tier. I also have role based views. Before asking this question...

Javascript pattern for library with dependencies

javascript,design-patterns
Sometimes I've come across a particular pattern present in some javascript libraries. Maybe it's a coincidence but I've seen it in libraries with dependencies. The syntax is as follows (The sample is taken from Backbone which has a hard dependency on underscore) (function(root, factory) { if (typeof define === 'function'...

Asp.Net MVC 4 view model and domain model ids

c#,asp.net-mvc-4,design-patterns,domain-driven-design,viewmodel
Our system runs on multiple servers. All the tables in our system uses GUID as the Primary Key and Foreign Key fields. This is however our old system and it it going through a brand new rewrite. The motivation to use GUID in the old system was for migration of...

Running code in a PHP once

php,design-patterns
I'm trying to write a class in PHP that acts as a wrapper for a collection of command line tools to make them easier to use from PHP. I have a single class (MyClass) in a file myclass.php. I have code that checks to see if the required tools are...

What is the proper way to use inheritance when combined with factory method?

oop,design-patterns
Given that I have 3 classes Asset, AssetA, AssetB what is the proper way to structure inheritance when using the factory method? Here is how I would like to use these classes: Asset.new(data) should deterministically create either AssetA or AssetB depending on some flag present in data Asset should also...

Segregating the read-only and read-write in Spring/J2EE Apps

mysql,jpa,design-patterns,architecture,spring-data
We using Spring, Spring-Data and JPA in our project. For production servers, we would like to setup database cluster such that all read queries are directed to one server and all write queries are directed to another server. This obviously will require some changes in the way the DAOs are...

Refactoring a concrete method in abstract class which contains an abstract method

c#,design-patterns,refactoring,abstract-class
Considering the below code, abstract class AbstractClass { public abstract void AbstractMethodA(); public void ConcreteMethodA() { //Some operation ConcreteMethodB(); } } public void ConcreteMethodB() { //Huge code unrelated to this class AbstractMethodA(); } } class DerivedClass : AbstractClass { public void AbstractMethodA() { //Some operation } } Now I wish...

Regular Expression differences between [] and ()

php,design-patterns,expression
How to understand about this Pattern? /^((?:\+?61)|0)(2((3[3789])|(4[0123456789])|(5[012356789])| (6[0123456789])|[789][0-9])|(3((3[234])|(4[012345789])|(5[0123456789])| (6[123457])|[789][0-9]))|(7(([23][0-9]|(4[0123456789]))|(5[234567])| (7[679])))|(8((2[56])|(5[123458])|(6[0123456789])|(7[0123456789])| (8[0123456789])|(9[0123456789]))))[0-9]{6}$/ How the square bracket[] and Parenthesis() differ from? ...

XML pattern to JS regex

javascript,regex,xml,design-patterns
I have a form that generate an XML file validated by a XSD schema. In the XSD there are a lot of rules (pattern attribute). For example, pattern: [\p{L}\d\s\.,\[\]\{\}€@#\-\(\)/='\+:\?!&quot;%&amp;\*;&lt;&gt;]* documentation : type A : all letters, all numbers, space, dot, comma, \[ \] \{ \} € @ # \- \(...

Where to apply domain level permissioning

design-patterns,permissions,authorization,onion-architecture,hexagonal-architecture
Permissioning/Authorization (not Authentication) is a cross-cutting concern, I think. In an Onion Architecture or Hexagonal Architecture, where should permissioning be performed? Examples of permissioning required would be: Filtering data returned to the front end (UI, API, or otherwise) Validating that a business operation can be performed at all Ideally, via...

Non-OS Specific FD(File Descriptor) for C/C++

c++,design-patterns,asynchronous,file-io,network-programming
Linux is also treated as a file, a network socket. but, Windows is not. and common files and network sockets treated as "FD". if the code should not rely on the operating system, how should write? i think it like below.. #ifndef INVALID_SOCKET #define INVALID_SOCKET (-1) #endif class Descriptor {...

Create an object that has methods deferred to a different object for execution [Python]

python,oop,design-patterns
To explain it and for simplicity, I will use the power domain example. Imagine that you have more than one equipment. All plugged in one power strip with multiple plugs. The power strip can be controlled via an Ethernet or some other means. Out of all these, there is one...

Publisher in Pub/Sub should be Synchronous or Asynchronous?

javascript,design-patterns,javascript-events,anti-patterns
My view on mechanism: Pattern wise publisher should just publish an event and should not care about listeners / subscribers for that topic / event. In case of JavaScript, lot of frameworks for Pub / Sub publishes event in Sync manner for example : framework just maintains map of event...

How to avoid duplicating implemented getter function in PHP

php,oop,design-patterns
While this question is about methods of solving this problem, I am particularly interested in good clean OO design and solutions that conform to current PHP best practices. Thanks in advance for taking a look. I have the following interface: <?php interface Tool { /** * Return the unique name...

Java Design Issue: Enforce method call sequence

java,oop,design-patterns
There is a question which was recently asked to me in an interview. Problem: There is a class meant to profile the execution time of the code. The class is like: Class StopWatch { long startTime; long stopTime; void start() {// set startTime} void stop() { // set stopTime} long...

MVP, JavaFx and components references

java,design-patterns,model-view-controller,javafx
I've studied all popular GUI patterns - MVP,MVC,MVVM and finally I decided to implement MVP (Supervising Controller). So I have the following OBJECTS(!). Stage<-View<->Model. It's important Stage!=View, it is another object. Between view and model data binding. Besides I have a presenter(controller) which handles all events and works with view...

Why there isn't library of design patterns?

java,oop,design-patterns
I'm new to design pattern subject. If design pattern are so great, why can't someone build a library of them so I don't have to create them in each application?...

Domain Model with Event Sourcing

.net,design-patterns,cqrs,event-sourcing,event-driven-design
Silly question...but why do I need a Domain model at all if I use event sourcing. I have (an Event Bus of course) and Application Services with business operations that each send a Command after basic validation Command Handlers which receive Commands perform additional Command validation and publish Events Event...

How to extract business logic in this example

design-patterns,logic,structure
The following method filters a data collection based on order statuses. Im wondering what would be the best way to extract the business logic held within about the order statuses. For example, say the order statuses were to change down the line i.e. ('in_transit', 'at_courier') then this method, and associated...

Perl: Keep only one of two consecutive characters

regex,perl,design-patterns
I'm having trouble applying a regex to keep only one of two specific consecutive characters in a column. I have the following file in which C-O appears for number 1 and number 2, as indicated. I would like to write a new file in which only C-O in number 1...

What's wrong when not using singleton pattern

java,design-patterns,singleton
I'm reading about the singleton pattern from my ebook (Head First Design Patterns), and I know that using this pattern is suitable in case you need only one instance of some class. But I have a little trouble with the problem introduction in this ebook. (Yeah, I think I can...

Functionality of as-pattern, non overlapping pattern through 'as pattern'

haskell,design-patterns,overlapping-matches,as-pattern
I am new to functional programming and haskell in particular and have two questions abound as-pattern and the reduction of overlappings through using it. Giving the following code example: last1 :: [a] -> a last1 [x] = x last1 (x:xs) = last xs last2 :: [a] -> a last2 [y]...

Send error from doNext block?

ios,objective-c,design-patterns,reactive-cocoa,overcoat
I'm using ReactiveCocoa and Overcoat/Mantle/AFNetworking to fetch data and authenticate a user from a RESTful API. This is the code in the login view controller that manages the login button and textfields for credentials: @weakify(self); self.loginButton.rac_command = [[RACCommand alloc] initWithEnabled:validCredentials signalBlock:^RACSignal *(id input) { @strongify(self); return [[PFUserManager sharedManager] logInUser:self.usernameTextField.text password:self.passwordTextField.text];...

State design pattern - Passing Objects

c++,design-patterns
I have a state design pattern implementation with 3 states: State1::DoTask(){...} State2::DoTask(){...} State3::DoTask(){...} These all 3 states need to use 2 classes already instanced e.g. State1::DoTask() { sensor->GetData(...) server->Send(buf,size) } How is the best way to pass these 2 class pointer objects to the State1, State2 and State3? I thought...

State pattern: Identify state class type from string

java,design-patterns,state
Background I have a command that uses the state pattern. When the command state changes I am notified in the UI that for example class stageOneState is now the active state. Is it bad practice to check the state class type using a string as an identifier? Is this undoing...

what object representation in builder pattern exactly means?

design-patterns
I'm a newbie for design pattern.I feel I missing some essential pieces in understanding Builder Pattern. what the object representation exactly means in this definition? THE BUILDER PATTERN: Separates the construction of a complex object from its representation so that the same construction process can create different representations. Is it...

how to get result which is returned with C callback in C++

c++,sqlite,design-patterns,callback
I am rather new to handle C callbacks in C++. I made a sqlite wrapper c++ class, which just calls sqlite3_exec(). static int callback(void *NotUsed, int argc, char **argv, char **azColName){ SqliteAccessor* sqlite = static_cast<SqliteAccessor*> NotUsed; if(argc > 0) { sqlite->set_table_exists(true); } return 0; } class SqliteAccessor{ public: bool has_table(const...

Decouple visualization methods and application [closed]

c++,design-patterns
this is my first question on SO, so please bear with me. We develop an application, which gathers data, and we have methods that let us visualize the data in various ways. With growing number of methods, we decided to separate the application and the visualization methods. I'm wondering what...

Can a java method return value depending upon condition?

java,design-patterns
I have a ICoreClient interface and AClient and BClient classes implements this. ICoreClient is exposed for users. I need to add a new method in ICoreClient interface. So, it needs to be implemented in both clients. I can not make this method generic as it has completely different signature but...

Design pattern for incremental code

java,design-patterns,code-design
According to the business logic, the output of one of the method is used as an input to another. The logic has linear flow. To emulate the behaviour, now there is a controller class which has everything. It is very messy, too much loc and hard to modify. Also the...

Angular: where should transitions among states be?

javascript,angularjs,design-patterns
Here's a design issue: I am making a web application with Angularjs, and I am trying to use the $stateProvider to model the routing of the sections within the app. Imagine I have two states, A and B, each one with its template and controller: .state('A', { url: "/A", templateUrl:...

Multi-threading list pattern advice

c#,wpf,multithreading,design-patterns,asynchronous
I have made an application which also contains a folder/file scanner. I'm coming across a problem with the threading structure. How it works: For each folder/file it finds it starts a thread. There is a function inside each thread that uses a list to check if a similar item has...

name of design pattern for below approach

design-patterns
I have open source code,my target was to add some functionality to this code without breaking the opensource structure. For example class OpensourceClass{ String getValue(){ return ""; } } so I created a interface int class and a instance of that interface is introduced in opensource class class OpensourceClass{ public...

Is there some kind of a design pattern that pushes for public statics methods?

php,design-patterns
I am wondering if there's a design pattern where every class has static public methods where you can just use them anywhere in the code. Is that kind of pattern considered safe if followed by some kind of known standard? Personally I use dependency injection, and the use of Namespaces,...

Conditional EventHandling

c#,design-patterns
I believe I have a design question and I hope to get your input. I made a small program to illustrate my question. Basically, my program consists of a radio system that gets heard on every room in the building. The sound is conditional on the receiving end, depending if...

Subtypes of an interface only compatible with a subtype of another interface

oop,design-patterns,design,architecture,solid-principles
I've been scratching my head for a long time on a problem and I still don't know what would be the best solution. Since the application domain is very technical, I'll illustrate my problem with a simple example. Suppose I have the following interfaces: public interface Animal { public void...

Data to be passed along with an event under Messaging pattern architectire

javascript,design-patterns,backbone.js
Is it a good idea to pass a model or a collection data in a message on every event. E.g. messageBus.on('someEvent',modelData); and the subscriber than receives the data. Or it is better to have kind of service (JS module) which would store and update the data on a model/collection throughout...

How do I pass data from presentation layer to business logic layer? (ASP.NET MVC 5)

c#,asp.net-mvc,design-patterns,n-tier,business-logic
I'm creating my first web application with ASP.NET MVC 5 and want to do it the right way. I plan on creating an architecture with a Presentation Layer (MVC), a Data Access Layer (DAL), and a Business Logic Layer (BLL). The DAL and BLL will be separate class libraries from...

How to design abstract listener and its implementation?

design-patterns,design,template-method-pattern
I have decided to split my application into 3 separate modules - one "abstract" with almost all application logic (anyone looking at the code can tell WHAT it does), one "implementation" module with all specific implementation layers (like db, connections, etc) and one small "runtime" module that maps implementation with...

reference data class member visitor pattern

c++,design-patterns,reference
I have a container class that has a plain old datatype called DataStore. This data store will be passed to visitor.They share a single copy since any updated performed by the container are to be seen by visitor. class xyz { //Plain Old Datatype typedef struct DataStore { //add any...

Implementing a Command Design Pattern with static methods C#

c#,design-patterns,design,static
I know how to implement a Command Design pattern as follows: public abstract class Command { public abstract void Execute(string someString); } Say I inherit this ,as an example: public class ConnectionCommand : Command { public override void Execute(string connectionString) { ...do some stuff here...; } } Problem is to...

Injecting an instance using Unity whose constructor parameter is not known

design-patterns,dependency-injection,unity,constructor-injection
I have an interface as follows public interface IDataProvider { List<string> GetData(); } Implementation of it public class TextDataProvider: IDataProvider { public TexDataProvider(string source){...} public List<string> GetData() {...} } One of my services uses IDataProvider to get data. Different implementations could be injected by changing the Unity Register method with...

Singleton as performance upgrade in access to database

c#,asp.net,design-patterns
I'm writting a .NET application that implements different design patterns. I have an idea to write singleton + flyweight pattern example. Let's imagine I have remote database with Pizzas & ingredients. My idea is to: on app start I would download all Pizzas and Ingredients and keep them in flyweight...

Generate CSV test data at random from template

design-patterns,design
I am going to have to generate many CSV files that will contain random-ish data. There will be rules about the fields, such as some will be integers, some should be names picked from a particular list, some will be text generated from a Markov chain with a given source,...

Should I used the Factory Method pattern?

design-patterns
I am developing an application that uses a combo box to select a version number. Depending on this selection a different subclass is to be instantiated and a method defined in the super class is to be called. I am having trouble deciding which pattern to use. Perhaps the Factory...

Flyweight pattern - Memory footprint

python,python-2.7,design-patterns,ubuntu-14.04,flyweight-pattern
I'm learning Python and I've thought it would be a nice excuse to refresh my pattern knowledge and in that case, the Flyweight pattern. I created two small programs, one that is not optimized and one is implementing the Flyweight pattern. For my tests purposes, I'm creating an army of...

Using design patterns in laravel 5

design-patterns,laravel-5,php-5.6
What are the design patterns that we can use in large projects with Laravel 5 ? is there any good tutorials or books to learn those design patterns ?

Multiple Dispatch: A conceptual necessity?

oop,design-patterns,polymorphism,dynamic-dispatch,multiple-dispatch
I wonder if the concept of multiple dispatch (that is, built-in support, as if the dynamic dispatch of virtual methods is extended to the method's arguments as well) should be included in an object-oriented language if its impact on performance would be negligible. Problem Consider the following scenario: I have...

Javaxfx: MVP (Supervising Controller) must view keep reference to presenter (controller)

java,design-patterns,javafx
I want to implement MVP (Supervising Controller) with JavaFX. I've studied several examples in internet and saw that view keep reference to presenter. Is this right? I thought that view should not know about presenter at all. There is biderectional data binding between view and model VIEW<->MODEL although view doesn't...

Fragment callbacks explosion, how to deal?

android,design-patterns,android-fragments,android-activity,callback
I am creating my app with using fragments. I have something like main activity, it has FrameLayout as root layout to hold fragments. After much thought I have decided to separate my application logic in several parts, for example : MainActivity is responsible for app basic navigation (MainPageFragment, CategoryListFragment, ProductListFragment,...

Problems implementing ViewHolder pattern

android,design-patterns
I'm working on an android app from a book. I'm getting errors : "crimeHolder cannot be resolved" and I can't understand why.. public View getView(int poisition, View convertView , ViewGroup parent) { //If we weren't given a view, inflate one if (convertView == null) { convertView = getActivity().getLayoutInflater().inflate(R.layout.list_item_crime, null); ViewHolder...

Design for a shop - multiple product classes

java,design-patterns
I was reading about Spring and encountered an example consisting of an abstract product class with name and price fields. Next, there is a Battery class which extends the Product class and adds a rechargable field. Then, a CDDrive class (also) extending Product but adding a capacity field. In the...

Domain Driven Design for Rails App: Implementing a service in a basic example

ruby-on-rails,ruby,design-patterns,domain-driven-design,component-based
Two Models: An Owner and a Dog: owner.rb class Owner < ActiveRecord::Base has_one :dog end dog.rb class Dog < ActiveRecord::Base belongs_to :owner end And here is the schema: schema.rb ActiveRecord::Schema.define(version: 123) do create_table "dogs", force: true do |t| t.string "name" t.integer "energy" t.integer "owner_id" t.datetime "created_at" t.datetime "updated_at" end add_index...

Design Pattern to handle bulk actions in c#

c#,design-patterns
I wonder is there any design pattern in c# to handle bulk actions similar to bulk state transition pattern which is in apex? I studied all types of Creational, Structural and Behavioral Patterns but didn't find any pattern in c# similar to that. Thanks for your time. For reference to...