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.

learn more… | top users | synonyms

0
votes
0answers
47 views

Heuristics/rules for programming to an interface

I am struggling with applying the "programming to an interface" guideline because I can't seem to decide in which situations it is necessary and in which ones it's overkill (or even counter productive)...
0
votes
1answer
46 views

How do I manage a large state graph when building a scaleable finite state machine?

Lately I've been working on a project that involves parsing a toy domain-specific-language. While building it out, I realized that an efficient way to handle parsing tokens would be to represent the ...
2
votes
2answers
127 views

Tag based programming

I don't know if this is a thing but here's a silly idea. Often there are cases when you have to refactor code such that you need to change code pertaining to some particular area. This may involve ...
7
votes
4answers
377 views

Is it bad practice to reuse method parameters?

There are times when I will need to modify a value passed into a method from within the method itself. An example would be sanitizing a string such as this method here: void SanitizeName(string Name)...
4
votes
2answers
176 views

The order of values in ? : expression

Which construction is more readable: someVariable == null ? SOME_VALUE : someVariable; // avoids negation someVariable != null ? someVariable : SOME_VALUE; // normal situation first I have to ...
1
vote
4answers
237 views

Are some people just unable to code? [closed]

So for the past year or so, I've been trying to self-teach myself programming. The problem is, every time I start to try and teach myself (like on Codecademy and such) I start off great and then ...
0
votes
0answers
33 views

Strategies to manage approvals of orders together with a log

Backgound I need to develop a system that handles orders that needs to be approved by supervisors (or users with more privileges). A log have to be implemented to show who created the order and when, ...
0
votes
0answers
31 views

Debugger directions

I am running an old DOS executable file that runs a set of instructions to test an electronic component via com1 (RS-232) on a pc. The 16bit software has 8 main routines and some subroutines within to ...
0
votes
0answers
44 views

Designing a plugin-based platform - control vs. functionality

TL;DR I want to build a host application/framework for plugins. On the one hand I want to enable plugins to do anything and on the other hand I want to have control over them. Background I'd like ...
-1
votes
0answers
25 views

Improving scripting / programming efficiency in R

