Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
3 answers
225 views

How to allow users to provide their own child classes in a factory design pattern in c++?

I am building a c++ project that will allow users to essentially model and create their own fleet of cars. Right now, the approach I have in mind is a Car Factory Class that will implement all of the ...
J K's user avatar
  • 27
3 votes
1 answer
193 views

Are contiguous objects contiguous in virtual memory or physical?

More or less what the title says. Suppose we have a sequential container like vector in c++ that will store data contiguously. When we say that the data is stored contiguously do we mean that it's ...
codefast's user avatar
  • 159
2 votes
2 answers
381 views

Optimal way to share data between different classes

I have a C++ code that performs simulation of a physical system which deals with motion of objects. It has the following classes: Class Main, containing all the main calculation methods and the data ...
grjj3's user avatar
  • 131
2 votes
1 answer
147 views

C++: Good approach to handle libxml2 resource management in a wrapper

I try to write a C++ wrapper to a well-known C library, libxml2. In libxml2, an xmlDocPtr represent an XML document and xmlNodePtr represents a node. An xmlDocPtr contains a root xmlNodePtr and every ...
Zoltán Várnagy's user avatar
1 vote
1 answer
144 views

Do you re-include system headers in the implementation files?

Here's a scenario: suppose you have #include <unordered_map> in the header and you don't declare it anywhere in the implementation file but you use it, maybe mp[whatever] = some; should you re-...
user129393192's user avatar
0 votes
1 answer
161 views

Is it good practice for object APIs to be required to be called in sequence to gather information?

I had this discussion with someone and it ended ambiguously. Suppose you have a class that needs to Parse a file to gather some information. It can expose this information to you after the fact. ...
user129393192's user avatar
5 votes
4 answers
3k views

Should I initialize third party libraries in a class or function?

I'm making a game using C++ and a handful of libraries like SDL2 and OpenGL. For a lot of these libraries, you need to initialize or set them up, and there's usually some important object(s) that come ...
Konjointed's user avatar
0 votes
2 answers
254 views

How to deal with boolean or enum variables used to decide code flow?

I am working on algorithm implemented in C++ that maintains several enum types. Say 3 to 4 enum types each with at least 4 different values. Plus the code maintains several boolean variables. The code ...
Mahesha999's user avatar
1 vote
2 answers
300 views

Combining Command and Visitor design patterns

Designing the architecture of a personal project, I've come up with the idea of using the combination of these two patterns to solve an architectural issue. In an MVC context, I need to implement ...
Gareg's user avatar
  • 21
0 votes
0 answers
52 views

Setting Dependency Design

Hello I'm currently designing an GUI application who's main job is to update and display settings and some other data. For context, I'm using QT framework. I'm starting to refactor the settings ...
mcmatt90's user avatar
0 votes
0 answers
99 views

How can I better design systems and components in ECS?

I'm working on a game from scratch in C++ which is based on an Entity Component System and I've ran into a bit of a problem with the way I've been designing my systems and components. I find myself ...
Konjointed's user avatar
0 votes
1 answer
1k views

Some approach or Design Pattern to implement same method different parameters of Interface class

I am using the Flyweight pattern to cache and reuse objects of the different classes. For example, I have a Shape interface class and multiple types of Shapes implementing the methods from the ...
Himanshuman's user avatar
2 votes
1 answer
114 views

Converting the classes with multiple dimension to Bridge design pattern

Bridge design pattern is something which is very confusing and GOF does not do justice with beginners in the definition. I was asked in my current organisation to add one more dimension to our class ...
Himanshuman's user avatar
4 votes
9 answers
1k views

Can a Domain Object always be "completely ignorant of persistence" and yet still possible to persist?

Domain Object, while not necessarily a design pattern, can at least be considered as a design "concept", and one of its points is: https://wiki.c2.com/?DomainObject Domain objects should ...
The_Sympathizer's user avatar
-1 votes
1 answer
123 views

How to handle dependencies between objects/components

Im currently working on a college project on the simulation of magnetic interactions of particles, see physical simulation: design thoughts. Right now im starting to code my system according to this ...
Meck3l's user avatar
  • 17
7 votes
9 answers
2k views

Changing number of arguments of a function

I wanted to know the best practice(s) for ensuring scalability while passing arguments. Say, in version 1.0 of an application, the foo function looks like this void foo(int i) Now, in version 1.1, ...
awakened's user avatar
1 vote
3 answers
1k views

Why is recompilation of dependent code considered bad design?

