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

11
votes
1answer
6k views

raw, weak_ptr, unique_ptr, shared_ptr etc… How to choose them wisely?

There is a lot of pointers in C++ but to be honest in 5 years or so in C++ programming (specifically with the Qt Framework) I only use the old raw pointer: SomeKindOfObject *someKindOfObject = new ...
21
votes
5answers
13k views

When and why you should use void (instead of e.g. bool/int)

I occasionally run into methods where a developer chose to return something which isn't critical to the function. I mean, when looking at the code, it apparently works just as nice as a void and after ...
1
vote
2answers
90 views

Best Practices for Automating Word Documents [on hold]

I recently started at a company as a Automation Developer. My job is to automate periodic reports (in Word) for all of our customers (~50), one for each. Each report is slightly different, so I am ...
0
votes
0answers
56 views

Heuristics/rules for programming to an interface [duplicate]

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)...
6
votes
4answers
7k views

Returning null or a empty value/throw exception? [duplicate]

Various programming books suggest that methods should not return null values (Clean Code for example). Instead of returning null default values (0 or empty string or empty object) should be returned ...
0
votes
1answer
47 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 ...
10
votes
4answers
502 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)...
37
votes
14answers
22k views

RESTful API design. What should I return if there are no rows?

I'm currently coding an API for a social network with the Slim Framework. My question is: What are the best practices when there are no rows to return in the json structure? Lets say that this call /...
2
votes
2answers
141 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 ...
1
vote
2answers
163 views

Is a an object Necessary or can I still use a DataTable

I'm currently working on a fund project and I have it set up so I get the holdings from my database and store in in to a DataTable to process. I've created a function where my Database results are ...
4
votes
2answers
177 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 ...
4
votes
8answers
545 views

Testing loses its effectiveness if all programmers don't use them

Let's assume you are convinced that the extra time spent unit testing has merit and improves production. Does that still hold up when everyone working on the same code doesn't use them? This question ...
2
votes
4answers
241 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
45 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 ...
14
votes
6answers
8k views

What technologies are used for Game development now days? [closed]

Whenever I ask a question about game development in an online forum I always get suggestions like learning line drawing algorithms, bit level image manipulation and video decompression etc. However ...
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 ...
26
votes
16answers
3k views

How often do experienced programmers have trouble getting their code to perform its intended purpose?

I'm kind of inexperienced with programming (ie less than a year) and I have recently been getting discouraged, mostly from not being able to solve problems with my own code (Not forgetting parentheses ...
2
votes
2answers
135 views

Does the type safety of a programming language implements it binding mechanism or vice versa?

I am really confused about the concept of Strongly typed programming language (AKA type safety enforcement).Based on multiple definition from Wikipedia source I can conclude from how I understood it ...
11
votes
7answers
9k views

Non-zero exit status for clean exit

Is it acceptable to return a non-zero exit code if the program in question ran properly? For example, say I have a simple program that (only) does the following: Program takes N arguments. It returns ...
-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 ...
19
votes
4answers
550 views

Using flat files vs database/API as a transport between a frontend and backend

I've got an application which has generated a rather heated discussion between a couple of the developers. Basically, it's split into a web layer and a backend layer. The web layer collects ...
1
vote
1answer
77 views

Better way to organize query methods in Android?

In my Android app I have a SQLiteHelper class that extends SQLIteOpenHelper, and takes care of things like table-creation and upgrades. SQLiteDatasource class that performs CRUD operations on the ...
1
vote
2answers
99 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
231 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? ...
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 ...
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 ...
35
votes
14answers
18k views

Is it possible to reach absolute zero bug state for large scale software?

I am talking about 20-30+ millions lines of code, software at the scale and complexity of Autodesk Maya for example. If you freeze the development as long as it needs to be, can you actually fix all ...
-4
votes
2answers
112 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
1answer
138 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 ...
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....
13
votes
6answers
18k views

Is CSV a good alternative to XML and JSON? [closed]

Is CSV considered a good option against XML and JSON for programming languages? I generally use XML and JSON (or sometimes a plain text file) as flat file storage. However, recently I came across an ...
19
votes
5answers
5k views

Is every number in the code considered a “magic number”?

So every number in the code that we are sending to a method as an argument is considered as a Magic Number? To me, it shouldn't. I think if some number is let's say it is for minimum length of user ...
1
vote
3answers
239 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. ...
0
votes
4answers
304 views

Best Practices when extending an application

I have to extend a web application for a customer, there is no documentation of the current app, no analysis and even worse, there is no technical support or management. The client gives me a list of ...
1
vote
1answer
67 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 ...
5
votes
5answers
2k views

Programming as fast as you can touch-type… How to get to that stage? [duplicate]

I took a test recently and found that I could touch type comfortably at around 100 wpm... and if given some sort of autocorrect/intellisense then that would be even faster (who knows maybe 150 wpm?)......
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 ...
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 ...
7
votes
4answers
334 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
185 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 ...
40
votes
10answers
7k views

Why would a program use a closure?

After reading many posts explaining closures here I'm still missing a key concept: Why write a closure? What specific task would a programmer be performing that might be best served by a closure? ...
56
votes
12answers
20k views

What kind of problems does MapReduce solve?

I have been reading about MapReduce for a while -- but what I can't understand is how someone would make a decision to use (or not use) MapReduce. I mean, what are the problem patterns that signal ...
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 ...
5
votes
2answers
130 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 ...
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 ...