308 questions
Best practices
0
votes
0
replies
19
views
Chart.js + TypeScript: separate helper methods vs. single config function — better practice?
I'm building a Chart.js timeline chart in Angular/TypeScript and I'm wondering which approach is considered better practice.
Option A — Separate helper methods:
private buildChartConfig(
record: ...
Best practices
0
votes
1
replies
107
views
Best practices for breaking down long methods and modularizing large features in Spring Boot
I’m working on refactoring a legacy codebase with a method that’s grown to several hundred lines.
The method mixes many responsibilities and is difficult to maintain.
Because the codebase is old, I ...
1
vote
3
answers
120
views
Maintainable INSTEAD OF trigger with Identity columns
I want to add a trigger to my table to validate the data before allowing insert or update.
For example, something like this:
CREATE TABLE MyHorribleLegacyTable (i int IDENTITY, name char(100),
...
2
votes
7
answers
835
views
Avoid repetition of strings in SQL query
I have a SQL query where the list of strings is repeated twice: ('foo', 'bar', 'baz', 'bletch'). What is the most maintainable method to avoid such repetition and make this code more DRY?
I am not ...
-1
votes
1
answer
83
views
How to maintain enums (and adding new values) in a very large codebase
In a very large and old codebase, suppose we're using a database column status with enum values as NEW, IN_PROGRESS, COMPLETED, REJECTED.
Now this status is used in multiple conditions in code like
if ...
3
votes
1
answer
699
views
Angular How to easier maintain build in i18n translations
We use the build in i18n module for angular.
I successfully generated source file for my original lang (en). Then I copied the source file and created another file with (es) translation.
It is easy to ...
8
votes
3
answers
666
views
Python: Should I save PyPi packages offline as a backup?
My Python projects heavily depends on PyPi packages.
I want to make sure that: in any time in the future: the packages required by my apps will always be available online on PyPi.
For example:-
I ...
1
vote
1
answer
466
views
Is calling an API from inside an initializer in Python bad?
I have a Python class that requires some data in order to be initialized. This data is usually obtained using a function from another module, which makes calls to an API. One of the parameters my ...
2
votes
1
answer
144
views
Invoke overridden virtual methods of a derived class without exposing them
I would like to write a function f which invokes two overridden virtual methods, op_1 and op_2, of a derived class in a particular order, without exposing those methods beyond f and the methods' ...
0
votes
1
answer
161
views
How we can achieve writing reusable and modular code
How we can achieve writing reusable and modular code in an Enterprise code. What are the basics to get started
0
votes
1
answer
135
views
How to maintain Composite Pattern efficiency with increasing components?
I am currently writing some code in C# and have decided, at one point, that for my specific case a composite pattern will be useful.
However, there is clearly a performance problem in my code once I ...
2
votes
1
answer
230
views
Refactoring instanceof
On my current project, I need to convert values between types that are only known at runtime: the input type is the JSON type of the input, and the output type is defined in a configuration file ...
1
vote
0
answers
52
views
Should I declare a number as constant if it is passed as a parameter to a meaningful named function?
Suppose we a validation code similar to the following:
Rule(account => account.CompanyName).MaxLength(50)
Or
Rule(account => account.Balance).MustBeGreaterThan(0)
Do we still call the numbers ...
0
votes
1
answer
88
views
Prevent improper use of a User Defined Data Structure and Making DS resuable
Objective:
Define a Priority Queue Implemented with a Max Heap
Provide as much type safety as possible and provide an implementation that is flexible/reusable (even though python is dynamic and only ...
-1
votes
1
answer
380
views
Recommendations to learn Refactoring
I have learned clean code and some people advise me to learn refactoring. So what are the best resources to learn refactoring and code smells in practical way? I tried to learn from Martin Fowler book ...