All Questions
Tagged with programming-practices patterns-and-practices
70 questions
1
vote
2
answers
155
views
how best to take a vertical slice of something already trivial?
Lets say I have a project which is something relatively simple like a copy checker for legal text files stored in git, that multiple people contribute to via pull requests that must be reviewed before ...
-1
votes
1
answer
100
views
Is there any benefit/viability to sharing models across API versions that have differing schemas
I have been asked to get involved with a Team that is currently having delivery issues for various reasons. During my review I came across an acceptance criteria on a user story;
If you call v1 of ...
2
votes
4
answers
3k
views
I wrote a class with "init" method. Should I call it from other class methods? Or leave it to the object user? (Code Design)
I have a java class with an init method. It's different from the constructor. The constructor just initializes the variables/fields. The init method connects to a database and performs some ...
-1
votes
1
answer
107
views
How can I prevent an object from being re-sanitized everytime it is passed as input to a function?
Suppose that I have a class named CharStream
Additionally, there are a large number of functions which convert their function input into a CharStream
def funky_the_function(_input):
input = ...
-1
votes
3
answers
873
views
Would Injecting dependencies in C# as default parameters be a bad practice?
Given the (old) debate over whether Singletons are overused/abused/are worth it - would it be a bad idea to inject the dependencies as default parameters? In this way, we could get rid of defining ...
0
votes
2
answers
933
views
Best pattern/practice to execute a multi-step code generation process
I am working on a project that generates an API with the possibility of doing CRUD operations based on a high-level description of the resources that the user would like to have in an application. In ...
0
votes
3
answers
125
views
Should we test private data (static objects in this case) to make sure it maintains its structure?
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: '...
0
votes
1
answer
672
views
Source of "... against the interface, not the implementation"
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 ...
1
vote
1
answer
822
views
Is it bad practice to run different versions of code in different environments? (i.e. test, prod)
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 ...
0
votes
2
answers
113
views
Calling general-purpose methods from the code that clearly needs only specific behavior
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)
...
1
vote
4
answers
222
views
When should a method depend on a data source and NOT have it declared as a parameter?
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 ...
0
votes
0
answers
57
views
What best practices/principles could help me improve my routine call placement?
I'm trying to change my module's outline since I feel I'm blocking some reuse possibilities, but I don't know how to justify it under the lens of good practices/design principles. Keep in mind this is ...
39
votes
8
answers
10k
views
Is it ok copying code from one application to another, both belonging to the same repository, to keep them independent?
Given a repository which contains two different applications A and B (e.g. bootloader and RTOS), is it ok to copy source code from A to B in order to avoid dependencies (include's, adding A source ...
8
votes
5
answers
983
views
Is it bad practice to add "false or" or "true and" to conditionals?
Is it bad practice to add false or ... or true and ... for the sake of promoting code genericness and/or ease of use?
As in:
SELECT *
FROM table
WHERE TRUE
AND IsEnabled
AND SomeField = some_value
...
29
votes
9
answers
8k
views
In software design, should an application remain agnostic regarding its usage with real world data / mock data?
Let me try to summarize a bit more with a simple example:
You're building a large application, a user portal for example, with feeds, news, account management, and a whole range of difference ...