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
1 vote
4 answers
188 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 ...
-1 votes
1 answer
63 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 ...
  • 99
2 votes
3 answers
228 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 ...
0 votes
0 answers
49 views

How to improve the Mediator algorithm when new widgets are added?

i want improve mediator algorithm when the new widgets are added.How do I make changes in this form? plas help me and the code:
2 votes
3 answers
202 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) { ...
  • 29
3 votes
0 answers
132 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
3 answers
221 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 ...
  • 19
0 votes
2 answers
78 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 ...
  • 19
0 votes
3 answers
476 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 ...
  • 51
-1 votes
1 answer
2k 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 ...
24 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 ...
1 vote
1 answer
202 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 ...
  • 143
0 votes
2 answers
688 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 ...
1 vote
3 answers
231 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 ...
5 votes
2 answers
414 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 ...
  • 393
0 votes
3 answers
356 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 ...
  • 363
-1 votes
1 answer
129 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 ...
  • 163
1 vote
1 answer
227 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. ...
  • 49
0 votes
2 answers
263 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 ...
-1 votes
2 answers
128 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 ...
  • 43
0 votes
1 answer
106 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. ...
  • 101
-4 votes
3 answers
168 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 ...
-1 votes
1 answer
83 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 ...
  • 107
3 votes
2 answers
361 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 ...
2 votes
3 answers
438 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-...
0 votes
3 answers
94 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: '...
1 vote
1 answer
133 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 ...
3 votes
2 answers
354 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 ...
  • 614
-2 votes
2 answers
818 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 ...
  • 1
-1 votes
3 answers
149 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 ...
  • 109
12 votes
5 answers
3k 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 ...
  • 151
12 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 ...
5 votes
2 answers
786 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 ...
  • 217
9 votes
4 answers
549 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 ...
  • 209
3 votes
4 answers
523 views

Is it a bad practice to have an interface method to tell whether it can handle an object?

interface Resolver { boolean canResolve(SomeInput input); SomeOutput resolve(SomeInput input); } public static void main(String[] args) { List<Resolver> resolvers = ...; ...
0 votes
1 answer
295 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 ...
  • 31.8k
6 votes
2 answers
556 views

Should function names describe their parameter types?

If you wish to perform the same action using different parameters, you can either make differently named functions: public Apple findAppleById(long id){ return repo.findById(id); } public Apple ...
  • 187
1 vote
1 answer
78 views

What is the best approach to use a common variable in multiple method in a request in laravel [closed]

I have a $c variable that is calculated at the beginning of the request. After calculating this several nested methods use it as a part of their job. Is it better that I pass down the $c variable to ...
  • 121
2 votes
3 answers
145 views

How to deal with interpreter dependencies

Consumer software often has interpreter dependencies. How should a situation where the required interpreter is not by default installed on the targeted system be handled for consumer software, soft ...
  • 165
4 votes
4 answers
351 views

API Design: Sending errors in the response

Suppose I have a products API: /products GET: List of products POST: Creates a product /products/12345 GET: Get a specific product PUT: Updates a specific product So is this a good idea for the ...
2 votes
2 answers
745 views

One API or Two APIs one for internal use and the other for external use

I follow the Layered architecture Like this: But with two differences: I use Blazor Assembly for UI Layer. I have API layer(REST) In between the presentation layer and the service layer. My ...
2 votes
1 answer
369 views

How to balance 'efficient' vs 'clean' code? [closed]

I have been coding in python for a little over a year, and I have learned a lot and developed quite a few applications, in the process. I do not program for my profession, I simply program ...
1 vote
2 answers
194 views

Is using KDoc/Javadoc comments inside of a function considered bad practice?

I often find it helpful to use KDoc/Javadoc comments inside of a class or function instead of normal comments. IntelliJ colorizes them more obviously by default and, more importantly, allows ...
0 votes
1 answer
228 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 ...
  • 103
0 votes
3 answers
178 views

What do you call a routine that contains a smaller routine?

Just a question about general terminology. A subroutine as I understand it is basically a packaged subset of instructions that a routine runs to obtain a specific result that it needs for a larger ...
0 votes
2 answers
97 views

Calling general-purpose methods from the code that clearly needs only specific behavior

Here are a couple of examples in Python: clearly_even = 2 * get_integer() print(solve_for_any_integer(clearly_even)) def solve_for_any_integer(x): while x % 2 == 1: x = make_even_from_odd(x) ...
1 vote
4 answers
216 views

When should a method depend on a data source and NOT have it declared as a parameter?

I was assigned a code review to one of my colleagues. I posed the following, which I wanted to share here in order to hear whether I am right or wrong. Consider the following code snippet: public void ...
  • 363
1 vote
2 answers
52 views

Using public nested types to self contain complex POCOs for serialization

So a lot of the web says not to use public nested types unless you need the member visibility semantics (including this msdn article, even though that article hasn't been touched since 2008). For the ...
  • 331
2 votes
2 answers
1k views

If Entities, in the Clean Architecture, are enterprise wide rules how different applications consume them?

In this post, Uncle Bob writes: Entities encapsulate Enterprise wide business rules. An entity can be an object with methods, or it can be a set of data structures and functions. It doesn’t matter so ...
-2 votes
1 answer
85 views

Does it make sense to have a return type for a method doing batch operations [closed]

My application syncs data between 2 different services. Data flow looks something like this: Target <-- My Service <-- Source I have a method that starts this batch operation: // we have ...
  • 143

1
2 3 4 5
32