I am reading a book C++ Software Design by Klaus Iglberger. In the book, the author asserts multiple times that recompilation effects of dependent code is extremely bad. For example, The heart of the ...
User 10482's user avatar
0 votes
1 answer
147 views

Best software architecture approach for a single core system

Objective: Designing a data intensive application(myApp) C++ on Linux/RTOS which runs on a single core cpu, there are also 150 other applications share the same core with high priority than myApp. How ...
uss's user avatar
  • 141
0 votes
1 answer
267 views

Design of A Multithreaded Simulator

When designing my simulator, I have gotten stuck on 2 main design choices. The simulator can be described as having X number of nodes (between 50 - 2000) that each need to independently do some ...
Nabiel Kandiel's user avatar
1 vote
3 answers
392 views

Class design: should I split responsibilities or should the class take care of itself?

I have a Curve class that has some CurveData inside as private member as well as getter functions for topics of interest (e.g. peaks, width and so). So the math logic of a curve is inside this class. ...
user3717741's user avatar
1 vote
0 answers
1k views

Best way to store key-value pairs of different types in c++?

I'm reading values from a (PE) binary file. The values have a known length and position in the file and are stored with no padding (right next to each other). They store various types (int, long, ...
jan's user avatar
  • 111
0 votes
3 answers
287 views

Use aggregation like LSP in C++

I was reading about LSP (Liskov Substitution Principle) in a book called Clean Architecture: A Craftsman's Guide to Software Structure and Design. I have a question regarding how this would be ...
Gooday2die's user avatar
-1 votes
1 answer
123 views

Smart pointer class choice: Simplicity vs. right tool for the job

