Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [code-quality]

Questions for best practices for writing high quality code.

Filter by
Sorted by
Tagged with
0 votes
1 answer

Our php codes base has 6 different ways to do INSERT … ON DUPLICATE KEY UPDATE, how do I fix it?

Our php codes base has 6 different ways to do INSERT … ON DUPLICATE KEY UPDATE. It happened over years because the php framework is evolving and my team members come and go, although I won't say we ...
Qiulang 邱朗's user avatar
2 votes
3 answers

Displaying a list of similar but different objects without resorting to type checking

I'm creating the UI for a "Point of Sale" type page. You can add orders, grouped orders, and custom items to your transaction, and it should display these in a list so you can see what you ...
Conman_123's user avatar
0 votes
1 answer

How to deal with very complex codebase? [duplicate]

I recently changed my job to a big MNC and the code I am exposed to is highly complicated, difficult to read and understand. Although it is divided in microservices and runs on local I have to keep ...
Surya Saini's user avatar
17 votes
8 answers

How to be (more) critical during Code Reviews? [closed]

I'm a Software Engineer who sometimes need to review the code of my fellow team members. I often look at the source code and think; this looks fine. I'm having a hard time to think critical about it. ...
Jay's user avatar
  • 289
21 votes
4 answers

In C, if I am passing a file descriptor to a function, should I close it in the function or in the place where I called the function?

I have a situation like the following: int fds[2]; pipe(fds); // Write lots of stuff into fds[1] close(fds[1]); do_stuff(fds[0]); // Should I close fds[0] here or at the end of do_stuff? Which one ...
eem's user avatar
  • 329
19 votes
9 answers

Why should we reuse code as binary modules instead of copy/pasting?

So this is a basic question that was asked by a junior developer (not in these exact words). He had worked on a feature which was used in multiple projects. The main feature can be easily isolated and ...
nakiya's user avatar
  • 387
18 votes
6 answers

Is setRGBColor(32,128,192) a valid use of magic number?

According to When is a number a magic number?, I know magic number should not exists, so I know the following code about creating a Label from some UI framework and set the color RGB needs to be ...
wcminipgasker2023's user avatar
38 votes
11 answers

Should developers fix bugs in their own code? [closed]

This is more of a philosophical question. I have recently started working on a new team and I see here a pressure on developers to fix bugs in their own code. Whenever a bug is found in a feature, the ...
emperor-shallots's user avatar
1 vote
1 answer

Is module scoped initialisation considered a bad practice?

A module app.js includes another module service.js. The service.js module/file contains some functions but also does some module scoped initialisations(registry variable). // service.js const ...
Cap Barracudas's user avatar
0 votes
2 answers

Is usage of "with" prefix acceptable for filter methods that are specific(not generic) [closed]

I am not a native english speaker so I have the following question related to naming I have a class that has generic filter method of type: filter(Predicate predicate) In the same class I have some ...
Alexander Petrov's user avatar
1 vote
1 answer

Working with a poorly written piece of software as an entry-level developer with no support or documentation [duplicate]

I'm and entry-level developer straight out of college. I am the only developer at this company. I feel the challenges I face are different to most people working with sub optimal or very poorly ...
mpAppProg's user avatar
2 votes
5 answers

Is it a code smell for a factory to have many methods?

I have a testing project, in Katalon Studio, that uses data classes, called models. This is a conscious design decision. Also a conscious design decision, is the decision to separate the concern of ...
Mike Warren's user avatar
10 votes
8 answers

When are try/exceptions not an anti-pattern?

I just finished a discussion with colleagues regarding the use of exceptions in code. Here is the code (pseudocode) that they had written: resp = fetch(URL) if resp.status_code != 200: return ...
Daniel's user avatar
  • 517
3 votes
5 answers

How do I find indicators to show that code review is improving quality of a code base?

I was asked to review and handle merge request for a code base, which has been contributed by dozens of programmer with basically no regulation (or perhaps there was but nobody follows), so I set up ...
Rahn's user avatar
  • 147
-1 votes
1 answer

What is point of having certain microservices making another API call in the same service

I was going through an old, largely untouched part in my company’s codebase and found one API. It does the following things. A POST API with path host/entities/trigger which fetches a list of entity ...
elliot's user avatar
  • 11
2 votes
3 answers

What would be a good metric of quality of a single bug fix?

If you solve a bug in a poor way, it might result in even more bugs in the future, so I need a way to validate if the fix was actually good. Time between the bug assignment and issue closed doesn't ...
ayowhatthedogdoin's user avatar
1 vote
2 answers

