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

10
votes
3answers
463 views

Is it bad to refer to access array elements via pointer arithmetic instead of the [] operator?

I've just started learning to program in C, and to improve my understanding of pointers and arrays, I tried to refer to the elements of an array without creating any pointer at all: for(k1 = 0; k1 &...
5
votes
1answer
84 views

Signature-changing decorator: properly documenting additional argument

Let's say I have a custom decorator, and I want it to properly handle docstring of decorated function. Problem is: my decorator adds an argument. from functools import wraps def custom_decorator(f):...
6
votes
1answer
162 views

Is there a standardized practice for ordering attributes in HTML tags?

Thanks for looking. I am working on an AngularJS project and the attributes are numerous in many of my HTML elements: <button type="submit" ng-click="Page.UI.DetailView.ExecuteFunction()" ng-...
2
votes
1answer
200 views

How to implement a facade correctly

I have read multiple websites on this topic but none of them gave me a 'good' solution for the problem I am having. The problem is described in the following (related) questions: How do I couple the ...
3
votes
3answers
70 views

Handling Value Unit data

We have some data that is strongly bound to each other and we are using it for calculations. Its a value with a unit type and an optional relation. E.g. 1500 meter above sea level. The unit type ...
5
votes
6answers
633 views

Is it an overkill to write unit tests for a small code base? [duplicate]

I am the sole maintainer of a code base of about 2000 lines of code. It's not big, but over time the code became so unmaintainable my boss agreed to give me time to rewrite it from scratch. Since the ...
1
vote
1answer
112 views

Extensible way to create bash program

I have a bash script that should be extensible with additional functions with as little change to the script as possible. The basic function is as follows. It loops through a list of files to check. ...
45
votes
6answers
9k views

Is it better to check `c >= '0'` or `c >= 48`?

After a discussion with some my colleagues, I've a 'philosophical' question about how treat the char data type in Java, following the best practices. Suppose a simple scenario (obviously this is only ...
1
vote
1answer
149 views

What does `Resolving` mean in programing? [closed]

I see many places where the word Resolve is used, in Dependency Injection (resolve an implementation to an interface), Package Manager (ex: Resolve packages dependencies), Web (ex: Resolve a hostname)....
-3
votes
1answer
81 views

Manage lock of a software feature [closed]

I've wrote a standalone java SE software which executes, for example, the features A, B and C. Now, i want to that, if a lock is enabled (and this lock is a command sent remotely by my backend), the ...
3
votes
2answers
231 views

Should I use my own public API for my web interface?

I am designing an API with django and its rest framework (and I am already not sure if it worth the hassle to version it or not). I totally know the iOS and Android apps will call the API, get a ...
2
votes
3answers
169 views

Is it considered a bad coding practice to write methods/properties that support (only) testing? [duplicate]

When I write (unit) tests I always try to avoid for example microsoft fakes because then the edit&continue feature no longer works. However this often requires refactoring... and sometimes methods ...
1
vote
2answers
107 views

Unit Testing: Structured vs Unstructured Programming [closed]

Is it possible to write effective unit tests for unstructured code? I was reading through the various answers to this question. It explains the implications of unit testing procedural and OOP code, ...
1
vote
1answer
106 views

Reducing the arity of functions [closed]

I have discovered that reducing the arity of functions in my code to zero or one improves their non-functional characteristics significantly, such as testability, maintainability and their ...
2
votes
3answers
281 views

Use of electronics in programming [closed]

