2022 Developer Survey is open! Take survey.

Questions tagged [code-quality]

Questions for best practices for writing high quality code.

Filter by
Sorted by
Tagged with
-3 votes
2 answers
59 views

best practice to recover or handle a request 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 ...
user avatar
0 votes
0 answers
22 views

Add API for smartphone APP requests (Ionic6) to Flask APP working with browser requests

We have a working multi page python flask web MVC application using bootstrap. We are looking to create app for smartphones and we decided ionic would be the better framework (along angular) since we ...
user avatar
  • 101
27 votes
5 answers
6k 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 ...
user avatar
-1 votes
3 answers
177 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 ...
user avatar
  • 117
0 votes
1 answer
275 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 ...
user avatar
  • 197
2 votes
2 answers
197 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 ...
user avatar
  • 29
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
-3 votes
1 answer
100 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 ...
user avatar
0 votes
1 answer
129 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 ...
user avatar
0 votes
0 answers
35 views

How to best process unreliable conditional data on the frontend?

For the past couple of weeks, I was working on creating a simple visual display of some data as bullet points. I already have a solution for the title but I wanted to post this question, to hopefully ...
user avatar
2 votes
1 answer
287 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 ...
user avatar
  • 129
3 votes
3 answers
1k 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. ...
user avatar
  • 133
3 votes
4 answers
295 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 ...
user avatar
  • 147
1 vote
3 answers
162 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 ...
user avatar
1 vote
3 answers
155 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 ...
user avatar
  • 149
0 votes
1 answer
111 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 ...
user avatar
1 vote
1 answer
98 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 ...
user avatar
0 votes
0 answers
51 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 ...
user avatar
1 vote
3 answers
303 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 ...
user avatar
  • 2,412
1 vote
2 answers
144 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 ...
user avatar
4 votes
8 answers
631 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 ...
user avatar
-4 votes
1 answer
141 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 ...
user avatar
2 votes
1 answer
414 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 ...
user avatar
-4 votes
3 answers
138 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 ...
user avatar
  • 1,411
0 votes
1 answer
137 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 ...
user avatar
  • 587
68 votes
8 answers
14k 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 ...
user avatar
  • 807
1 vote
3 answers
158 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, ...
user avatar
  • 219
0 votes
3 answers
88 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 ...
user avatar
  • 215
2 votes
1 answer
186 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 ...
user avatar
-2 votes
1 answer
81 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 ...
user avatar
  • 13
1 vote
1 answer
87 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 ...
user avatar
  • 243
0 votes
2 answers
437 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 ...
user avatar
  • 1,631
1 vote
1 answer
219 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 =...
user avatar
-3 votes
2 answers
102 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 ...
user avatar
-3 votes
1 answer
75 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 ...
user avatar
58 votes
12 answers
7k 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 ...
user avatar
-5 votes
1 answer
56 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 ...
user avatar
-1 votes
1 answer
134 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 ...
user avatar
  • 375
8 votes
9 answers
6k views

Returning true/nothing instead of true/false?

Is it OK to have a function that returns true/nothing instead of true/false? My examples use JavaScript, but I'm wondering about the general case, not attached to one specific language. The subjects ...
user avatar
-2 votes
1 answer
234 views

Design pattern for a switching between APIs with no code changes

I'm trying implement in JavaScript/Node.js a data upload functionality. I want to be able to switch between different storage providers, e.g. AWS, GCP, Azure, with no code change, for instance, via ...
user avatar
  • 135
4 votes
1 answer
585 views

The case against path expressions in #include directives

I am preparing for a discussion with my fellow programmers which will be about their use of the C/C++ #include directive. The codebase which I have to retrofit to Automotive standards is using ...
user avatar
-4 votes
3 answers
220 views

How to Replace Many if Statements for many types

I have many dependent statements. What is the best approach to handle these cases dynamically? Example enum UserType { case buyer case seller } enum ViewType { case active case ...
user avatar
  • 101
0 votes
2 answers
351 views

Model View Controller: Can the Model access the view directly?

According to my understanding, in the MVC design the Model can only receive the functions calls from the Controller and not from the View directly. Is it true that the Model can change or access the ...
user avatar
5 votes
1 answer
480 views

How to modernize large legacy Fortran program? [duplicate]

Problem Background Recently, I joined a government agency as a software engineer/scientist/analyst. Previously, worked in software industry - gained 3 years of software engineering experience at ...
user avatar
  • 325
-2 votes
1 answer
162 views

Proper program structuring in Python

So, recently I have been doing a lot of programming in Python. I have noticed that my programs can be somewhat hard to read. I usually have one main class which does everything, sort of like this: ...
user avatar
6 votes
3 answers
3k views

What does it mean for a method or a function to do one thing? [duplicate]

What does it mean when you say that a method or a function should do only one thing? Can it do a few things as long as it has a cohesive name? Should we avoid routines with the word "and" in them? ...
user avatar
  • 429
56 votes
6 answers
22k views

Functions that simply call another function, bad design choice?

I have a setup of a class that represents a building. This building has a floor plan, which has bounds. The way I have it setup is like this: public struct Bounds {} // AABB bounding box stuff //...
user avatar
  • 1,953
5 votes
1 answer
230 views

What is 'hand native' optimization?

In the seminal 1989 Microsoft memo Zero-defects code by Chris Mason (which is still a great read even today), the term 'hand native' is used several times. Some examples: 1. Users measure our ...
user avatar
  • 300
2 votes
1 answer
166 views

Better way to implement a feature with turn on/off based on a flag

I'm trying to implement a feature with option to turn it on/off based on a flag. I'm doing it in the following way which I feel like a overkill, public interface Feature { public interface ...
user avatar
6 votes
2 answers
727 views

How to avoid code review bottlenecks when some of the team pair program

There is a school of thought that describes code reviews as the number one priority activity for all developers in a sprint since they are either: a) A source of unrealised value b) A source of bugs ...
user avatar
  • 9,607

1
2 3 4 5
13