All Questions
Tagged with programming-practicespatterns-and-practices
70 questions
39votes
8answers
10kviews
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 ...
1vote
2answers
155views
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 ...
84votes
8answers
73kviews
Is modifying an incoming parameter an antipattern? [closed]
I am programming in Java, and I always make converters sort of like this: public OtherObject MyObject2OtherObject(MyObject mo){ ... Do the conversion return otherObject; } At the new ...
2votes
4answers
3kviews
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 ...
29votes
9answers
8kviews
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 ...
-1votes
1answer
100views
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 ...
40votes
6answers
38kviews
Try/Catch/Log/Rethrow - Is Anti Pattern?
I can see several post where importance of handling exception at central location or at process boundary been emphasized as a good practice rather than littering every code block around try/catch. I ...
-1votes
3answers
872views
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 ...
-1votes
1answer
107views
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 = ...
0votes
2answers
933views
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 ...
8votes
5answers
983views
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 ...
17votes
4answers
7kviews
Why does Facebook obfuscate the names of CSS classes?
If you look at the source code of a website such as Facebook, you'll see many classes as such: <div class="_cy6 _2s24"><div class="_4kny"><div class="uiToggle _8-a _1kj2 _4d1i _-57 _5-...
43votes
6answers
14kviews
Should I place functions that are only used in one other function, within that function?
Specifically, I'm writing in JavaScript. Let's say my primary function is Function A. If Function A makes several calls to Function B, but Function B is not used anywhere else, then should I just ...
1vote
1answer
822views
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 ...
18votes
7answers
27kviews
Why unused variables is such an issue?
I was cleaning unused variables warnings one day, and I started to ponder, what exactly is the problem about them? In fact, some of them even help in debugging (e.g. inspect exception details, or ...