Programming Practices are the commonly or not so commonly used practices in development of software. These can include things like Agile Development, Kanban, Coding shortcuts, etc.
1
vote
1answer
58 views
Should a loop be nested inside an unchanging conditional?
I was reviewing some old code and stumbled upon a loop nested inside a conditional like this:
std::cin >> number; //number is used elsewhere, so should be preserved
if (number <= 10)
for ...
0
votes
1answer
41 views
Bad practice to use table column names as keys in JS when making XHR requests?
Is it OK to use table column names as keys in a key/val pair on the JS side when making XHR/AJAX requests?
In JS, I'll do something like this, where I specify the data to insert into the table, using ...
1
vote
3answers
88 views
Is it a good practice to split one commit into two, where one is content change, the other is style(indent) change?
Suppose I am to make a commit that wrapped a section of code inside another thing, so the section came to have 1 more level of indent. In diff it will show delete 100 lines, add 100 lines though all ...
3
votes
4answers
187 views
A DTO class having an ArrayList of its own type - is this considered a good design?
I came across a DTO class like the below one.
class PersonDTO {
private String firstName;
private String middleName;
private String lastName;
private String dob;
// some 50 fields ...
1
vote
2answers
63 views
Assigning dictionary values to variables before using them as function arguments
I find myself often having a function, for example authenticate:
authenticate(user, token):
# do authentication
and a dictionary created by reading a configuration file, like this:
conf['...
12
votes
3answers
472 views
When is it okay to use Parallel Arrays?
I've been running into code (new code) that uses what I call 'Parallel Arrays' or Lists. Meaning there are 2 arrays that contain related data and are linked by their position (index) in the array.
I ...
2
votes
0answers
80 views
Breaking a Large Python Project into Multiple Packages
I have a medium sized python program (12K SLOC) organized as a single python package with multiple subpackages:
proj/
setup.py
proj/
__init__.py
projfile1.py
subproj1/
...
1
vote
2answers
209 views
What is the simplest OS or platform upon which we can do SE today [closed]
What is the "simplest" operating system or platform upon which we can do Software Engineering in this day and age? Or, in other words, are there "minimum requirements" for OS & platform for doing ...
1
vote
3answers
422 views
Should I comment or remove any un-used code from my Solution?
I was working in a story and in last minute, I have been asked to hide something from UI and we will used it next release.
Should i remove it or comment it
Should i remove or comment anything ...
0
votes
1answer
51 views
MV(X) Patterns: How much nesting is too much? Is not enough?
Posts may be smaller than they appear! Skip the bulleted list.
Lemme Just Say...
I know that this is going to be largely (entirely...) opinion-based. Everyone has their own approach, and their own ...
3
votes
1answer
108 views
Ensuring Multiple Implementations are Valid
I'll preface this with a few classes that shows what I'm trying to do
interface IDataField { /* ... */ }
class DataFieldImplementationA : IDataField { /* ... */ }
class DataFieldImplementationB : ...
0
votes
0answers
51 views
Python good practice: feed into class dictionary or combine local dictionaries?
A question about good practice in python:
I have a function that is called by a lot of other functions, and generates hierarchical information that falls into different buckets. In this function, I ...
0
votes
4answers
280 views
Cleaner code practices for Java programming
What would be considered better, cleaner code from the following options? The code basically sends a file through a Socket using an OutputStream that encrypts it. The code does not look that basic ...
6
votes
3answers
772 views
Writing clean code without knowledge on the programmed topic
Are there any tips that can help me create clean code when I'm working with something poorly documented and completely new to me?
It is easy to write a clean code when we are writing something for ...
3
votes
3answers
257 views
Is it right to skip unit testing and go straight writing integration tests if there's no point of testing the unit in isolation?
According to Martin Fowler's article,
https://martinfowler.com/bliki/TestPyramid.html
It is advisable to write more unit tests than integration tests. Does this mean ideally that every unit of work ...
0
votes
1answer
60 views
API design - return which operations the user can perform
My Rest API returns a tree structure like this:
[
{
"name":"test old",
"id": 1,
"type":"a-object",
"spend":13,
"status”: “active”,
"children":[
{
"name":...
1
vote
4answers
139 views
Naming procedure conventions - Where to place adjective in a verb followed by an object convention
I am reading on Coding Complete book the following statement:
To name a procedure, use a strong verb followed by an object A
procedure with functional cohesion usually performs an operation on an
...
273
votes
16answers
23k views
Grokking Java culture - why are things so heavy? What does it optimize for? [closed]
I used to code in Python a lot. Now, for work reasons, I code in Java. The projects I do are rather small, and possibly Python would work better, but there are valid non-engineering reasons to use ...
2
votes
3answers
174 views
Is it pythonic to replace a bash script with series of subprocess calls
I have a pretty simple bash script which consists of a bunch of one liners and some simple logic.
Its been recommended that I rip the bash script apart and rewrite it all in python using subprocess. ...
0
votes
2answers
105 views
Which End should start first? (MVC)
I am developing a small application and trying my best to make it as professional as possible in regards to design pattern etc.
It is a JavaFX app, and my app works fine but I am uneasy at the fact ...
3
votes
0answers
110 views
Understanding Typescript's views on inheritance
I have been struggling to understand the reasons why typescript developers choose the way they implemented inheritance.
What I would expect from any language supporting inheritance is these order of ...
-1
votes
1answer
113 views
Modelling research paper data in JSON
I need to design an UI to edit a research paper, I don't have enough knowledge about the research domain but still I tried to do my best and thought to design a normalized schema. I am describing the ...
1
vote
1answer
192 views
How do programmers retain knowledge of languages/technologies they don't use often? [closed]
How do programmers retain knowledge for languages/technologies they don't use on a regular basis?
Take for example the PC Assembly Book. The author states he rarely uses ASM at all. Yet he was able ...
1
vote
7answers
296 views
Repeated Instantiation of the Same Class in a Method
This is sort of a follow up question on Multiple Same Object Instantiation.
And I think, is not really language specific, so this is applicable to Java and C#?
Version A
public MyClass {
public ...
13
votes
2answers
849 views
What's this programming technique called?
I came across this programming technique while doing pair programming in an interview and couldn't find the name of it on google.
The idea is that you first write the expression which uses the ...
-4
votes
1answer
51 views
Standards used to implement an Android application?
I was wondering if someone could explain what type of standards are involved in developing an Android application. This is what the instructions specify:
These standards could be related to ...
1
vote
1answer
47 views
Best practice to test clustered production system
Say you have a big bloat of enterprise software and for every customer a different setup in terms of amount of appservers, search cluster size, webservers, database, loadbalancers and application-...
15
votes
5answers
471 views
Should older code be updated to use newer language constructs, or should outdated constructs be stuck with?
I want to make some enhancements in some still-functional code that was written a long time ago, before the programming language it is written in grew in features. In theory, the whole project uses ...
0
votes
2answers
83 views
Updating <some> database records while retaining old values
I am designing application for multiple users.
Their data (e.g Surname) might change in time.
But documents they create should contain their data for moment they created it.
For now i am adding new ...
0
votes
2answers
62 views
What's the correct way of computing money in programming (precision, repeating decimal) [duplicate]
This is the first time I'll be writing an application (personal) that involves money computation.
One of the potential issues I found is with regards to precision and repeating decimal.
Ex.
1 / 3 = ...
3
votes
0answers
58 views
Data Transfer Between Loosely Coupled Modules of an Application
Let's say we have a rather large project written in Python using the Django framework that is made up of multiple modules (proper term in Django is a project made up of multiple apps, but for the sake ...
1
vote
3answers
75 views
How to handle custom metadata in XML?
Backstory
I have an XML type document (SSML, which is used forText-To-Speech), which will be used to generate audio files when ssh transferred to a remote server. As such, I will need to include ...
7
votes
7answers
589 views
Is an inputless program redundant? [closed]
Are there useful programs that don't take inputs such as:
A user's keyboard input;
an interrupt from a clock;
data from another server etc.
A program that computed/printed out predefined data could ...
0
votes
0answers
59 views
Capturing keyboard events for a limited time
I'm trying to code a kind of simple video game where there are two kind of players:
Human Players: They enter an keyboard input
CPU Players: A random input is calculated
For Human Players there is a ...
3
votes
0answers
132 views
REST API URL parameter
We've come across the following case when working on REST API.
Users have the ability to expand the product deployment by installing custom JSON configurations. These configurations tend to be ...
3
votes
0answers
212 views
Is it a good idea to use a Spring MVC as an Frontend of a Microservice Architecture?
My microservice prototype currently has a Spring boot MVC application as its front-end. The application renders the View completely in the backend. It makes rest calls to other microservices like ...
4
votes
2answers
211 views
Where should I use abstract classes vs interfaces for a REST API client?
I'm trying to write a REST API client for practice and I'm having trouble figuring out how lay out the project.
The approach I'm taking right now has Actions, DomainObjects, Requests, and a class ...
39
votes
5answers
5k views
Is it considered an anti-pattern to read from STDIN from within a library?
While writing a library for a large project I'm working on at work, an issue came up which required a token to be sent to an email address, and then passed back into the code where it can then be used ...
2
votes
1answer
43 views
Calling repository inside a mapper
Is it bad practice to autowire and call a repository from within a mapper class? I have a mapper class that maps a model to an entity for JPA. In order to keep repository calls within my service, it ...
1
vote
1answer
47 views
Where does my GetOrderNumber logic sit in a layered approach?
In a good layered design of an application, where would logic that generates an order number for an order entity sit?
The logic will need to lookup and increment either a sequence or a table with ...
1
vote
5answers
238 views
Algorithm to determine if filename contains a “name” or not
I'd like some advice on how to approach this problem. I have a database of ~3000 pictures of people. Their names are built into the filename but there is no standard format. Here are some common name ...
3
votes
1answer
157 views
Block Scoped and Function Scoped Languages
I've noticed that some languages like C, C++, Java, Perl, and .NET Visual Basic have "block" scoping which means that a variable will only be defined within the specific code block it was declared in.
...
-2
votes
2answers
74 views
multiple uses for original software [closed]
How does a programmer figure out multiple uses or applications for the original software he/she has written. I am an artist who has designed a RPG game with several different and separate applications ...
6
votes
7answers
961 views
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 ...
7
votes
3answers
257 views
How to perform input validation without exceptions or redundancy
When I'm trying to create an interface for a specific program I'm generally trying to avoid throwing exceptions that depend on non-validated input.
So what often happens is that I've thought of a ...
41
votes
9answers
6k views
Is a JS Boolean having custom properties a bad practice?
In JS you can return a Boolean having custom properties. Eg. when Modernizr tests for video support it returns true or false but the returned Boolean (Bool is first class object in JS) has properties ...
1
vote
1answer
64 views
MIT, BSD, Apache License: Create application for client
I create Application for my client. I use some libraries released on GitHub under MIT, BSD and Apache license. I create also documentation (PDF file) where I would like to point what libraries and ...
0
votes
0answers
11 views
Helper methods for JUnits logic [duplicate]
I've found a lot about creating JUnits for helper methods, where a "helper method" means usually a non-public method of a class.
I would like to ask the same question but in different context. A "...
4
votes
2answers
214 views
Using tiny number of classes from a large library
I wrote a utils library (5 KLOC) that a lot of my projects use. I've also written a very small project (150 LOC) that needs just 1 or 2 of the classes in the utils library.
I really don't want to add ...
42
votes
10answers
4k views
Acceptable to rely on random ints being unique?
I've been implementing a network protocol, and I require packets to have unique identifiers. So far, I've just been generating random 32-bit integers, and assuming that it is astronomically unlikely ...