I'm wrestling with a design choice question here. I've got a class that needs a couple of semaphores. Semaphores are non-movable objects. Objects of this class however need to go into a vector (there'...
T.E.D.'s user avatar
  • 1,069
2 votes
2 answers
449 views

How to handle duplicate null checks

I'm working with a legacy codebase that has a lot of functions with a nullcheck on the same object. Example: std::vector<SessionNode*> * SessionManager::SessionMap; Session * getSession(int ...
Siddiqui's user avatar
1 vote
0 answers
77 views

Create Views depending on the dynamic type of an object returned by the model in MVP

In my MVP app, my model (a service) returns a collection of ISession pointers. Each pointer points to an object of a derived type HttpSession or HttpsSession. The model (the service) knows nothing ...
JenyaKh's user avatar
  • 111
1 vote
1 answer
146 views

Constructor initializer list too bloated?

I noticed that my Member initializer list is not really readable. My main.cpp files looks like this: #include "Application.hpp" using Pathfinding::Core::Application; int main() { ...
a a's user avatar
  • 261
2 votes
1 answer
144 views

Delegating whole class bad practice?

Suppose I have the following struct: struct Dimension { void setDimension(Vector2i dim); Vector2i getDimension() const; bool canShowInformation(); } And this struct uses the Dimension ...
a a's user avatar
  • 261
-3 votes
1 answer
63 views

Is it possible to add a unique identifier to the shared Data via bittorrent (P2P)?

I know that P2P sharing is copying the exact content between the peers. Everyone has the same data. Let's assume the content is very important and I don't want anyone to distribute outside the group. ...
JackUP's user avatar
  • 1
3 votes
1 answer
142 views

Design for deduplicating concurrent tasks in flight simultaneously

I have 1-20 agents that issue requests over time with roughly ~50 in total in flight at any given time. Many of these requests are identical. The tasks are idempotent, but if two identical requests ...
Unknown1987's user avatar
0 votes
0 answers
31 views

User proof network app with distant database [duplicate]

I’m currently writing a software for my company (3rd world country), and I wanted it as simple as possible to install and maintain, so I started with Qt and no server app beside the database, (MariaDB ...
Max13's user avatar
  • 159
2 votes
1 answer
571 views

C++ PImpl and Move Semantics

Suppose I'm writing a C++ class with the PImpl idiom for the usual reasons of providing a stable ABI and/or reducing #include dependencies. I want the class to have value semantics: modifying a copy ...
aschepler's user avatar
  • 129
-1 votes
2 answers
1k views

Hide private class member details from user but use it internally in non user facing code

I find myself in a situation with the following implementation. I have a class that is exposed to users. My intention is to expose a high-level abstraction to the user rather than internal details of ...
Debashish's user avatar
  • 135
4 votes
7 answers
5k views

How do interactions between objects work?

I am getting confused when objects interact using OOP. Here i'm trying to model the interaction between a vending machine and a coin. The coin is inserted into the vending machine. The interaction is ...
user avatar
2 votes
1 answer
2k views

How to do MVC in C++

I have a QT application with a window of OSG written in C++. I want to implement the app using MVC design. The application allows you to add markers to OSG model and it is using QT to edit the markers....
jacob galam's user avatar
9 votes
4 answers
2k views

Why does the C++ standard still allow uninitialized primitive variables?

If reading uninitialized memory is undefined behavior anyway, why has the C++ standard not been changed so that objects of primitive type (int, unsigned, float, double, bool, char) get default-...
darkblueflow's user avatar
-1 votes
1 answer
232 views

How to avoid cyclic dependency in UI application

I'm developing an UI application where I ran into an issue with a cyclic dependency. Here is the simplified code, to explain the problem. #include <list> class UiStyle; UiStyle* CreateStyle(); ...
mooko's user avatar
  • 33
2 votes
1 answer
620 views

Serialization and SOLID principles

I have several configuration structures that can be JSON serialized and deserialized as follows: namespace config { struct Foo { std::string hostname {}; std::string ip_address{}; ...
NutCracker's user avatar
2 votes
0 answers
127 views

How to design software driver for the analog to digital converter?

I have been developing software driver for the analog to digital converter in C++. The a/d converter is primary intended for conversion of the temperature signals. The temperature signals are then ...
L3sek's user avatar
  • 169
1 vote
1 answer
155 views

Templates for generic code and code flexibility

I have a data which is a std::vector of a "small collection" of items of a given type struct Bunny {};. I was vague about "small collection" because for now it's a collection of ...
Enlico's user avatar
  • 130
2 votes
2 answers
2k views

good design for signal handling in main executable

I have a executable that starts up some resources, spins a bunch of worker threads and then waits in a loop for the done command. After the done command is received, it does a bunch of clean up and ...
simplename's user avatar
1 vote
1 answer
268 views

Best way to structure multiple constants C++

Context I'm developing a chess engine of my own, where if anything can be pre-initialized/pre-calculated, should be. This is because speed is the number-1 priority, and every extra second you spend ...
user avatar
3 votes
1 answer
804 views

Are there any C++ command pattern implementations which make it easy to add additional functions and their parameters

For my situation I have a device receiving string commands such as turn_on, pump, etc. Some of these commands also have arguments attached to them such as an int. I have methods like this void turn_on(...
Cedric Martens's user avatar
6 votes
6 answers
975 views

How is design using C different from C++?

A employer is looking for C programmers, and I'm told they say that ... Good C design isn't the same as good C++ design ... and so they're looking for candidates experienced with C and not only C++. ...
ChrisW's user avatar
  • 3,417
10 votes
6 answers
4k views

Why are people coding "C-style C++"?

In discussions about whether to cast the result of malloc or not when coding C, one common argument is that if you cast the result then you can compile your C code with a C++ compiler. Why would one ...
klutt's user avatar
  • 1,438
0 votes
2 answers
174 views

Encoding const-ness on interfaces. Readers - Writers vs Const wrapper

This question is based on this separate question on stack overflow. I have a very low-level structure meant to compactly save presets on flash memory. For simplicity I am going to use stored_record as ...
Liarokapis Alexandros's user avatar
-2 votes
1 answer
296 views

Designing a sqlite component in C++

I work on a small component in an embedded device (sensor). This component : Every 5 seconds, sends requests to other components using sockets (get health check status, operating status etc) and ...
psy's user avatar
  • 137
2 votes
2 answers
183 views

How can I improve this design to achieve a more loosely coupled system and better testability?

My question I built an inverted pendulum on an Arduino using C (ie. everything was done procedurally). I'm trying to self study application design and would like to refactor my code into a more OO ...
Hunter's user avatar
  • 187
4 votes
3 answers
403 views

How to know where to draw the line between "safe" code and "over-engineered" code?

Suppose I have a class Texture that will be passed to a Renderer to be displayed on screen. One possible design is as follows: class Texture { public: Texture(unsigned w, unsigned h) : w_ {w},...
dav's user avatar
  • 159
1 vote
1 answer
115 views

How to make a system of mutually related classes?

I am making a C++ glfw wrapper for myself to use. I want to have classes like Monitor, Window, Context that would be wrappers for glfw objects like GLFWMonitor* or GLFWWindow*. The problem is that if ...
janekb04's user avatar
  • 123
0 votes
0 answers
235 views

How to create factories for same object type but different ways of creation following Domain Driven Design rules? (C++)

Brief description of a problem - providing factories which are creating same object type in different ways and following rules of DDD (isolated domain model, independent domain objects inside of it). ...
Bohdan's user avatar
  • 1

1
2 3 4 5 6