Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
-2 votes
0 answers
36 views

When to save complex html/css/js as an image and load that instead? [closed]

I am working on building a site and have a fairly complex layout consisting of many html elements is inside of one large button. I imagine that I could just save this layout as an image and load the ...
user avatar
  • 9
0 votes
2 answers
128 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 ...
user avatar
  • 295
-1 votes
1 answer
34 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 ...
user avatar
  • 153
1 vote
1 answer
87 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. ...
user avatar
  • 39
0 votes
2 answers
132 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 ...
user avatar
-1 votes
2 answers
110 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 ...
user avatar
  • 35
0 votes
1 answer
99 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. ...
user avatar
  • 101
-4 votes
3 answers
158 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 ...
user avatar
-1 votes
1 answer
74 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 ...
user avatar
  • 107
2 votes
2 answers
264 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 ...
user avatar
2 votes
3 answers
320 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-...
user avatar
0 votes
3 answers
85 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: '...
user avatar
1 vote
1 answer
114 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 ...
user avatar
3 votes
2 answers
246 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 ...
user avatar
  • 615
-2 votes
2 answers
148 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 ...
user avatar
  • 1
-1 votes
3 answers
74 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 ...
user avatar
  • 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 ...
user avatar
  • 151
12 votes
6 answers
4k 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 ...
user avatar
5 votes
2 answers
359 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 ...
user avatar
  • 217
8 votes
4 answers
526 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 ...
user avatar
  • 199
3 votes
4 answers
370 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 = ...; ...
user avatar
-1 votes
1 answer
181 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 ...
user avatar
  • 31.4k
4 votes
2 answers
267 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 ...
user avatar
  • 167
1 vote
1 answer
72 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 ...
user avatar
  • 121
2 votes
3 answers
142 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 ...
user avatar
  • 165
4 votes
4 answers
272 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 ...
user avatar
1 vote
2 answers
392 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 ...
user avatar
2 votes
1 answer
315 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 ...
user avatar
1 vote
2 answers
137 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 ...
user avatar
0 votes
1 answer
155 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 ...
user avatar
  • 103
0 votes
3 answers
157 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 ...
user avatar
0 votes
2 answers
88 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) ...
user avatar
1 vote
4 answers
213 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 ...
user avatar
  • 295
1 vote
2 answers
37 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 ...
user avatar
  • 331
2 votes
2 answers
604 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 ...
user avatar
0 votes
0 answers
57 views

best way to write to console in c#

i am using xamarin to build an android app. what is best way to write to console? I think you need 3 main things. 1st is visual indicator (so its for eyes to find it) 2nd is error location 3rd is ...
user avatar
-2 votes
1 answer
77 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 ...
user avatar
  • 143
1 vote
1 answer
128 views

Best practices when combining development environments

I'm working on a Swift-project (an iOS-app) where a webview is used to show an HTML-document. This document is manipulated by some JS, which is compiled and minified from TypeScript. There's also SASS ...
user avatar
  • 165
3 votes
2 answers
120 views

Checking the user in almost all use cases

I have a web application that has Users that belong to Companies. A User can only belong to 1 Company at a time and they can manage their own company information. I'm using java spring and I'm ...
user avatar
1 vote
4 answers
668 views

Is it good practice to put comment headers into each file?

I have an Unity project with countless of C# script files and I'm working on it solely. Although nobody else is working on it, I'm aware that some form of code documentation is crucial for my future ...
user avatar
  • 23
4 votes
3 answers
255 views

Passing object or using the field

I would like to know what is a more appropriate way to code in Java. Is it generally better to pass entire objects in the method's parameters or just using the fields from the class? Using the field: ...
user avatar
  • 63
-1 votes
1 answer
48 views

Unit testing a chain of network requests - how many tests?

I have some fairly complex code, that is a chain of API calls. The result of one call is the input of the next. class PaymentService { func pay(userId: String) async { let paymentSource = ...
user avatar
-1 votes
1 answer
159 views

How to avoid cyclic dependency in UI application

I'm developing an UI application where I ran into an issue with a cyclic dependency. Here is the simplified code, to explain the problem. #include <list> class UiStyle; UiStyle* CreateStyle(); ...
user avatar
  • 33
1 vote
4 answers
138 views

How to design a program that would definitely use microservices in production, but which I want to demo on a virtual machine for my portfolio?

So I am an independent software developer and I'm building up my portfolio in the hopes of helping with job applications. I have a broad design for a web based "app" (not really like a phone ...
user avatar
0 votes
1 answer
50 views

where to put conditional in chain of operations

I have two types of input data which will go through a number of steps for processing. The processing differs only in one of those steps, e.g.: TypeX: A() -> B() -> Cx() -> D() TypeY: A() -&...
user avatar
  • 111
3 votes
3 answers
390 views

What is the technical terminology for the practice of checking for null and edge cases in programming?

I took a PHP test for NASA recently and thought I should have done better. I believe the issue is something I used to know about, but need a refresher in. I can't remember what it is called though. It ...
user avatar
3 votes
3 answers
382 views

When doing multiple operations on a variable, is it considered bad practice to reuse the same variable name?

A commonly repeated best practice is to not reuse local variables. However, when doing multiple small operations on the same variable, I struggle both with coming up with good names for all the ...
user avatar
  • 141
8 votes
1 answer
2k views

Is it bad practice to require the same module in multiple files in Javascript?

Let’s say I have three files, all of which import a fairly large module. But I’ve divided them because they have different functions. Now each of the JavaScript files needs an initial statement like ...
user avatar
1 vote
0 answers
44 views

How to implement timing-mechanism for fantasy draft process utilizing ASP.NET Core 3.1 SignalR

I have developed a Fantasy Draft system utilizing ASP.NET Core SignalR, along with Azure's SignalR service (for backplane/scaling stuff). Last year I utilized a poor-mans' javascript version that just ...
user avatar
  • 401
1 vote
3 answers
660 views

Best practices for maintainable Graphviz / PlantUML code

I've been using Graphviz a little and just found out about PlantUML which is quite similar. I make diagrams but later the processes or systems depicted by the diagrams might change so I need to make ...
user avatar
  • 439

1
2 3 4 5
32