2
votes
1answer
172 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 ...
1
vote
1answer
44 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 ...
3
votes
1answer
79 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 ...
0
votes
1answer
100 views

Traversing an AST using Visitors

I'm writing a compiler for a C-like language, and I'm looking for an elegant way to traverse my abstract syntax tree. I'm trying to implement the Visitor pattern, although I'm not convinced that I'm ...
0
votes
2answers
213 views

Can this argument be enough?

We have two C++ classes named Important and Small The class Small use a few methods and attributes from the class Important, but not all. Since our application is performance critical, instead of ...
0
votes
1answer
156 views

Interface questions for using Command Pattern and Dependency Injection together

I have many projects that have essentially the same high level requirement: test all hardware on a device. Each device can have a different communication protocol, requires different test equipment to ...
1
vote
5answers
628 views

How do I deal with global variables in existing legacy code (or, what's better, global hell or pattern hell)?

So... We have this fairly complex project (~10k LOC, but there's duplicated code so it's hard to tell) with hundreds of global variables. The project has more dependencies on other projects, and many ...
0
votes
2answers
258 views

Difference between Singleton pattern and auto_ptr<> resp. unique_ptr<>

I'm maintaining some legacy code of a physical simulation. The calculation object is build as a singleton, to ensure there is only one instance. A co-worker told me, that singleton are completely ...
0
votes
1answer
193 views

Does C++ support subtyping?

I know it might be a silly question to ask, but I didn't quite get an a absolute clear answer on this matter, so I thought I'd put it here. Does c++ support the subtyping in the sense that it ...
1
vote
2answers
302 views

Client-server application design issue

I have a collection of clients on server's side. And there are some objects that need to work with that collection - adding and removing clients, sending message to them, updating connection settings ...
1
vote
1answer
305 views

a lot of small objects - OO pasta [closed]

In the code I am working on, there are a lot of really small objects like: class HasFieldLameSetter { public: HasFieldLameSetter(field& p_):m(_p){} void set(bool p2) ...
3
votes
3answers
375 views

Alternative inheritance paradigms in object-oriented design

My apologies if a variation of this question has been asked before, but due to its nature it is hard to search for. I am having a discussion with a colleague about object-oriented design, and it ...
1
vote
2answers
215 views

Event based logging. Is it a good idea and is it ok to pass a handle to a “logged” object?

Hi I have fairly complex program that is doing computations in a quite large loop. I want to log some basic statistic about the run to be able to analyze its performance over time and vs loop number. ...
4
votes
1answer
302 views

Which parallel pattern to use?

I need to write a server application that fetches mails from different mail servers/mailboxes and then needs to process/analyze these mails. Traditionally, I would do this multi-threaded, launching a ...
-1
votes
1answer
360 views

How to reconstruct this application using design pattern

I am engaging in redesigning a linux c++ server application. The application acts as file relayer in the form of receiving file packets (incuding control packets and data packets) from client A, ...
7
votes
2answers
383 views

Database Facade to wrap our existing queries?

We have a very big application written in C++ using the MFC framework (millions of code lines). No need to say that it's a legacy system, but it's also heavily maintained and updated. This application ...
0
votes
2answers
156 views

How to design member access for an Article-type class? [duplicate]

I am doing a final project in a C++ class writing a very simple usenet-like client/server. I figure that since it's usenet-like I'll have a NewsGroup class and an Article class, I'm now working on my ...
10
votes
4answers
897 views

Command pattern design

I have this old implementation of the Command pattern. It is kind of passing a Context through all the DIOperation implementation, but I realized later on, in the process of learning and learning ...
1
vote
3answers
492 views

Is this Observer variant an improvement?

In a C++ code base I've been working on, they have a bunch of instances of the observer pattern, but it's a little different from the classical pattern. In the classic, the Observer is a specific ...
2
votes
2answers
186 views

Should I split out synchronization from my class and what's it called?

When thinking about testability and modular code, I recently thought about whether I should split out the synchronization part of a class from the actual behavior part. By example: The app "needs" ...
1
vote
1answer
276 views

Is this an implementation of the promise pattern?

I am writing a library in C++ (making use of many C++11 features) that (as far as I can tell) implements the promise pattern. The library consists of a class that makes asynchronous network requests. ...
11
votes
3answers
2k views

How to avoid “managers” in my code

I'm currently re-designing my Entity System, for C++, and I have a lot of Managers. In my design, I have these classes, in order to tie my library together. I've heard a lot of bad things when it ...
7
votes
4answers
498 views

Design pattern for polymorphic behaviour while allowing library separation

Let's say I have a hierarchy of Item classes: Rectangle, Circle, Triangle. I want to be able to draw them, so my first possibility is add a virtual Draw() method to each: class Item { public: ...
5
votes
4answers
728 views

Is there something like a polymorphic Singleton?

I have a resource loader object that loads objects from the disk or from a ZIP archive, depending on the platform. It has state (e.g. the path to the directory or the ZIP archive, and possibly some ...
2
votes
4answers
1k views

Good design pattern for a c++ wrapper around a c object

I have written an extensible c++ wrapper around a very hard to use but also very useful c library. The goal is to have the convience of c++ for allocating the object, exposing its properties, ...
1
vote
2answers
261 views

What is a useful pattern to maintaining an object state in a one to many relationship?

I am looking for a design for my application, here are the players(classes) involved. struct Transform { // Uses a matrix to transform the position. // Also acts acts as the state of a ...
3
votes
2answers
287 views

Clarification on the Strategy Pattern

I've just been reading through some basic design patterns, Could someone tell me if the term "strategy pattern" only applies if your implementing a completely abstract interface? What about when ...
2
votes
6answers
1k views

Learning good OOP design and unlearning some bad habits [duplicate]

Possible Duplicate: What books or resources would you recommend to learn practical OO design and development concepts? I have been mostly a C programmer so far in my career with knowledge ...
4
votes
1answer
791 views

Best Creational Pattern for loggers in a multi-threaded system?

This is a follow up question on my past questions : Concurrency pattern of logger in multithreaded application As suggested by others, I am putting this question separately. As the learning from ...
1
vote
1answer
723 views

How can I implement a database TableView like thing in C++?

How can I implement a TableView like thing in C++? I want to emulating a tiny relation database like thing in C++. I have data tables, and I want to transform it somehow, so I need a TableView like ...
8
votes
8answers
1k views

Is STL implemented with OO?

There are several design patterns like Adaptor, Iterator implemented in STL. Does that mean STL is implemented with OO concepts? What is the relationship between OO and template parts of C++? I ...
0
votes
1answer
169 views

The design of a generic data synchronizer, or, an [object] that does [actions] with the aid of [helpers]

I'd like to create a generic data-source "synchronizer," where data-source "types" may include MySQL databases, Google Spreadsheets documents, CSV files, among others. I've been trying to figure out ...
1
vote
1answer
398 views

Incorporating GoF design patterns in Objective-C without Abstract/Virtual classes

As someone who is becoming more comfortable working in Objective-C I would like to be able to incorporate more design patterns and OOP features in my projects but struggle to implement them as ...
1
vote
3answers
683 views

Pattern for Accessing MySQL connection

We have an application which is C++ trying to access MySQL database. There are several (about 5 or so) threads in the application (with Boost library for threading) and in each thread has a few ...
11
votes
2answers
2k views

Best overview to modern C++ paradigms?

I used to write C++ extensively between 8 and 10 years ago. I have since moved on to C# for professional reasons. However, from time to time I see statements like "If you're still manually ...
3
votes
3answers
662 views

Patterns for Handling Changing Property Sets in C++

I have a bunch "Property Sets" (which are simple structs containing POD members). I'd like to modify these property sets (eg: add a new member) at run time so that the definition of the property sets ...
3
votes
2answers
637 views

Lazy Processing of Streams

I have the following problem scenario: I have a text file and I have to read it and split it into lines. Some lines might need to be dropped (according to criteria that are not fixed). The lines ...
2
votes
1answer
257 views

Are there design patterns or generalised approaches for particle simulations?

I'm working on a project (for college) in C++. The goal is to write a program that can more or less simulate a beam of particles flying trough the LHC synchrotron. Not wanting to rush into things, ...
3
votes
1answer
541 views

Using the decorator pattern in a deep class hierarchy

How would one use the Decorator design pattern for anything other than trivial toy problems, in a deep class hierarchy? For example, let's say you have the class class Decorated : public Foo, Bar, ...
23
votes
7answers
4k views

Are utility classes with nothing but static members an anti-pattern in C++?

The question Where should I put functions that are not related to a class has sparked some debate over whether it makes sense in C++ to combine utility functions in a class or just have them exist as ...
1
vote
4answers
490 views

How should I deal with nested compositions?

I came across the following question on a website for interviews: Here are 3 products: table, chair and bench. Product can be of material: wood, metal, and plastic. Design class structures for ...
5
votes
1answer
2k views

Observer pattern; knowing *what* changed?

I've created two abstract classes Subject and Observer that define a classic Observer pattern interface. I derive from them to implement the Observer pattern. An observer might look like this: void ...
4
votes
3answers
1k views

Is CRTP used much? and why it is/isn't? [closed]

I'm thinking about curiously recurring template pattern. I find it quite useful, and it's pretty well adjustable for many tasks. But I have to admit, I don't see much of CRTP code in the wild. Is it ...
31
votes
10answers
2k views

Difference between Idiom and Design Pattern?

What is the difference between idiom and design-pattern? It seems that these terminologies overlap somewhere; where exactly, I don't know. Are they interchangeable? When should I use what? Here is a ...
2
votes
3answers
594 views

GUI: Setting options in two different places and having them stay in sync?

Programming in Windows with Visual Studio 2010 C++ and MFC. My question is about how best to store, update, and pass around program settings or options. I have a simple main GUI window/frame/dialog. ...
0
votes
1answer
241 views

Designing classes containing the same objects but different amount of them

I am creating a main object, MACHINE, which will contain a diversity of several other objects -- AXIS, AMPLIFIER, ENDEFFECTOR, etc. The number of contained objects will vary depending on the MACHINE ...
6
votes
3answers
684 views

Avoid having an initialization method

I have this existing code where they have a class and an initialization method in that class. It is expected that once the object of the class is created, they need to call initialize on it. Reason ...
3
votes
4answers
1k views

Is this a pattern? Should it be?

The following is more of a statement than a question - it describes something that may be a pattern. The question is: is this a known pattern? Or, if it's not, should it be? I've had a situation ...