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

25
votes
6answers
4k views

Is throwing new RuntimeExceptions in unreachable code a bad style?

I was assigned to maintain an application written some time ago by more skilled developers. I came across this piece of code: public Configuration retrieveUserMailConfiguration(Long id) throws ...
0
votes
1answer
47 views

Logging private data

In general, I write a debug log whenever one of my functions is entered, including the parameters. For instance: function execute_query($query, $conn_string) { ...
0
votes
0answers
17 views

What are the important features of a Portal Framework?

I am looking to build a portal framework similar to liferay/ backbase. I want to discuss the important things that I need to take care of. e.g. Security/ UI / Extendability/ Customization etc.
19
votes
5answers
90k views

Is initializing a char[] with a string literal bad practice?

I was reading a thread titled "strlen vs sizeof" on CodeGuru, and one of the replies states that "it's anyways [sic] bad practice to initialie [sic] a char array with a string literal." Is this ...
55
votes
7answers
5k views

Code First vs. Database First

When I design and create the software I work on, I typically design and create the back-end SQL tables first and then move on to the actual programming. The project I'm currently working on has me ...
0
votes
2answers
164 views

Why is it so difficult to read code? [on hold]

Give me a task, and I deliver. If you want an app that does this and that, I can fix that for you. But if someone else does the job, and shows me the code, I am often lost. It is very difficult for ...
0
votes
1answer
46 views

Should I put the parameters in constructor or in method? (Python 3)

I have the following code: def __init__(self, vocable_file_path, xsd_file_path, word_list_file_path): self.vocable_file_path = vocable_file_path self.xsd_file_path = xsd_file_path ...
-1
votes
0answers
67 views

How to compare numbers in a file? [on hold]

What I would have to do to search a file (file.txt for example), and compare its values with the ones I'm asking the user to input, only write the ones that are not duplicated, while letting the user ...
42
votes
17answers
4k views

Best practice on if/return

I want to know what is considered better way of returning when I have if statement. Example 1: public bool MyFunction() { // Get some string for this example string myString = GetString(); ...
-1
votes
5answers
173 views

Are modern IDE's a 'crutch'? [on hold]

I have recently been working on a c++ project in a linux environment, utilizing a text editor (GEdit, not a real IDE) and command line. At the same time, where I work we use VB.NET, and Visual Studio ...
247
votes
16answers
43k views

Why are shortcuts like x += y considered good practice?

I have no idea what these are actually called, but I see them all the time. The Python implementation is something like: x += 5 as a shorthand notation for x = x + 5. But why is this considered good ...
2
votes
2answers
88 views

Final steps of wrapping up a Python script into a program

I finished building a Python script containing eight functions which download files, extracts them, manipulate and analyze their data and then produce graphs and export them into PNG files. The ...
-5
votes
0answers
34 views

I am learning c programming using codes represented on web please help [on hold]

I am making a bank type program. I am stuck in if else statement step. Pls help Codes are as follows: #include<stdio.h> #include<conio.h> int main() { char fName; char mName; char ...
0
votes
0answers
14 views

WPF: Single use DataTemplate/ContentPresenters combo [on hold]

I've inherited a large WPF project. A lot of the xaml files take the following format: <Window ...> <Window.Resources> <DataTemplate> <!--All The Content ...
2
votes
1answer
188 views

How often should RAII be used? [closed]

I've been attempting to learn C++, but it is famously plagued by bad tutorials. I learned about a clever little trick called RAII (Resource Acquisition is Initialization), where one wraps a heap ...
6
votes
5answers
1k views

C++ Iterators: Best practice to represent end of range - Last or Beyond-last?

I am writing a library which deals a lot with sub-sequences of ordered containers. So for example I have a container (1,2,3,4,5,6) and a user wants to access (3,4,5). I am providing the subsequence ...
-1
votes
2answers
51 views

Creating Objects from a JDBC ResultSet, best practice?

I'm still in the process of learning JDBC and web services (currently forced to work with SOAP, but more interested in REST). I want to save each table row from the ResultSet in it's own object. There ...
169
votes
17answers
17k 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 ...
5
votes
8answers
848 views

Why is (position < size) such a prevalent pattern in conditionals?

In a condition statement (IF) everyone use (position < size), but why? Only convention or there is a good reason for that? Example: if (pos < array.lengh) { // do some with array[pos]; } ...
2
votes
0answers
40 views

tracking branch relations with Git [closed]

here is my workflow. I have master as the most complete version of the program. If I want to add a feature I'll create a branch named with -feat as a suffix. as bugs come up, I'll create new branches ...
35
votes
16answers
3k views

Are there concrete reasons not to use libraries and code snippets heavily?

Overall I'm in programming for about 8 years now and it seems to me that I'm relying more and more on open source libraries and snippets (damn you GitHub!) to "get the job done". I know that in time I ...
0
votes
1answer
93 views

Modular programming practices

As I start to code more and more, for example in C++, I tend to also want to learn more about the accepted standards for code. I'm trying to code a chess engine right now, but I'm unsure how to treat ...
36
votes
8answers
3k views

Is OOP becoming easier or harder? [closed]

When the concepts of Object Oriented Programming were introduced to programmers years back it looks interesting and programming was cleaner. OOP was like this Stock stock = new Stock(); ...
1
vote
0answers
42 views

How to write class libraries that work with DB

I have programmed a library in C#, which process some EDI into meaningful data based on the DB structure of a table. I have used a typed dataset in the class library project. Now I run into an issue ...
2
votes
1answer
91 views

In C#, is it good practice to use implicit numeric conversions from int to float?

For example: if(5.0f > 1) { } Does it have a significant performance penalty? Compared to just doing if(5.0f > 1.0f) { }
18
votes
5answers
8k views

When and why you should use void (instead of i.e. 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 ...
49
votes
8answers
7k views

Is it good that testers are competing to see who opens more bugs?

I'm a software developer. There is a team of testers who follow and run test cases written by the analyst, but also perform exploratory testing. It seems like the testers have been competing to see ...
4
votes
4answers
3k 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 ...
30
votes
5answers
5k views

Bad practice - switch case to set environment

In the last three years that I have worked as developer, I have seen a lot of examples where people use a switch statement to set the path (both in back-end and front-end) for a URL. Below is an ...
2
votes
3answers
1k views

Validating best practices, property vs dto, simple type vs object

Consider an application where adds an email address to his profile and submits it. We have some dispute in our team over how to validate this email address. Some developers (including me) believe ...
55
votes
17answers
4k views

Alternatives to Professional Version Control [closed]

We're teaming up with some non programmers (writers) who need to contribute to one of our projects. Now they just don't like the idea of using Git (or anything for that matter) for version ...
4
votes
4answers
120 views

Creating two-way object references and keeping data integrity

I have two different classes; a Player and a Group. I need to be able to query a Player which Groups they are registered to (player.getGroups()), and which Players are registered to a Group ...
3
votes
1answer
571 views

Does it make sense to choose UTF-32, based on concern that some basic rule will be broken for UTF-8?

I'm working on an cross platform C++ project, which doesn't consider unicode, and need change to support unicode. There is following two choices, and I need to decide which one to choose. Using ...
1
vote
3answers
58 views

Programming to an Interface and Interface Segregation in the Context of a User Class [duplicate]

I try to program to an interface whenever possible, but its not clear to me how I could apply it to a model as broad as a user. Which can hold many disparate fields (name, age, phone number, ssn, ...
1
vote
1answer
124 views

What is the best way to remember a successful execution over several program calls?

I'm working on a build process, that is called manually over the command line. To check if it exited unsuccessfully during the build I want to set a lock file (symbolic link) and remove it on ...
-2
votes
1answer
61 views

Programming to an Interface and Keep Testability in Unique Classes [duplicate]

I try to program to an interface whenever possible, but when I have a class that fulfills a very specific and unique purpose, one that can't be abstracted. Is it correct for me to say that I've ...
24
votes
11answers
2k views

Is it okay to use a language that isn't supported by your company for some tasks?

I work for a company that supports several languages: COBOL, VB6, C# and Java. I use those languages for my primary work, but I often find myself to coding some minor programs (e.g. scripts) in Python ...
32
votes
9answers
4k 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? ...
16
votes
2answers
338 views

Has variable width types been replaced by fixed types in modern C?

I came across an interesting point today in a review over on Code Review. @Veedrac recommened in this answer that variable size types (e.g. int and long) be replaced with fixed size types like ...
0
votes
2answers
88 views

guideline on void methods that do not throw exceptions

In our codebase I saw a method that is similar to following: public void doSomething() { try { ... } catch (Exception e) { ... //log something ... } } ...
1
vote
1answer
35 views

Filtering additions to a list

Hopefully Iʼm posting this in the right SX, and Iʼve tagged it correctly. I have a legacy system that Iʼm making additions to which contains a custom list object. This list object can contain two ...
5
votes
1answer
115 views

Modern Interpretation of the Unix Philosophy of “Rule of Generation”

According to Wikipedia, Eric S. Raymond said that one of the 17 Rules of Unix is the "Rule of Generation", stating that: Developers should avoid writing code by hand and instead write abstract ...
4
votes
3answers
357 views

@SuppressWarnings in generic array declaration

While doing a coding test, I ran into a problem where I need to initialize an array of generic type in Java. While trying to figure out how to do that, I looked at this Stack Overflow question and it ...
0
votes
6answers
119 views

Would you create a specialized type just to wrap a primitive? [duplicate]

Often times in programming, we need to represent some value which can easily be represented using a simple primitive type. For example, in a game we might need to represent the velocity of a moving ...
1
vote
3answers
83 views

Using auto-increment clustered key and guid primary key together

My boss is the db administrator in a new software project and he came up with that design where every table will have both a auto-increment clustered key and a guid primary key (or possibly composite ...
0
votes
4answers
256 views

Checking for emptiness of collections with (in)equalities - what's the best practice?

For a long time now I've been in the habit of checking whether a collection (array, dictionary, whatever) is non-empty with a nonequality. Like this: if ( MyArray.Length < 1 ) { // Do ...
30
votes
9answers
10k views

Should the methods of a class call its own getters and setters?

Where I work I see lots of classes that do things like this: public class ClassThatCallsItsOwnGettersAndSetters { private String field; public String getField() { return field; ...
0
votes
0answers
31 views

What are some common patterns for managing a polyglot persistence layer?

I am pretty interested in the idea of using multiple datastores to support a single application and understand the benefits in theory but would like to know a little more about how things are done in ...
22
votes
12answers
2k views

Should developers be forced to check-in before leaving work each day, even if the code does not compile? [closed]

During a previous consulting position, the developers where told to check-in code on a nightly basis, regardless if it complied or was complete. Managers were afraid of losing any code and said now we ...
2
votes
2answers
71 views

WCF service with methods to fetch data

I'm planning on building a WCF service that will fetch data entities from a Sql Server database. And I'm currently struggling with best practices issues. The thing is that there's a few different ...