Skip to main content

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
-4 votes
3 answers
219 views

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
220 views

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
602 views

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
1k views

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
148 views

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
461 views

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 ...
jbolt's user avatar
  • 131
6 votes
2 answers
3k views

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
  • 662
-2 votes
2 answers
4k views

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
729 views

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
15 votes
5 answers
6k views

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
  • 181
13 votes
6 answers
6k views

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
2k views

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
  • 277
9 votes
4 answers
665 views

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
3 votes
4 answers
815 views

interface Resolver { boolean canResolve(SomeInput input); SomeOutput resolve(SomeInput input); } public static void main(String[] args) { List<Resolver> resolvers = ...; ...
Martin Tarjányi's user avatar
0 votes
1 answer
753 views

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 ...
Mike Nakis's user avatar
  • 32.8k
9 votes
2 answers
1k views

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 ...
Bar Akiva's user avatar
  • 217
1 vote
1 answer
155 views

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 ...
mehrdadep's user avatar
  • 121
2 votes
3 answers
211 views

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 ...
eds1999's user avatar
  • 165
4 votes
4 answers
1k views

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 ...
123432198765's user avatar
1 vote
2 answers
3k views

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 ...
Anyname Donotcare's user avatar
2 votes
1 answer
485 views

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 ...
NewCoder18's user avatar
1 vote
2 answers
561 views

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 ...
Matt Robertson's user avatar
1 vote
1 answer
904 views

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 ...
notacorn's user avatar
  • 109
1 vote
3 answers
319 views

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 ...
CycklopsGT's user avatar
0 votes
2 answers
121 views

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) ...
George Sovetov's user avatar
1 vote
4 answers
244 views

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 ...
Veverke's user avatar
  • 541
1 vote
2 answers
125 views

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 ...
KallDrexx's user avatar
  • 331
2 votes
2 answers
2k views

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 ...
Rafael Rozon's user avatar
-2 votes
1 answer
147 views

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 ...
rsp's user avatar
  • 143
1 vote
1 answer
180 views

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 ...
eds1999's user avatar
  • 165
3 votes
2 answers
242 views

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 ...
Jordi Pagès's user avatar
3 votes
4 answers
7k views

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 ...
Junes's user avatar
  • 43
4 votes
3 answers
1k views

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: ...
max's user avatar
  • 163
-1 votes
1 answer
80 views

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 = ...
Lord Zsolt's user avatar
-1 votes
1 answer
264 views

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(); ...
mooko's user avatar
  • 33
1 vote
4 answers
196 views

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 ...
Ellie Lockhart's user avatar
0 votes
1 answer
122 views

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() -&...
allstar's user avatar
  • 123
3 votes
3 answers
696 views

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 ...
Eric Hepperle - CodeSlayer2010's user avatar
4 votes
3 answers
2k views

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 ...
Godsmith's user avatar
  • 151
11 votes
1 answer
5k views

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 ...
elbecker's user avatar
  • 121
1 vote
0 answers
69 views

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 ...
ganders's user avatar
  • 411
2 votes
3 answers
2k views

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 ...
Fred's user avatar
  • 509
-3 votes
1 answer
560 views

If my foo.py is merely foo_var = 1 and bar.py is merely import foo, I know I can write baz.py that says from bar import foo_var, but should I? (Or should I instead do from foo import foo_var?) Is ...
Pro Q's user avatar
  • 697
24 votes
10 answers
7k views

While I am reading The Pragmatic Programmer e2, I came across Tip 38: Crash Early. Basically, the author, at least to my understanding, advises to avoid catching exceptions and let the program crash. ...
Hawk's user avatar
  • 487
9 votes
12 answers
5k views

I see a lot of reasons to use binary over text-based formats. With binary, I find it a lot easier. I can use fread(data, sizeof(struct DataStruct), 1, fileptr) to read, or fwrite to write data. I ...
Block of Diamond's user avatar
2 votes
4 answers
986 views

My requirement is simple, I want to be able to count the number of bits in a number. With a little bit of research, I found that MSVC has __popcnt, GCC has __builtin_popcount and so on. At this stage,...
user avatar
3 votes
2 answers
230 views

I have a Desktop application that was saving some data to %AppData%\MyApp\old.txt (roughly 1KB). I have decided to rename the file that I write to to new.txt. If I push out this change, customer ...
pushkin's user avatar
  • 141
20 votes
8 answers
23k views

Consider the following: public boolean maybeUpdateTime() { if (this.timeReference.isAfter(lastInterval.getBeginning()) { this.timeReference = lastInterval.getEnd(); lastInterval = ...
Lucas Noetzold's user avatar
4 votes
1 answer
580 views

Recently I had a conversation with a colleague, who proposed that a whole app could rely on an event aggregator (or message bus). I think this is a really good pattern if someone wants to decouple ...
Shadow's user avatar
  • 361
1 vote
2 answers
384 views

I just started reading The Pragmatic Programmer e2. I came a cross the topic of avoiding Duplication with Data Sources, which I did not fully understand. The pragraph reads as follows: Many Data ...
Hawk's user avatar
  • 487

1
2
3 4 5
32