Questions tagged [programming-practices]
Programming Practices are the commonly or not so commonly used practices in development of software. These can include things like Agile Development, Kanban, Coding shortcuts, etc.
1,595 questions
1
vote
1
answer
238
views
Internal data representation in firmware
I'm developing firmware for control system.
That system will collect data from different sensors (using ADC, GPIO, I2C temperature sensors, etc.), process this data and generate some control signals.
...
0
votes
4
answers
281
views
Use-cases for Expression<TDelegate> except translating to another language?
So I just learned about Expression<TDelegate>. As a library author this really intrigued me; my libraries make extensive use of source generators to generate both high-performance code and code ...
-1
votes
1
answer
186
views
Testability when API contract is fixed
Recently, I spoke to an Engineering Manager about some work I've done:
I had to implement a micro-service to a third party API contract (that they will call). Part of the requirement is to ...
0
votes
3
answers
320
views
Use of environment variable or appsettings as a counter, good or bad practice [closed]
I'm wondering if it's bad practice to have a variable in a webserver which counts the amount of incoming requests and put it in an environment variable.
In C# for example you have System.Configuration....
-2
votes
1
answer
602
views
Are there good practices or even conventions to store LLM prompts I use while coding?
I sometimes use some language model assistance (e.g., GPT-4o) while coding. I'd like to save somewhere the prompts and language model versions I used. Are there good practices or even conventions to ...
-3
votes
2
answers
812
views
Is throwing an error in programming is good Idea at all? [duplicate]
I am wondering if throwing an error in programming is good Idea at all ?
While programming we throw error when something unexpected or invalid has occurred. But if we have thrown exception and it is ...
0
votes
1
answer
300
views
Is immutable objects over POJO in general?
Lombok is used in the legacy project where I am currently working for since last year. The project is legacy with 10+ years, and POJO/JavaBeans, i.e. @Data annotated classes, have been widely used for ...
2
votes
2
answers
625
views
Is trunk-based development viable for SDK development?
Is trunk-based development (TBD) viable for development of software where versioning, compatibility, long term support and service level agreements (SLA) play a big role for business (e.g. libraries, ...
5
votes
5
answers
1k
views
Is it bad practice to use nullptr in ternary operation?
I've set up a ternary operator in place of a pile of if-else's, the final expression being nullptr in order to finish the loop, like so:
int menuSelect;
std::string operation="";
(...
2
votes
2
answers
634
views
When to prefer print over logging?
Generally print statements are frowned upon in favor to logging. But are there any situations where I should prefer using print statements?
In a interactive command line application, if I ask for user ...
2
votes
3
answers
291
views
What is the code smell called when API are encapsulated many times [closed]
In legacy code bases, some APIs might be encapsulated by different developers with separate classes many times. Example:
public void calculate(int baseIncome) {
revenueCalculator.calculate(...
-1
votes
1
answer
177
views
Help in understanding if my design getting complicated [closed]
I have 3 classes
class Backup
end
class Database
end
Class App
end
The backup database has a reference to Database and App, like
class Backup
def getDatabase
Database.create
end
def ...
3
votes
5
answers
547
views
Business acronym usage in source code
What are the rules about acronym usage that are related to the business ?
I always hesitate between using the acronym or not. When talking with people who work here they will understand faster when I ...
2
votes
4
answers
3k
views
I wrote a class with "init" method. Should I call it from other class methods? Or leave it to the object user? (Code Design)
I have a java class with an init method. It's different from the constructor. The constructor just initializes the variables/fields. The init method connects to a database and performs some ...
-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
4
answers
379
views
Storing both a compiled service for a Docker container as well as the container in a repository. Good practice, bad practice or no precedent?
This has erupted from quite a turbulent meeting between two senior developers, a lead developer and an engineering lead, and after 90mins reached no resolution.
We create Spring Boot Java services ...
3
votes
3
answers
885
views
How do you go from specification to implementation in a systematic way?
This sounds like a newbie's question, but please bear with me. I have 10+ years of commercial software development experience, and I still don't know how to do this properly.
I'm working on a pet ...
3
votes
0
answers
170
views
Forgetting about the utils [closed]
Let's say my language's standard library does not include TrickyFunction(). Since implementation seems quite trivial for me, I decide to create utils in the project and add such function, for others ...
0
votes
2
answers
99
views
I've a doubt regarding Environment Model of execution
I came across Environment Diagrams,it is described below
Whenever Python needs to work with an object, that object is stored in
memory; and, additionally, Python also needs a way to associate names
...
-1
votes
1
answer
18k
views
@Getter, @Setter vs @Data in lombok? [closed]
So I was sending code for review and approvals for some changes I made recently. that includes a class as below:
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ...
1
vote
2
answers
367
views
Is it a bad habit to use other class' "private" variables in Javascript
I've gotten this idea in my head that i shouldn't use a libraries variable, if the variable name begins with '_', as it is standard to write private variables that way.
But now i'm thinking i'm taking ...
1
vote
3
answers
369
views
What does it mean for a version a programming language to not be supported anymore?
I am fairly new to programming; I was following a tutorial that was using php 7.3.8. So I went to the documentation website of that same php version, and it says it’s no longer supported. So, I ...
-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 ...
2
votes
1
answer
1k
views
Does it make sense to use byte instead of int in Java? [duplicate]
Recently, I had to implement a business rule in a certain project. The rule basically consisted of checking a range between 1 and 12, values that would be used later, in some way, with Bootstrap.
...
-1
votes
2
answers
281
views
Do I really need TaskManager class? [duplicate]
Background:
I'm coding an app, the core idea is simple - I can choose a 'Task' (consists of name, code to perform aka Runnable, progress) through GUI, start it, stop it, start all 'Task's and stop all ...