Questions tagged [patterns-and-practices]
Design patterns (repeatable solutions to commonly occurring problems) and best practices in software engineering
375 questions
3
votes
3
answers
349
views
How do you abstract a platform library like SDL from the graphics api?
I'm creating a basic 3D game in C++ with SDL2 and OpenGL3, and one of my learning goals for this project is to design my code around the ability to swap out SDL or OpenGL. However, the problem I'm ...
2
votes
4
answers
479
views
Is casting a concrete type to an interface and using it if it successful bad practice?
I recently came across some code:
val, ok := i.(SomeInterface)
if ok {
val.Method()
}
The above is Go, and attempts to cast to an interface and then runs the method for that interface against the ...
-1
votes
2
answers
147
views
How to handle complex logic, avoiding recalculation for performance reasons?
let's say we're building an Ecommerce Marketplace.
We have Sellers and each Seller has Products.
We want to display a list of available Products across all Sellers to Buyers.
But, we only need to ...
1
vote
2
answers
171
views
how best to take a vertical slice of something already trivial?
Lets say I have a project which is something relatively simple like a copy checker for legal text files stored in git, that multiple people contribute to via pull requests that must be reviewed before ...
0
votes
1
answer
165
views
Storing Data For Consumption in Python
I have a program which needs some constant data, in JSON-like format. However, this data only needs to be consumed by my Python program, and by making it Python code, I can include types like datetime....
2
votes
3
answers
196
views
Class design using Open and Close Methods
As the title says, Im thinking if it's a good practise to have classes that have Open and Close methods in the sense that they can be reused without a new instance being created again.
Also, if I want ...
0
votes
0
answers
309
views
Pattern for Nuget Package (Abstractions, DepedencyInjections, etc.)
I've been interested in following what other successful libraries are doing with their nuget packages. Unfortunately, I can't seem to find any materials to read online and I don't even know what to ...
-1
votes
1
answer
247
views
Why have a path argument when there is cwd
When writing a program that uses a working directory, e.g., PostgreSQL data directory or download target for wget, is there an advantage of having a CLI argument (or an environment variable) for such ...
-1
votes
1
answer
117
views
How can I prevent an object from being re-sanitized everytime it is passed as input to a function?
Suppose that I have a class named CharStream
Additionally, there are a large number of functions which convert their function input into a CharStream
def funky_the_function(_input):
input = ...
1
vote
0
answers
119
views
Reuse and sharing with primitives
I am having trouble naming and thus searching for the right keywords for a pattern I am seeing in my web applications and their associated difficulties. Here are some examples of the pattern I mean:
...
1
vote
3
answers
231
views
Separating network logic from business logic
I am creating a simple P2P file sharing system, where one peer can send some Objects (e.g., String, custom objects, etc...) to another peer.
The peer, that receives the Object, can then manipulate it, ...
-1
votes
2
answers
151
views
Appropriate design pattern for coupled Objects
I code an Object-Oriented simulation where you can have a Unit move on a Terrain. The cost of such move depends both on both Unit capabilities and Terrain features: a boat can move on water, a plane ...
-1
votes
3
answers
965
views
Would Injecting dependencies in C# as default parameters be a bad practice?
Given the (old) debate over whether Singletons are overused/abused/are worth it - would it be a bad idea to inject the dependencies as default parameters? In this way, we could get rid of defining ...
1
vote
2
answers
3k
views
Difference between Strategy pattern and Repository pattern
I found the following definition of Repository Pattern:
Repositories are classes or components that encapsulate the logic required to access data sources. They centralize common data access ...
0
votes
3
answers
147
views
Should we test private data (static objects in this case) to make sure it maintains its structure?
I had a discussion at work about whether to unit test a private static object we're using as data for a public component.
const data = {
45: { name: 'John' },
2: { name: 'Patricia' },
27: { name: '...
0
votes
1
answer
307
views
Should I use SCSS mixins as shortcuts for default CSS syntax?
This question is mainly about readability and understanding of the code. Im am also in the process of creating a SCSS framework like Compass and Bourbon.
I struggle to write SCSS because I like to see ...
0
votes
1
answer
751
views
Source of "... against the interface, not the implementation"
For a paper I am writing, I need to find the origin of the following two phrases:
Code against the interface, not the implementation
and
Test the interface, not the implementation
(Note: the ...
2
votes
2
answers
308
views
Understanding passwordless sign up for mobile apps
How does phone number based authentication work, and what are its best practices?
I've noticed there are apps with streamlined sign-up/log-in processes where only a phone number is required, simply ...
1
vote
1
answer
904
views
Is it bad practice to run different versions of code in different environments? (i.e. test, prod)
As an example, let's say you have the following pseudocode:
if test environment: # meaning you don't have the typical service account prod perms
sudo as service account + do operation
else: # in ...
6
votes
1
answer
1k
views
Methods with "With" prefix?
I started working on a project and I saw some methods with this With prefix and I'm wondering if this refers to a known pattern.
Does anyone know of this naming pattern?
0
votes
3
answers
148
views
Strategy & Architectural Decision: Customer data migration between two companies
Asked this originally here, and didn't receive any answer so far, hence posting here too.
Let's say company A acquired company B in a certain region. This means, A and B were competitors in that ...
6
votes
4
answers
860
views
Is there a standard name (or examples) for the "sandwich" pattern?
I've noticed a certain idea recur in different contexts, but before I start calling it "the sandwich pattern", it would be useful to know (in the spirit of other "Is there a name for ...
2
votes
2
answers
161
views
What pattern for translation is better, naming the key by screen/context or by text?
I'm in a dilema where I'm translation a full mobile app where the translations are going to be a key value pair but I'm not sure how to name the key.
Should I name the keys describing what the text is,...
1
vote
1
answer
186
views
Who should log output, the ThingDoer or the code which calls ThingDoer.DoThing()? [duplicate]
Here's a common question I ask myself:
If I have a ThingDoer class and it has a method DoThing(), and I want to log a message stating "Doing a thing", should I put this logging code in the ...
1
vote
1
answer
167
views
Deisgn Pattern: How to map UI requests to Controllers to Services?
I'm learning about writing WebApi design patterns.
I am trying to create a simple CRUD web app with ReactJS UI and C# .NET CORE webapi with sql backend.
Articles show that specific Repositories are a ...