Suppose I have a huge function: huge.function <- (my.dataframe, my.option = TRUE) { my.dataframe <- short.function.1(my.dataframe) my.dataframe <- short.function.2(my.dataframe) my....
-1
votes
0answers
27 views

Python public package development environments

I have a package on my computer I use for personal, general use code. I build it with python setup.py develop --user which works very well for making changes to the code and it taking effect without ...
1
vote
2answers
110 views

How to do dynamic dimension for loops

I have a for loop in C# as below, int[] dim1, dim2, dim3; //Initialize dim1, dim2 and dim3 for(int i = 0; i < dim1.Length; i++) { DoSomething1(i); for(int j = 0; j < dim2.Length; j++)...
0
votes
0answers
35 views

How can incorrectly scoped variables cause issues between users/requests in web apps

I've had some errors that have arisen in a recent web app I've built that have been fixed by being more diligent in locally scoping variables. The issues happened "sometimes" as in very rarely. This ...
1
vote
2answers
97 views

Planning to convert PDF to JPG, Annotate the image, Reconvert to PDF

I have a feature where scanned exam answer books need to be digitally annotated and marked. The scanning portion of the work is with another vendor who refuses to scan in any format other than PDF as ...
7
votes
1answer
223 views

How do I feel more productive after programming? [closed]

I really enjoy the actual programming part of programming, and actually writing the code, and figuring it out. But on this project I've been working on, most of my time has been spent on kind stupid ...
0
votes
0answers
135 views

Any Special Practice On How To Read Code? [duplicate]

We know so much articles and best practice on how to write a better code. Class decoupling, reversible engineering decision, clear responsibility, etc. But how about best practice on how to read code? ...
2
votes
3answers
130 views

Should I only declare the variable as integer if I can perform calculations on it?

Been thinking this for a while now, for example I have a UX that let's the user choose what IP to connect. I have numericUpDown1, numericUpDown2, numericUpDown3, numericUpDown4 to limit the user to ...
1
vote
1answer
35 views

Preparing multiple serial ports with multiple TCP in my project that I can enable or disable if I want

I have intermediate level of understanding on how TCP and serial works, I've also been able to develop system that uses 1 TCP client and 1 Serial 2 Serials 1 TCP Server 1 TCP client My problem is ...
5
votes
5answers
306 views

Do you generally send objects or their member variables into functions?

Which is generally accepted practice between these two cases: function insertIntoDatabase(Account account, Otherthing thing) { database.insertMethod(account.getId(), thing.getId(), thing....
2
votes
1answer
137 views

Choice of variable names and types in graph algorithm

I am learning algorithms and data structures from this awesome resource Algorithms. Rather than doing dry reading I am trying to re-write all the code myself so that I can learn coding as well as ...
1
vote
1answer
66 views

Is an all-encompassing enumerator appropriate?

I will illustrate the problem with a specific case. Suppose we have a bit-flag style enumeration type defining different kinds of validations. It's tempting to define an enumerator like ...
1
vote
3answers
238 views

How to store many global variables?

I have around 30 not-changing "objects" (the amount of them is final, no more can be added or removed). Each object has an id as well as some booleans describing what the object is and what it isn't. ...
7
votes
4answers
333 views

Is it acceptable to declare objects of the same type, within themselves?

Is it acceptable to declare new objects (and return them) from within the same object, as in the example below? Or, is it better to move it to some kind of handler class? public class Person { ...
6
votes
3answers
181 views

Is it better to try and implement incomplete code, or write your own?

Our application is a 6-year old legacy application made by out-of-house contractors. Occasionally we stumble upon the skeleton of something they put together but never implemented, and it causes us ...
30
votes
5answers
6k views

Why do we need enums in dynamically typed languages?

I was reading some code here and saw that an enum is used to store names of html tags. Why do we ever need to do this? What benefit do I get using this strategy? I know that how useful enums are in ...
24
votes
8answers
4k views

Wouldn't it be beneficial to write tests during code review?

A colleague of mine came up with an idea that I found interesting. Wouldn't it be beneficial to write tests during code review, by the person doing the review assuming that we don't do TDD? For ...
42
votes
5answers
4k views

How to avoid typical “dynamic language mistakes”?

I've recently poured a couple of hours into JavaScript because I wanted to benefit from the massive userbase. Doing that I have noticed a pattern that most people attribute to dynamic languages. You ...
0
votes
2answers
64 views

Method to mask variable names in C++ files (cpp, h) and create an intermediate API?

I have a project which involves using C++ files along with an API on a local PC to communicate with a remote server app, and for sake of maintaining a semblance of non-disclosure with any hired ...
5
votes
2answers
129 views

Always upgrade to latest stable release of every library , good or bad practice? [closed]

So we are writing medium size software,and it has two parts frontend is written in angularJS and backend in laravel. Laravel provides api and nothing else. Now very often one of many dependencies ...
-4
votes
2answers
110 views

Should one always start a boolean with “is” or “has”? Or write it as it makes more sense grammatically?

Examples: isKeyValid -> keyIsValid hasPostThumbnail -> postHasThumbnail The first case is easier to remember (convention). The second is easier/more natural to read. Which should I use?
2
votes
2answers
31 views

Refactor using CTI or create new Entities

I'm currently developing on a rather large e-commerce application that handles multiple different business-fields. Like every e-commerce application we have a Concept called an Order which has one or ...
35
votes
5answers
3k views

When should I extend a Java Swing class?

My current understanding of Inheritance implementation is that one should only extend a class if an IS-A relation is present. If the parent class can further have more specific child types with ...
3
votes
2answers
171 views

Using “partial” type to shorten main class file

Is it a normal practice, or a sign of a bad design? For example I have a function that loads prefabs in a main logic class nearing 200 lines, and I can either move it out into a separate file ...
2
votes
2answers
89 views

Best practices for getting data by different criteria

I have one BL function and one SQL stored procedure (let's name it: getPersonDetailsById) which returns person details by passing his PersonId. Now I need to get the same details (data table) but by ...
1
vote
2answers
90 views

Is it a good idea having default static variables for new instances?

OK let's say I have something like this: public class MyObject { public static int DefaultValue = 9 private int _value = DefaultValue; public int Value { get { return _value; } set { ...
4
votes
1answer
66 views

Common imports between many scripts in Python project

I'm writing an automated installation script for a bunch of software, in Python. The purpose is for the script to fetch compressed files from a directory and install/configure each utility or ...
0
votes
1answer
106 views

Best practices/patterns for generation PDF reports

I have PDF generation feature in my app. I am using iTextPDF for generating reports, so it works well. The problem is not exactly in pdf generation but in approach. Currently PDF generation code looks ...
1
vote
1answer
155 views

Improving a try/catch

I'm a python programmer trying to get to grips with Java's inflexibility; I'm trying to parse a date from a string into a Calendar object private Calendar parsedDate ( String dateString ) throws ...
6
votes
2answers
129 views

Ensure that callbacks registration and triggering don't cause infinite recursion

I just spent a long, miserable week debugging a stack-overflow in a C++/Qt application. The fundamental problem was that I had a function that accepted a callback, and in certain cases the callback ...
43
votes
15answers
12k views

How to write correct loops?

Most of time while writing loops I usually write wrong boundary conditions(eg: wrong outcome) or my assumptions about loop terminations are wrong(eg: infinitely running loop). Although I got my ...
1
vote
1answer
129 views

How to deal with states in front end?

This may sound as a naive question but its bugging me since a long time. I have the following scenario: I have written a new shiny Todo service with my favorite front-end and back-end framework. To ...
2
votes
5answers
798 views

Best way of writing comments in code [closed]

I was wondering how one should write comments in code. I mean, should a comment be a descriptive of what is done in code, like : //we have got array, now we iterate over it. code to iterate array ...
88
votes
13answers
12k views

How to warn other programmers of class implementation

I'm writing classes that "must be used in a specific way" (I guess all classes must...). For example, I create the fooManager class, which requires a call to, say, Initialize(string,string). And, to ...
3
votes
1answer
245 views

Is using a function inside a for loop bad practice?

I recently read somewhere that calling a function within a loop is considered bad practice. Is this true? So for example, if I had the following: function foo(value){ console.log(value); } var ...
2
votes
1answer
119 views

When making a change to a single table in our app, should we minimize the scope of our change, or follow best practice for css/jsp coding?

My co-worker has been assigned the task of editing one of our Java application's tables. She is almost done, but needs to make one final adjustment to the table - this requires her to add a CSS ...
0
votes
4answers
269 views

Why are getter and setter functions considered to be against OO design? Why they should be avoided? [duplicate]

http://www.javaworld.com/article/2073723/core-java/why-getter-and-setter-methods-are-evil.html If you need to change the way the object is implemented in such a way that the type of X changes, you'...