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.

Filter by
Sorted by
Tagged with
0 votes
4 answers
152 views

How to eliminate repetition in three subclasses: each defines an identical method that does almost the same thing, but with a different return type

TLDR: I have three subclasses, each inherits from the same parent class, each defines an identical method that does almost the same thing, except that each of these methods has a different return type....
thatUserHOverThere's user avatar
2 votes
2 answers
429 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, ...
Tomasz Bąk's user avatar
0 votes
1 answer
75 views

Is there any benefit/viability to sharing models across API versions that have differing schemas

I have been asked to get involved with a Team that is currently having delivery issues for various reasons. During my review I came across an acceptance criteria on a user story; If you call v1 of ...
Kinexus's user avatar
  • 305
4 votes
5 answers
417 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=""; (...
Hench's user avatar
  • 51
0 votes
5 answers
232 views

When, if ever, should a private member variable, used in one function, be made into a local static variable?

Lately, I have been playing with this idiom: Changing a private member variable into a local static variable when: member to singleton class used in only one function member is mutex for a shared ...
Anon's user avatar
  • 3,593
3 votes
2 answers
271 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 ...
Sourav Kannantha B's user avatar
0 votes
1 answer
127 views

How best to share common steps between services while allowing them to provide their own behaviour

I've started working on a C# codebase. There are three services which run the same set of steps of three kinds of objects, each returning IResult: public IResult FooService(Foo foo) { ... } public ...
hyperfiction's user avatar
1 vote
3 answers
243 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(...
Rui's user avatar
  • 1,681
26 votes
8 answers
6k views

What is a good way to indicate that a number is not something you can count with?

What is a good way to indicate in programming that the sequence of digits you see is not a value you can do math on? I use a lot of numbers which aren't "numbers". From account-numbers to ...
Pieter B's user avatar
  • 13.2k
-1 votes
1 answer
164 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 ...
Raja G's user avatar
  • 109
1 vote
3 answers
258 views

Scala Option vs. conditional branches

If I'm writing Scala functions and have to check for nulls in situations where I can't avoid it (say, working with Spark UDFs and some legacy Java types), is it better to turn things into Option or to ...
wrschneider's user avatar
  • 1,289
3 votes
5 answers
386 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 ...
mp9007's user avatar
  • 59
2 votes
3 answers
224 views

Correctness of an implementation beyond the methods signature contract of an interface

Is there a programming principle/guideline that tackles the correctness of a implementation beyond the methods signature contract of an interface? Let's say we have a repository interface with two ...
qUneT's user avatar
  • 53
1 vote
4 answers
1k 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 ...
joker's user avatar
  • 121
1 vote
0 answers
90 views

What is the best way to implement the following type of paradigm?

I have the following piece of code. Line 1 is a container (for simplicity, one can think of it as a list of elements e1, e2, ..., en). Now there is a function function_fun which takes as input an ...
A J's user avatar
  • 19
-1 votes
1 answer
95 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 = ...
Samuel Muldoon's user avatar
23 votes
6 answers
6k views

How important is it to clearly understand requirements and architecture before starting to code? [closed]

Whenever possible I have been requiring an understanding of the requirements and architecture for the next scope of work before starting to code. Sometimes due to schedule pressure on larger projects ...
Bill Dyer's user avatar
  • 377
1 vote
4 answers
287 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 ...
Crazy Dino's user avatar
-1 votes
1 answer
88 views

Verifiable Credentials Wallet

I'm working on a project that requires the use of verifiable credentials, and I'm looking to build a wallet that can store and manage these credentials according to the W3C standard. However, I'm ...
ash's user avatar
  • 99
3 votes
3 answers
396 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 ...
Violet Giraffe's user avatar
2 votes
3 answers
329 views

C# Duplicated usage of an if/else condition and a ternary operator. A good practice?

I had a debate with a work mate regarding the following code as to which one of it would be the better practice: My code (in pseudo): var A = <precondition either TRUE or FALSE>; var B; if(A) { ...
Chams's user avatar
  • 29
3 votes
0 answers
149 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 ...
JoshThunar's user avatar
0 votes
3 answers
267 views

Proving program correctness under all possible cases

There are techniques of proving program correctness under all possible cases, but that is a more advanced topic, for a later subject in your curriculum. I always had this doubt: Is it possible to ...
Dennis's user avatar
  • 19
0 votes
2 answers
83 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 ...
Dennis's user avatar
  • 19
0 votes
3 answers
670 views

Why isn't a counter used to avoid nested for loops for index based operations?

Let's assume we have a method that we want to run as fast as possible and it needs to loop on a 2D array, naturally we would do a nested for loop as such: int[][] arr = new int[3][3]; for(int ...
Yoh's user avatar
  • 51
-1 votes
1 answer
8k 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 ...
Brooklynn99's user avatar
25 votes
13 answers
9k views

How much time should you spend planning a commit before writing code?

At the moment I'm spending more time planning out a commit than actually writing code when adding a new feature. Less than two hours would be lucky, and sometimes I'd spend a good part of the day ...
Tom Huntington's user avatar
1 vote
2 answers
282 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 ...
Jesper's user avatar
  • 143
0 votes
2 answers
2k views

Store static data in public folder as json file or directly in .js file?

I'm busy working on a website – somewhat new to this – and I don't quite know where I should store static data: in the public folder as a separate json file, or within the .js file as an object. In ...
AlePouroullis's user avatar
1 vote
3 answers
272 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 ...
alex schobel's user avatar
4 votes
2 answers
781 views

How to organize a chain of functions that share parameters, functional programming

When trying to follow a functional programming paradigm, I often find myself in a situation where I have a chain of functions that I would want to combine/compose somehow, but they all also take in a ...
Cordello's user avatar
  • 413
-1 votes
3 answers
586 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 ...
Veverke's user avatar
  • 423
0 votes
1 answer
628 views

How to handle config/env vars in a library project

I am building a new Python library project to be consumed by several of my application projects. The existing code consumes environment variables for various configuration settings. Should my ...
Brian's user avatar
  • 183
1 vote
1 answer
776 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. ...
Warlock's user avatar
  • 49
0 votes
2 answers
538 views

Best pattern/practice to execute a multi-step code generation process

I am working on a project that generates an API with the possibility of doing CRUD operations based on a high-level description of the resources that the user would like to have in an application. In ...
Ionut-Alexandru Baltariu's user avatar
-1 votes
2 answers
215 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 ...
Wiktor's user avatar
  • 33
0 votes
1 answer
116 views

When to Push or Publish

I'm in the process of redesigning our entire process control system (a daunting task, really!), and want to make the right decisions to how each system in the ecosystem communicates with each other. ...
Groger's user avatar
  • 113
-4 votes
3 answers
173 views

is it bad practise to go back to your last backup when you encounter an unneccessary bug? [closed]

I find when I am programming and I fix a bug in one area of the codebase, sometimes something slightly related or maybe unrelated breaks, and as a result I usually copy and paste the fix to a ...
jackw11111's user avatar
-1 votes
1 answer
132 views

Reducing Server Calls or Improving Server Response Times?

In the company I am working for, we have been told to keep server requests to a minimum. There are probably reasons for this specific to the company, but it made me wonder. Let's say I am building a ...
pythonweb's user avatar
  • 107
2 votes
2 answers
500 views

Design of a modular application

I'm developing an application (Java) in a modular architecture. I have two approaches in mind and I'm not sure which one will be "better code" in case of maintenance and conventions. I have ...
SmallDevice's user avatar
2 votes
3 answers
700 views

How to keep track of Indices

I've discovered my biggest issue with practicing interview questions and writing software more generally is keeping track of indices in python, maybe partly because my first two languages were the 1-...
JoeTheShmoe's user avatar
0 votes
3 answers
110 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: '...
Jose Daniel Vivar Personat's user avatar
1 vote
1 answer
283 views

Common methods of generating code with code

I wish to develop an application that can generate code based on an user input. Long story short: a user gives a formal description of a Resource (can be viewed as a REST resource) and based on this ...
Ionut-Alexandru Baltariu's user avatar
5 votes
2 answers
1k views

Is it good practise to rely on the insertion order of python dicts?

Since python 3.7, it is guaranteed that dictionaries maintain insertion order. The linked stackoverflow Q&A states This simply means that you can depend on it. Is it good practise to depend on ...
lucidbrot's user avatar
  • 634
-2 votes
2 answers
2k views

Best practices around writing testable extension methods

I’m currently working in C# and I’d like to write and extension method against a type. There is a small amount of repeated logic between classes surrounding JSON deserialization, using the ...
RTT's user avatar
  • 1
-1 votes
3 answers
413 views

Improving APIs that call 3rd party APIs [closed]

So I'm designing the backend of a platform that often calls other 3rd party APIs. The issues I've noticed were latency issues (sometimes the calls were fast, others a bit slow >15s) and I'm ...
Fares's user avatar
  • 109
14 votes
5 answers
5k views

Are there any problems with using continue or break?

My Software Engineering teacher just said: "Avoid using continue and break, always make it work without using these". Is there a problem with these instructions? I would say he didn't say ...
Shi Nha's user avatar
  • 171
13 votes
6 answers
5k views

Is it bad practice create "alias" variables to not use globals or arguments with long names in a method?

Is it OK to create a variable which only purpose is to increase readability? Example: public class Example { private final HowLongCanARepositoryNameReallyBeRepository ...
Adilson Cabral's user avatar
6 votes
2 answers
1k views

Why would you use 'new' and 'delete' for something that will be referenced through a vector?

I'm going through some code from this article about ECS-systems in game programming and trying to understand it, and something I'm seeing a lot is using heap memory in places where it seems like ...
JensB's user avatar
  • 237
9 votes
4 answers
577 views

How to document alternative code I considered but didn't go with due to performance?

I write code in R, and often find myself attempting to optimize the code for better performance. In a given script that tackles a specific problem, I test different code alternatives and compare them ...
Emman's user avatar
  • 209

1
2 3 4 5
32