Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

All Questions

Filter by
Sorted by
Tagged with
4
votes
1answer
75 views

Coupling and shared entity classes

I am currently working on a problem that has a central controller that is handling inputs and outputs between various modules and maintaining a number of entity classes as these change. When working ...
0
votes
1answer
85 views

What OOP design pattern would work best for an overseeing class connecting related objects enforced at compile-time?

The Problem I would like to create a managing "overseer" class that connects several related object groups together where any particular group is able to be easily swapped for another using C++11 ...
3
votes
1answer
272 views

Architecture for messaging library C++

I have a library, which sends and receives a set of binary messages and parses them. So far I’ve used inheritance for my design, i.e. class BaseMsg { // init msg from rx'd binary stream ...
2
votes
3answers
262 views

Why is the Command desing pattern useful for game AI?

I'm trying to learn the Command design pattern and apply it to the game I'm working on. First I read about the general implementation, and I feel like I understand it pretty well. Now I want to know ...
0
votes
1answer
148 views

Orchestrating Object Instantiation and Intercommunication

We have a C++ project managed by UML software, which generates code for instantiating and passing data between objects. Unfortunately, this software adds a lot of overhead to our builds and ...
0
votes
3answers
312 views

What would be the downsides of creating a derived interface of interface?

Would there be any downsides of creating sub-interfaces for virtual member functions that have different parameter types? A drawing of this is shown in the image attached. Apple and Orange do not ...
-1
votes
1answer
63 views

Best OOP practices for object accessing “aggregate object” members?

Is there a best practice for something like this? (Example in C++) class A { public: int usefulParameter; std::vector<B*> bContainer; }; class B { public: void ...
3
votes
0answers
79 views

Creating bindable input handler in C++ spanning two separate modules

I have a wxWidgets application. This is the first, main module. The second module is an openGL engine. It's a model-view-(controller) structure, where application is the view (and the controller), ...
2
votes
1answer
316 views

Designing a pause'able & resume'able task handler

I don't think the title describes the situation exactly. I apologize for the poor description. I'm trying to write a software system, in C++, that will have a heavy job (scanning the file system for ...
1
vote
3answers
210 views

Class invalid flag vs exception

So i have the following. I read in lines from a text file. Each line needs to be analysed and get the important data extracted (I wont go in the details here). I worte a Parser class which does this ...
1
vote
3answers
342 views

design pattern for class with data attached

I have a class Tiles that looks something like this: class Tiles { public: void AddTile(int x) { tiles_.push_back(x); } std::vector<int> tiles_; } Now I want to create a class Tiles with ...
21
votes
4answers
3k views

Use abstract class in C# as definition

As a C++ developer I'm quite used to C++ header files, and find it beneficial to have some kind of forced "documentation" inside the code. I usually have a bad time when I have to read some C# code ...
2
votes
0answers
101 views

Access modifiers in combination of interpreter pattern with template method pattern

Motivation: (Skip to "The Problem" if you don't need motivation for it) As a project for myself, I'm writing an expression parser for certain kinds of mathematical expressions, and I'm using the ...
1
vote
1answer
430 views

How to organize the management of resources for OpenGL?

I write my own 3D-graphics engine for education and have some difficulties with it's architecture. I wrote classes like OpenGLTexure, OpenGLMaterial, OpenGLGpuProgram, etc. I also wrote a class ...
6
votes
6answers
688 views

Exposing member variables vs Adding member functions to modify them

Say that we have a class Car that contains objects of type Wheel class Wheel { public: void SetFriction(double f) { friction = f; } private: double friction; }; class Car { ...
1
vote
1answer
198 views

Design pattern for modeling a PC

I have a type of "PC" (i.e. personal computer) that I need to model in C++ (can use language standards as new as C++11, but no newer than that). In short, we have a lot of granularity for components ...
0
votes
2answers
114 views

How to the refactor the following parallel code to avoid redundant checking?

In the following code sample, the processes are assigned to different contexts. And each App object will be bound to only one context. Though all the processes run the same code, only those belonging ...
1
vote
2answers
195 views

Design Pattern for a weather rating feature

I am in a software engineering class and I need to pick a design pattern to use for a 'feature'... I have two features, and one of them is to have a feature where a user can enter a zip code and time ...
0
votes
1answer
87 views

Modify variable from different libraries

I am working on a legacy C++ code with two libraries. Library1 is the main and Library2 uses classes from Library1 (so there are some #includes "HeaderFromLibrary1" in Library2). Deep in the code of ...
0
votes
2answers
139 views

Slightly Different Interfaces

I am creating a class which has an instance variable that has many different implementations, but the problem is that all of the implementations have a slightly different interface. Example: class ...
0
votes
2answers
299 views

Wrapping a shell process to manipulate a file system, how to improve design?

In my API library (C++) I am wrapping a shell process (spawned using popen) with several classes to manipulate a file system. The base class ProcessFileWrap wraps general filesystem tasks and ...
-4
votes
2answers
948 views

recommend a design pattern for a C++ application that takes some data, processes it, and returns results

So I am new to design patterns and C++11, but I have been studying both quite a bit. I am working on developing a C++ application to process some data, and I was hoping that someone with more ...
2
votes
2answers
1k views

When to actually use RAII?

I understand the concept of RAII: Use the destructor as a means to free resources, such as memory, or closing file handles/database connections. Coming from a Java background this was actually rather ...
2
votes
3answers
530 views

C++ - explicitly prefixing every member with public/private

Normally, a C++ class is written with public: and private: applying to a series of members: class Foo { private: int x; int y; int z; public: int getX(); int setY(int val); ...
3
votes
1answer
114 views

Command pattern to update private field

I have a class representing the state of my application and I want to create many commands to update this state. class State{ private: list<int> intList; ... } class ICommand { ...
5
votes
1answer
155 views

Templated versions of executable?

So I am creating a numerical solver that I want to use for many problems/algorithms. The way that it's written, there is a generic class called "Algorithm_Scheme" (and associated files ...
2
votes
1answer
137 views

Can I create a Factory method which holds an internal reference to an instance of B?

Given two classes: class A { B* b_; A(B* b){ b_ = b; } } class B {} B is a class that should be used only inside A so I would like not to expose its creation to whatever class ...
1
vote
2answers
56 views

Class member declared only to be passed to other class

Given three classes: class A { B* b_; A(B* b){ b_ = b; } void doThings() { C* c = new C(b_); ... // Use c } } class B {} class C { B* b_; ...
1
vote
0answers
250 views

Dependency injection in the template class

I have a template wrapper class around the container std::priority_queue that supports multithreading. The short version of it is below. In this class I employ the function IsReady() that checks ...
2
votes
1answer
190 views

Interface and implementation design structure?

I'm quite new to designing large programs in C++. I'm writing series of operations, each of which have their own class, which will be invoked by the ProcessMgr class. I'm using ProcessMgr as an ...
3
votes
2answers
122 views

Mechanical State Estimator design

I want to write a library for Mechanical State Estimation of a vehicle. This is, estimate variables as position, velocity an so on, using the information provided by different sensor measurements (GPS,...
3
votes
0answers
169 views

Design Pattern for Internal Builder

There is an object which is very complicated to build and many algorithms needed to figure out how it should be created (for your curiosity it is an object that represents and draws the beaming of ...
8
votes
4answers
873 views

Does it violate any OOP principle if a member function does not use any of class properties/member variables?

I have an existing class which interacts which can open, read or write to a file. I need to retrieve a file modification for that purpose I have to add a new method Suppose this following is my ...
1
vote
3answers
196 views

Handling diverse “plugins” while staying sane

My colleagues and I are struggling with a design problem. I'll try and explain the situation: We have a number of different components (let's call them plugins), that take an input, do something ...
6
votes
5answers
254 views

Choose only one of several inheritances

I may look like a total idiot with such a question but nothing came up when I searched it, so I guess why not. Here is my problem: I'm doing the UML work for a C++ game, that will feature animals ...
1
vote
2answers
553 views

Help with getting rid of circular dependency

I have the following circular dependency that I'd like to eliminate. I think I must have a flaw in my design. And I'd much appreciate any feedback on how to fix this. My circular dependency comes ...
6
votes
3answers
6k views

Which is the best design for callback implementation in C++?

I have a class "Parent". "Parent" class creates an object of class "Child" in my CPP module. The use-case is "Child" has to request for some information from "Parent". This can be done in several ways ...
2
votes
2answers
233 views

Design classes to prevent future code breaks

I'd like to design a robust version of this class (C++11): class Oscillator { private: std::vector<double> trajectory_; // Some numbers that are needed to get the trajectory ...
1
vote
1answer
679 views

Inner and outer class relationship: should outer class be friend of inner's?

Is this design bad? Does it break encapsulation? The structure class B is a component of class A. Therefore, class A needs access to class B's members. Let a house be class A. Let a housekeeper be a ...
3
votes
1answer
237 views

Writing a non-monolithic database wrapper

I have a SQL database to which I store and from which I read several objects into my C++ code. I wrote a single database wrapper which handles all the reads and writes to the DB. Of course this ...
1
vote
1answer
171 views

is this a good design

For example, I have a clan and a character. There's a character that is the leader. To give the clan a specific feature, some money from the character is required. I don't want to have too much tight ...
3
votes
0answers
434 views

What are the benefits of an input/output component design?

For the company I work at, all of our projects, including a new one started last year, are written in C89. We write for vxWorks (a real time embedded operation system). Our software runs multi-...
1
vote
2answers
178 views

How to store state data when the data is related to another entity?

In order to increase the parallel-ability of my objects, I try to make them read-only and include only data that naturally belong to the entity. I have class Object { ... }; class Processor { ...
4
votes
4answers
535 views

Is Template Pattern a good way to implement DRY?

Here is my problem: I have and class structure like this: class Base { private: SomeType something; bool isSomeValue; public: virtual void myMethod() = 0; }...
13
votes
1answer
2k views

Object lifetime invariants vs. move semantics

When I learned C++ long ago, it was strongly emphasized to me that part of the point of C++ is that just like loops have "loop-invariants", classes also have invariants associated to the lifetime of ...
2
votes
2answers
437 views

Private variables and the old FORTRAN common blocks [closed]

This is a question that perplexes me about object oriented programming. In some OOP languages (e.g. C++) a member function can access private variables of the class without restriction. That means ...
6
votes
2answers
510 views

Automatic namespace resolution in C++

My question is focused on design, and the code included in this question is meant to clarify the problem I'm experiencing. I'm interested in conceptual level answers and not code in order to answer ...
3
votes
5answers
156 views

Can encapsulation be implemented by proper types rather than accessors?

Interesting question came up while designing interfaces at work, now resolved, but I want to ask about the theory behind it. Is it incorrect to say that properly typed data members of a class provide ...
4
votes
3answers
19k views

How to share data members between classes in C++ without violating encapsulation too much

In C++ let's say I have some class A: Class A { int a1, a2, a3; void foo(); } and I need to use a subset of members (a1, a2) in a member function for a second class B. What ...
0
votes
4answers
312 views

How to write procedural code in an object oriented language?

I recently started working in domain of mesh generation . My programs usually contains large chunks of procedural code consisting of several phases. Eg. class MeshAlgo1 { /* A very long function ...