Best practice for updating object fields (with values calculated in methods)

What's the cleanest and most coherent way to assign a new value to an object field when the calculation of that value is outsourced to another method? The most obvious way would just be to update the ...
Lord Cat's user avatar
  • 139
41 votes
10 answers

What is the most efficient way to continue developing a piece of software in the long-term?

For my job, I work on multiple different scientific software projects, as well as general administrative tasks that go hand-in-hand with any 'office' job. Thus, any given working week could involve ...
simonp2207's user avatar
2 votes
2 answers

Should I abstract function calls with duplicate arguments?

I have an intuition, that I'd like to read what others have talked about. To me, it seems fairly intuitive that when you have a function which is called multiple times with the same arguments, it ...
Thiago Pereira Maia's user avatar
-2 votes
2 answers

best practice to recover or handle requests that is half completed or partially failed [closed]

Assume I have a request:'/order', ()=>{ // task 1 // task 2 // task 3 }) and task1 and task2 is completed but task3 failed. for example a user paid order successfully but saving order ...
Ali Shefaee's user avatar
27 votes
5 answers

Dry running a function

I have a function with a sensitive operation: function doSomeThingSensitive() { customers = getAllCustomers() for each customer in customers if customer is from Europe Give ...
Cap Barracudas's user avatar
-1 votes
3 answers

How to improve coding while/though working? [closed]

How could I improve my coding skills aka skills in coding while being in a job? My job is mainly coding and so, my coding should be better and better over time. But the struggle is: There are always ...
Ben's user avatar
  • 117
0 votes
1 answer

Is there a reason why you shouldn't use 'integration variables'?

I tend to create a variable whenever I need an uncircumstantially same value as to that of an earlier value more than once (the values are not happening to be the same by chance rather they actually ...
Nae's user avatar
  • 197
2 votes
2 answers

Is "pass through" boilerplate code the trade off for improved encapsulation and composition?

Is it a sign that something is wrong with the code design if you end up with a layer of functions that just forward request to a component? Exposing the component would avoid this but hurts ...
gjcapl's user avatar
  • 29
1 vote
1 answer

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 ...
mehrdadep's user avatar
  • 121
-2 votes
1 answer

Assumptions versus no assumptions - where do you draw the line? [closed]

In our line of work as software engineers, we can write code that assumes various things outside its scope or architectural boundary, in order to save performance, time, and on defensive coding ...
SpiritBob's user avatar
  • 105
0 votes
1 answer

Python code template for scripts to be run in batch

I will be writing a number of Python scripts which will be run in batch daily on a Windows server. I am trying to develop a template for writing the scripts. My intention is to use a configuration ...
Garrie Powers's user avatar
3 votes
2 answers

GetOrCreate method for a database operation

I have read this thread: Is it bad coding practice to create something in a get if it does not exist? But, my question involve a method which gets a record from a database or creates it if it doesn't ...
MrChudz's user avatar
  • 139
4 votes
3 answers

Should try-catch blocks be used when calling functions that already have them?

In JavaScript, if I have try catch blocks in a function that is meant to be called from another function, should I also put them in the calling function or just let the called functions handle them. ...
Russ Bain's user avatar
  • 143
3 votes
4 answers

how to perform code review among different types of developer?

My develper team includes Android, iOS, PHP, Web Front, .Net developers, but every type of developer only 1 person, and they don't know other's programming languages very well. We have setup Jenkins ...
Tealc Wu's user avatar
  • 149
1 vote
3 answers

How to track temporary fixes

Whenever I do temporary fix I want it to really be temporary. However, there is no way to come back to it later, as the fix might be a part of a bigger issue. Let's imagine that we have for some ...
Random Guy's user avatar
1 vote
3 answers

Which code to copy-paste and which to centralize?

In a fairly complex system with a dozen or more git repositories, most of them are done in a cookie-cutter fashion. What is or would be your best approach to deal with duplication? In my opinion the ...
gurghet's user avatar
  • 149
0 votes
1 answer

quality management on SQL stored procedures

I've always developed my own applications and use certain criteria to evaluate if the code is acceptable from a quality perspective. Now I've switched jobs and have to among other things maintain ...
denbrau's user avatar
1 vote
1 answer

Is bytes as request parameters as rest endpoint a security risk?

I am working on an application where user can send in an absolute path of an image or URL as string in API endpoint. My code is able to handle that. Now I have been asked to add the code which can ...
Samvid Jhaveri's user avatar
0 votes
0 answers

Best way to trigger javascript error to go to catch block

I have a couple of doubts regarding the quality of my code. I'm working on a helper function (for KoaJS) where I'm validating a Firebase ID token. If it is valid, I return the decoded token; otherwise ...
Guswiri Salpia's user avatar
1 vote
3 answers

Strategies for introducing or enforcing new linting or other code quality tooling rules

I'm in a situation where there is a code base that has TypeScript and ESlint but: There are a lot of type errors (code compiles despite errors using Babel) There are a lot of lint warnings. We may ...
dwjohnston's user avatar
  • 2,553
1 vote
2 answers

How to organize logic for table-like feature set? Looking for architecture pattern advice

I have a table-like feature set in a game. What it means is I have 10 types of battle, and 10 types of features related to battles, like hints, start/end logic, rewarding/spending resources, statistic ...
Pavel Oliferovskiy's user avatar
4 votes
8 answers

How to scale code reviews

My boss say we should find a way to scale code reviews at our company. As it is right now, we have about 16 software developers spread across 4 different teams/squads, but soon the company will close ...
Vini.g.fer's user avatar
-4 votes
1 answer

Python: Help with replacing list comprehension with generators [closed]

I have written the following code which takes a coord_list of points in a 2D coordinate system, a center and a radius and returns a list of all points from the list having distance at most radius from ...
sampleuser's user avatar
2 votes
1 answer

How do pull requests fit into a development process?

In my software engineering career I have never worked with pull requests. Probably because I only ever worked in relatively small teams (5-16 people) and only on projects that were structured well ...
Aleksander's user avatar
-4 votes
3 answers

Methods that receive buffer objects AND return another Object - is that bad design?

The Argument Some say that if you write a method that receives a buffer, iT MUST RETURN VOID -> the buffer is your exit point. Do not abuse the methods by receiving buffers AND returning a another ...
linuxunil's user avatar
  • 1,451
0 votes
1 answer

Code review patterns for multiple teams working on a single product

We're scaling out development on a single product from a single team to multiple teams. What are the patterns to ensure coding style, patterns and technology is used consistently? Is there one person ...
LazyCoder's user avatar
  • 617
69 votes
8 answers

In code review, should I ask to do a refactor outside of the scope in a pull request?

I have been studying the best practices for a code review, and I was wondering what to do in the following scenario: During a code review, I see potential improvements, but decide that they are ...
Tisp's user avatar
  • 817
1 vote
3 answers

Why are code readability and debugging arguments often expressed as a counter-argument for the use of generated LR parsers?

When it comes to using an LR parser generated by a tool, such as Bison, a disadvantage that often comes up as counterarguments is that the resulting parser will be unreadable and complicated to debug, ...
Foxy's user avatar
  • 219
0 votes
3 answers

How to arrange expected result model for test in a cleaner,readable way when the model contains many properties

In one of my projects I saw wrapping the expected results as a static variable in non static class. The reason for doing so is to make the code more readable, so that the massive expected result model ...
Anjo's user avatar
  • 215
2 votes
1 answer

Converter implementation in Python: class versus module?

I've written a little library that uses the builtin ast library to convert between functions, docstrings, argparse .add_argument, classes, and [soon] more. Stubs look something like this, with ir ...
Samuel Marks's user avatar
-2 votes
1 answer

Code Base Analysis

Does anyone know of a methodology that can be used on a project file tree to identify dead files, dead code, unused libraries, etc. I have been thinking about this for some time as I seem to inherit ...
abz.b's user avatar
  • 13
1 vote
1 answer

Can I use singleton in a Flyweight factory and still be a valid GoF implementation?

For teaching purposes, I am trying to create a "something useful" example of Flyweight pattern using PHP. My idea was load some "intrinsic" data from a csv (link) to a pool and ...
celsowm's user avatar
  • 253
0 votes
2 answers

Who should describe the testing procedure of a bug?

I used to work for a software development company, and there they had following way of solving bugs and the according testing: The bug ticket is analysed by the developer. The developer solves the ...
Dominique's user avatar
  • 1,766
1 vote
1 answer

Cyclomatic complexity vs repeated code

we've a python function that can be achieved in 2 ways 1st method def complexity_1(x, y): if 2 == x and 3 == y: a=3 b=4 c = a + b elif 2 == x and not 3 == y: a =...
janardhan reddy's user avatar

2 3 4 5