Questions tagged [design-patterns]
For questions requesting extra attention to be paid to the usage of design patterns in the code.
1,425 questions
10
votes
4
answers
2k
views
Builder pattern in Rust
I tried to implement Builder pattern, a popular design pattern for constructing objects consisting of different components, in Rust.
Here is my attempt:
...
6
votes
3
answers
1k
views
Game Design Patterns Command implementation
I started reading the GameProgrammingPatterns book and wanted to implement the command pattern.
...
4
votes
1
answer
186
views
ReportManager design — ownership via move or unique_ptr, SRP concerns, and O(1) lookup strategy
I’m practicing the Single-Responsibility principle with a small project.
A Report is composed of ...
-1
votes
1
answer
96
views
Am I overusing classes and/or OOP features? [closed]
I have a very class heavy approach to writing C++ code, which I don't think is necessarily wrong. However, I often use classes without knowing if I actually need them, which I feel leads to making ...
4
votes
1
answer
112
views
Maze game from book Design Patterns with smart pointers and polymorphism
The Design Patterns book chapter 3 about Creational Patterns starts with a maze game. They use the maze as an example throughout the chapter and instead of rooms they have also things like enchanted ...
9
votes
2
answers
364
views
Simple LRU cache implementations in C++20
LRU cache is a classical design pattern frequently questioned in programming technical interviews. It is best illustrated with pictures. Here are two examples.
The following are two alternative ...
4
votes
3
answers
353
views
numpy array/item handling functions
Recently I have been using numpy arrays, which have great utility via their broadcasting methods.
I am attempting to write a useful public facing library, and this ...
4
votes
2
answers
530
views
Simple Java program to aggregate lines of a text file
I have just written a small application to aggregate the lines of a text file, for example to group the lines according to the frequency of IP addresses in a log file.
Would the code be sufficiently ...
0
votes
1
answer
65
views
Bulk conditions evaluation throwing a single RuntimeException exception
Bulk conditions evaluation throwing a single exception of a configurable type for all unfulfilled conditions.
It is developed around several design patterns:
(1) fluent interface to configure the ...
1
vote
1
answer
117
views
Database design using Closure Table for tagging system
I created these database tables with the inspiration in NjDevPro github repository. The design uses Closure Table for implementation of hierarchical tagging system in ...
4
votes
2
answers
121
views
Managing file paths in a python Data Science project
When doing Data Science projects, I often have to load data and metadata, and output results, plots, logs, etc.
Therefore I have to handle all the file paths from where to load the input and write the ...
3
votes
0
answers
55
views
Structure of nested Divs with a table
I'm a new frontend programmer.
I'm making a web site with flask, and to be honest, I don't know much about front-end so I don't know if what I'm doing is best practices. In one section, I have a div ...
5
votes
2
answers
131
views
Argument Order To Determine Order Of Output (Python; `attrs`)
Feedback Request
Is the manner in which I use attrs adequate (i.e. designed well)?
Should I not expect to be able to use argument ordering to order the joining of ...
0
votes
2
answers
136
views
[Spring Boot][REST] Design Pattern Best Practice (Single Entity, multiple business logic implementations)
I have some problems regarding best-practice design between data source layer(Entity), domain layer(Service) and presentation layer (controller):
I have one entity with a type field in the database to ...
1
vote
1
answer
117
views
Refactoring Agreement Status Logic: Applying SOLID Principles and Separating Logging/Auditing with Decorators
I have some production code that contains a lot of repetition and mixes business logic with auditing and logging. I've made two attempts at refactoring it, primarily using decorators. I'd like to get ...