Does a programmer need to have a deep understanding of digital electronics. Theoretical v/s practical. As what they teach us at college is pretty basic? If yes, then do all kinds of programmers (...
1
vote
0answers
51 views

Is marking members as static against object-orientated programming? [duplicate]

Me and my co-workers are having a bit of a discussion about one of the code analysis issues thrown by visual studio: CA1822 Mark members as static The 'this' parameter (or 'Me' in Visual Basic) of '...
0
votes
0answers
44 views

If I set a default value in my table do I need to indicate it when calling the insert function in my system?

For example, I have this (see below) table. The default value for status field is disconnected. Then in my code I have a function like this MySQL_Query = "INSERT INTO `teller_info` " _ &...
9
votes
6answers
1k views

Does context (like as an argument in a function) allow for numbers in code that aren't magic numbers? [duplicate]

I've been reading many of the articles and such about magic numbers, i.e. wikipedia article programmers.stackexchange.com article It seemed like no one has considered context as a means of making ...
2
votes
2answers
199 views

Do nested conditionals have a significant performance impact? [duplicate]

This is a question that lives in my mind from a long time. Does the use of multiple nested conditional statements impact the performance of a taken code? So far I know that programmers have created a ...
1
vote
2answers
117 views

Throwing exceptions in application configuration providers

Simple question: What is the best/common practice regarding to throwing errors for application configuration providers? Given is a simple key/value-based configuration source: class Configuration ...
1
vote
4answers
351 views

What's the alternative to DRY code when it requires too many parameters?

What is the best strategy for maintaining easy to follow code when keeping things DRY means you have to pass a lot of parameters to shared functions? In my specific case, I have a grails based app, ...
165
votes
14answers
28k views

Why are the sizes of programs so large?

If we look at the vintage program Netscape Navigator or an early version of Microsoft Word, those programs were less than 50 MB in size. Now when I install google chrome it is 200 MB and desktop ...
2
votes
3answers
94 views

Best practise for databinding when a non-data object is included with the data

I'm using .NET with Windows Forms, but I believe there may be similar concerns with other toolkits. Suppose we have a list of objects of a certain type. Using an example to make the following easier ...
1
vote
7answers
397 views

Throwing an exception when a method does not complete or implement a work around? [duplicate]

I have been studying this subject quite a bit, and I am unsure of what's the best way. I still have a lot to go trough (books, blogs, stack exchange, etc), but I simply can't find a consensus. ...
0
votes
3answers
203 views

In the spirit of consistency, is it acceptable to comment everything equally? [closed]

Consistency is something I value (at an OCD perfectionist level to be honest). I can live with not writing any comments and focus on producing good, refactored, readable code -- or, if I must comment, ...
0
votes
1answer
77 views

Should the main functions of a program be in a separate object? [duplicate]

For a class project in Introduction to Object Orientated Programming, we are creating a simple game. This game has two main menus. I was just wondering what the best practice for organizing these ...
17
votes
6answers
1k views

Writing comments for some small code with rather large background [duplicate]

So I had to write some code related to splitting Bezier curves into parts. I read through several references and particularly referred this rather detailed one. The final code outcome is however ...
1
vote
1answer
117 views

Should DTO have validators?

I believe that DTO should be as dummy and easy as possible. However, after hint made by my friend, opportunity to validate data that is set in DTO sounds tempting. Let's have following example: //...
6
votes
3answers
2k views

Is it good to define a variable inside a loop? [closed]

My instructor once told me that I should not define a variable inside a loop, but I honestly still do not understand why. What are the disadvantages of that? Could any body explain that to me?
0
votes
2answers
339 views

How to structure a SaaS application?

The Problem I need to develop a Software-as-a-Service application, that will be used from our clients. The application contains a lot of forms (Company Application) using a step-by-step forms. They ...
1
vote
1answer
143 views

When to use absolute path? [closed]

I had given an answer on SO, the question was concerning a problem with a relative path. My answer was to use an absolute path, which I thought seemed simpler. The asker claimed to need a relative ...
6
votes
3answers
651 views

Is using hashes for primary keys a good idea?

The Austrian electronic ID card relies on the so-called sector identifiers. For example a hospital gets to identify a person by getting a sectorId for that person, which is computed roughly as follows:...
4
votes
1answer
127 views

Makefile for library project to be able to compile the unit tests and the demo program using make

I am new to makefiles and I am developing a (non-executable) library in C++. Additionally to the library I have (executable) unit tests and an (executable) demo program. I would now like to be able ...
1
vote
1answer
116 views

Should I use autoloaders in modules?

Lets say I'm running a PHP app like Magento, PrestaShop. Now these system have their own complex autoloaders to load controllers based on routes, required classes, models, etc. Most of the time as a ...
2
votes
2answers
233 views

Adding centralized logging mechanism to Project (Best Practice)

I want to add a logging mechanism to my project but I am afraid to have logging code spread all over the place. I thus had the idea of having only one class Logger responsible for writing relevant ...
0
votes
0answers
77 views

Why are scriptlets considered bad practice in JSPs when much more popular languages such as PHP seem not have any problem with them? [duplicate]

Why is doing <% if(blahblah) { //do something } %> in a JSP considered to be bad practice when noone who writes PHP seems to have any problem with doing essentially the ...
1
vote
4answers
570 views

Should I Include PHP code in HTML or HTML in PHP?

What is the best practice, to write my PHP code inside my HTML code or HTML inside PHP? PHP inside HMTL: <p class="lead">Welcome to the <?= COMPANY_NAME ?> website.</p> HTML ...
1
vote
1answer
98 views

Git Question: What to do when multiple people working on a project?

I made a project and put it on github, it's basically a small powershell function that is pretty useful in some situations. I've since made some improvements to it to add functionality...but someone ...
2
votes
1answer
160 views

Is it safe to use old code in a new project? [duplicate]

Here is the situation: While working by company A on project A you developed a very fast and perfect search algorithm. Then you switched to company B to work on project B which is totally different ...
-2
votes
2answers
172 views

Is it ever overkill creating classes/objects? [duplicate]

I just learned how to create a class or object in C++ and I'm practicing and learning. I'm writing a text based version of a popular board game and I was wondering if it's overkill creating a class ...
12
votes
3answers
440 views

Appropriate to put known issues directly in software?

I've taken over maintenance of an Android app, and there are a few residual problems that I've more or less fixed, but still have issues because of different Android OS versions. For example, sending ...
1
vote
1answer
93 views

Should I put stack trace in error files and halt my app with user friendly error [closed]

In my earlier project I wrote an app that is used in-house. My usual practice is to capture errors/exceptions from different classes and threads and put them in different log files corresponding to ...
0
votes
1answer
103 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 self....
31
votes
6answers
5k 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 ...
2
votes
2answers
197 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 ...
2
votes
1answer
310 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
2k 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 ...
2
votes
0answers
49 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 ...
0
votes
1answer
173 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 ...
0
votes
0answers
57 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 (...