Questions tagged [code-quality]

Questions for best practices for writing high quality code.

Filter by
Sorted by
Tagged with
18 votes
6 answers
4k views

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

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 fixing bugs in their own code. Whenever there is bug found in a feature, ...
emperor-shallots's user avatar
1 vote
1 answer
89 views

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

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

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

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

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
  • 331
3 votes
5 answers
324 views

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

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

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

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

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

Hosting/Imbedding Angular Application in ASP.NET MVC Application

Currently, I am working on an existing project, my team creates a new Angular-based application with the usage of some Angular modules that are developed in the company, in addition, there are some js ...
genichm's user avatar
  • 124
2 votes
2 answers
201 views

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

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

Assume I have a request: app.post('/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
7k views

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

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

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

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

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

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
2 votes
1 answer
657 views

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
  • 129
4 votes
3 answers
5k views

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

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

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

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

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

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

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

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,543
1 vote
2 answers
151 views

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

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

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

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

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,441
0 votes
1 answer
232 views

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
  • 607
69 votes
8 answers
15k views

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

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

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

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

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

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
  • 243
0 votes
2 answers
532 views

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,707
1 vote
1 answer
350 views

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
-3 votes
2 answers
109 views

Inspection code reviews, is it outdated today?

I'm a big proponent of peer reviews on every change, like with pull requests etc, however I'm questioning if this type of review alone is enough. For one, I have trouble with reviewers 'missing the ...
user3317492's user avatar
-3 votes
1 answer
79 views

Might be inheriting a php spagetti project. Full rewrite in different tech stack? [duplicate]

I'm in dire need of some help. My background is from python, js and ruby, with using frameworks to provide good structure. A potential client has an internal app which does quite a bit of stuff. This ...
Stephan Bakkelund Valois's user avatar
58 votes
12 answers
8k views

Is it common to have to iterate on a design due to overlooking problems with it?

When I'm designing a system for a program, I often make misjudgements that will prevent the design from either working, being maintainable, easy to use or all the above. This means I will usually have ...
Sebastian King's user avatar
-5 votes
1 answer
84 views

Should code be refactored to be more unit testable or should a framework like PowerMock be used?

Assume there's some code that's already in production that needs some unit testing. Generally speaking, would you want to refactor this code that's already in production by adding things like adding ...
JobHunter69's user avatar
-1 votes
1 answer
137 views

Is never touching merged code again realistic?

My boss has this idea in his head that once something gets through code review and lands in develop it should be "good enough" to never be touched again. He is not very pushy, he has been a ...
DFENS's user avatar
  • 375

1
2 3 4 5
13