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

1
vote
2answers
166 views

Trying to come up with a mapping convention for C# objects

so this is C# but it could apply to any OO language where different sets of objects exist across different layers of an application. We have been trying to come up with a convention within the team ...
-4
votes
6answers
2k views

Is having two conditions in an IF statement faster than having two separate IF statements?

I just wonder if having two conditions in an IF statement executes faster than having it separated into two like these: Single Statement, two conditions if ( (conditionA == true) && ...
4
votes
4answers
887 views

Exceptions vs ErrorCodes when working with devices

Out team is at the cusp of a new project. One of the components at the boundary of the system is the component which interacts with a printer through an external COM component (referenced as a usual ...
0
votes
2answers
92 views

How to deal with a new version of visual studio's directory?

When upgrading Visual Studio to a newer version, a new directory is created e.g. "Visual Studio 2013". I understand that that makes sense as we want to differentiate between code targeting different ...
4
votes
1answer
113 views

Is it good practice declare a function inline?

I'm writing a method and depending on a config field I need to change where I get my data from. What this results in me having to write code that looks like this: List<string> result = new ...
1
vote
2answers
225 views

Is it okay if we use an arbitrary string as UUID?

I found the tutorial of client (android) and server (pc) bluetooth tutorial from here. But my question is about the UUID. Is that okay if we define it randomly without the proper format? Because I ...
0
votes
1answer
73 views

Automatically create or update object in database

I have a database class with the following interface: public Database { //returns false if p (its ID) is already available //otherwise adds p the the list and returns true public boolean ...
38
votes
6answers
16k views

Method vs Function vs Procedure

Simple question, but I often hear these three terms defined with such ferocity, but which have been known to me to mean different things over the years. What are the "correct" definitions of ...
3
votes
2answers
124 views

How to do documentation for code and why is software (often) poorly documented?

There are some good examples of well-documented code out there, such as java api. But, a lot of code in public projects such as git and internal projects of companies is poorly documented and not very ...
2
votes
1answer
113 views

Is serialization better done in instance methods or static methods

Say I have a class workStockItem, that I wish to serialize. Which is the better style? using a static method or using a non-static method (maybe even implemented as a property as seen below) ...
0
votes
4answers
356 views

File exists vs. File does not exist. Is there a difference in performance?

Let's say I am checking a directory for the existence of a file, and then depending on whether or not the file exists, I act accordingly. For example, see the two Python snippets below. if ...
-2
votes
0answers
63 views

What is the name of a debugging (anti)practice when one introduces random changes into the code? [closed]

Well, I am curious if there is any name for such a practice, when one, to eradicate a bug, performs changes in the code with out analyzing logic. Neither logic of the program, i.e. understanding the ...
1
vote
2answers
91 views

Scalable Job Handler

We have a job table that triggers a notification when a new job gets inserted. Clients that can handle such jobs may subscribe to those notifications. When a client receives a notification, he can ...
143
votes
16answers
11k views

Is there a benefit in compiling your code as you go along?

I recently had a job interview in which they gave me an hour to write some real code. It wasn't a huge amount, probably less than 100 lines. After about 45 minutes, I compiled, ran it, and got it to ...
70
votes
10answers
13k views

Why do most of us use 'i' as a loop counter variable?

Has anyone thought about why so many of us repeat this same pattern using the same variable names? for (int i = 0; i < foo; i++) { // ... } It seems most code I've ever looked at uses i, j, ...
0
votes
2answers
82 views

Should a variable name be changed if its purpose changes?

I'll change my personal code often and not worry about going back and changing the associated variable names. Should variable names be maintained in case of meaning changes? var accountCurrentValue ...
1
vote
3answers
81 views

Setting global parameters: is this a reasonable use of const_cast and volatile?

I have a program that I run repeatedly with various parameter sets. Different parameters are used in different parts of the program (including different source files). The same parameter may also be ...
0
votes
3answers
90 views

Wrapping a map with instance or static method

I have a java.util.Map<String, Object> object which different types of values in it. I don't want to cast whereever I do a get operation over this. To do this, I created different classes ...
0
votes
2answers
66 views

Best way to indicate more results available

We have a service to return messages. We want to limit the number returned, either allowing the caller to specify the max number to return, or else to use an internal hard limit. We also have thought ...
0
votes
1answer
135 views

Why is the “app” folder now a (more) common pattern in web projects?

It might be related to the Yeoman project, or they might have adopted this from somewhere else, but it seems to be the default for all of their generators. Aside from Yeoman generators I've also ...
107
votes
20answers
10k views

How would you know if you've written readable and easily maintainable code?

How would one know if the code he has created is easily maintainable and readable? Of course in your point of view (the one who actually wrote the code) your code is readable and maintainable, but we ...
-3
votes
3answers
126 views

Determine Programming Language Used for Project Based on Source Code

Is there an easy way to determine which programming languages were used in a project assuming you have access to the source code? I have been programming for quite some time, so I can recognize most ...
98
votes
11answers
18k views

Should we avoid object creation in Java?

I was told by a colleague that in Java object creation is the most expensive operation you could perform. So I can only conclude to create as few objects as possible. This seems somewhat to defeat ...
8
votes
14answers
1k views

How to minimize typos when you code?

I make a lot of typing mistakes when I program. I have a good keyboard writing speed but I try to write faster and in the process end up making typos. I want to type faster, but make less errors. Can ...
-3
votes
0answers
58 views

Interview Preparation for Amazon [duplicate]

I have an upcoming interview with amazon. Can anyone please suggest me any book/website which can help me in preparation. Thanks
-4
votes
0answers
65 views

Programming Interview Question [duplicate]

I have an upcoming interview in a couple of days and had a question for you guys. I've heard that programming interviews have whiteboard problems where you solve a simple problem on a whiteboard. My ...
1
vote
0answers
53 views

Can TDD help me develop a CUDA version of image/video processing algorithms? [closed]

I have tried many ways to migrate the image/video processing algorithm I have to run on GPU using CUDA framework and made a little progress. From reading around Stack Overflow I found a lot of ...
0
votes
3answers
138 views

What is decoupling and what development areas can it apply to? [closed]

I recently noticed decoupling as a topic in a question, and want to know what it is and where it can apply. By "where can it apply", I mean: Is it only relevant where compiled languages like C and ...
4
votes
2answers
208 views

Can decoupling hurt maintainability in certain situations?

Can the fact that the business logic is mapped to interfaces instead of implementations actually hinder the maintenance of the application in certain situations? A naive example with the Java's ...
0
votes
1answer
109 views

Your thoughts on Best Practices for Scientific Computing? [closed]

A recent paper by Wilson et al (2014) pointed out 24 Best Practices for scientific programming. It's worth to have a look. I would like to hear opinions about these points from experienced programmers ...
1
vote
1answer
89 views

Software development based on a reference implementation [closed]

Lets say I have library "A2" as a dependency in a project. Library "A2" is derived from library "A1"(A2 is a fork of A1 with some modifications to the original source code) where someone has done few ...
20
votes
9answers
872 views

Tips on persuading boss that code review is a good thing

Let's say one works in a hypothetical company that has several developers that rarely worked together on projects and the Boss didn't believe that code reviews are worth the time and cost. What are ...
18
votes
3answers
11k views

Which is a better practice - helper methods as instance or static?

This question is subjective but I was just curious how most programmers approach this. The sample below is in pseudo-C# but this should apply to Java, C++, and other OOP languages as well. Anyway, ...
2
votes
4answers
207 views

Callbacks: when to return value, and when to modify parameter?

When writing a callback, when is best to have the callback return a value, and when is it best to have the callback modify a parameter? Is there a difference? For example, if we wanted to grab a list ...
-1
votes
1answer
66 views

Storing a looong lookup table

Background The product i am working on has a very long lookup-table. the table contains static data and cannot be auto generated. there are about 500 rows and 10 columns. columns have mostly integers ...
19
votes
2answers
2k views

Should one always know what an API is doing just by looking at the code?

Recently I have been developing my own API and with that invested interest in API design I have been keenly interested how I can improve my API design. One aspect that has come up a couple times is ...
17
votes
3answers
2k views

Is it good to review programs with seniors and boss even if it is working fine?

In my company, before delivery of any project, my boss asks my seniors to review programs written by me or other team members or sometimes boss also sits with us for review. I think it is a good way ...
5
votes
1answer
267 views

Structure vs. programming

Is it bad that I often find myself spending more time on program structure than actually writing code inside methods? Is this common? I feel I spend more time laying the foundation than actually ...
0
votes
3answers
117 views

One method with many behaviours or many methods

This question is quite general and not related to a specific language, but more to coding best practices. Recently, I've been developing a feature for my app that is requested in many cases with ...
19
votes
7answers
2k views

while(true) and loop-breaking - anti-pattern?

Consider the following code: public void doSomething(int input) { while(true) { TransformInSomeWay(input); if(ProcessingComplete(input)) break; ...
12
votes
8answers
2k views

Conception and design before coding: how much is this true? [closed]

I learned at school as well as I read everywhere else that a good development methodology needs conception and design before coding properly. That is not a new information even for a beginner ...
8
votes
10answers
713 views

What should be first - functionality or design? [duplicate]

I've started reading a book from Head First series about OOP and Design. In a first chapter it is stated I have to worry about design of my application just after basic functionality is ready. Basic ...
4
votes
2answers
393 views

How to delete an object when other things reference it (and not making the code full of inter-dependencies)

The situation: In my program, there are a list of cues. To call a cue at a certain time, there are objects called Triggers. Cues have many public methods that allow them, among other things, to be ...
0
votes
2answers
244 views

Why don't we completely de-couple frontend JS frameworks and backend APIs? [closed]

Whenever we implement a frontend framework in the likes of Backbone, AngularJS etc. there's an integration process involved with the backend technologies like NodeJS, Rails, Yii etc. (like setting up ...
5
votes
1answer
143 views

Strategies to manage multiple clients able to simultaneously edit same data

How can I deal with situations when multiple clients might edit same object at the same time? For example, I have a web app with admin console, which lets you edit profile data. Several users want to ...
24
votes
4answers
1k views

How to efficiently troubleshoot or test new code when hardware setup to reproduce bugs is difficult or impossible to obtain?

I work at a mid-sized company (150ish employees, ~10 size engineering team), and most of my projects involve interfacing with lab equipment (oscilloscopes, optical spectrum analyzers, etc) for the ...
4
votes
4answers
326 views

ASP.NET deployment/maintenance best practices

I have been in the web development industry for around 5 years now, always working in an open source environment. Mostly apache, mysql, and php with a little bit of ruby, using git for version ...
0
votes
2answers
142 views

Utility Functions Best Practices [closed]

Update: Most answers are about how to write a wrapping interface or what is a good wrapper around ADO. but my question is more about when to do so and when not. I never found a good rule for deciding ...
73
votes
8answers
7k views

Is it okay to not completely understand code functionality? [duplicate]

As I am currently struggling with learning WCF for a project at work, for the past several days I have been looking at online tutorials and examples on the best way to make a WCF client; and today, ...
0
votes
1answer
86 views

What is the best way to track database changes across a large team

What is the best way to track any change made to the SQL Server database before moving to production in case of a large team ? We have used excel sheets but quite often things get missed which come ...