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

-2
votes
0answers
8 views

Social media analytics platform [on hold]

I manage social media accounts for several people. My expertise with social media comes with the creation of actual content and not having any real ability in programming or software. The management ...
1
vote
1answer
255 views

What programming technique is this?

I have two Java classes. The first one is called "Index", and the second one, temporarily, I called it "IndexCache": public class IndexCache { private static Map<String, Index> map = null; ...
3
votes
1answer
170 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++ programmation (specifically with the Qt Framework) I only use the old raw pointer : SomeKindOfObject *someKindOfObject = ...
-4
votes
0answers
44 views

Differences between books in the principles of computer programming, and in programming languages [on hold]

What are differences between books in the principles of computer programming, and in programming languages (whose purposes are not for specific languages)? I am often confused by them. I heard ...
1
vote
1answer
96 views

How to work with a messy codebase and client [duplicate]

A client came to me with some features he wanted implementing. Easy enough to do what he asked. He paid me, I agreed to start on the start date and finish in 3 weeks. The code base is a disaster. It ...
1
vote
1answer
176 views

How to avoid violating one definition rule in this case?

We have an existing Mutex C++ class. It has a debug feature to track the owner thread id. So it has a member variable to store this, but because the original developer doesn't want to waste memory, ...
-5
votes
0answers
35 views

Standard for Documenting Program Flow [closed]

Problem: As a programmer, I would like to document the steps a program needs to take so that anyone else involved in the project can see the steps. However, I would like this to be as standardized as ...
0
votes
0answers
28 views

Best Practices for Managing Low Disc Space [closed]

What are the norms for managing a low disc space situation? i.e. what should my application do if there is low disc space on startup? What would an application normally do if it runs out of space ...
0
votes
2answers
85 views

Create the fields in class level then instantiate inside methods or create and instantiated inside methods

I'm a newbie in software development. Just wondering which code is better and why should I continue which pattern should I follow. First Snippet: Class TestClass { private Object1 field = null; ...
2
votes
2answers
79 views

Free Standing Functions in Global Namespace

When writing non-member, free functions, can they be placed in the global namespace so long as the signature specifies a namespace-scoped object? For example, in the code below, is "Example 2" ...
0
votes
2answers
71 views

Best way to offer team member help? [duplicate]

I've been having a problem recently. In my recent sprints, I have found myself finishing my work well before the sprint ends (several hours in a 2 week sprint). I am left with a lot of time and ...
0
votes
2answers
125 views

Is relying on Demorgan's law in open-source code a barrier to contribution?

I recently added this code to a Github project I'm working on: if not initial_push=='y' and not initial_push=='yes': print('Aborting.') return False Since this is a public ...
0
votes
2answers
84 views

How is a dictionary better than a big switch, when mapping data to action? [duplicate]

Often times we see stuff like that in code: void myFunction(string someValue) { if (someValue == "a") { // ... } else if (someValue == "b") { // ... } else if (someValue == ...
0
votes
5answers
150 views

Is it bad form to use the same variable name in different scopes?

Say you have some basic code where similar operations will take place in nearby lexical scopes. Take for example some simple pseudo code: variable = "foo" # Do something with variable if (True) { ...
-2
votes
0answers
54 views

What are the Pros and Cons of recursion over loops? [duplicate]

What can be said for the benefits and negatives of recursive functions over using a loop? For example. Is it just a matter of writing less code? Surely recursion has the potential to StackOverflow ...
0
votes
1answer
116 views

Why use the Singleton pattern over class functions and fields? [duplicate]

I'm going to start by saying that I understand that programming in mostly class functions and variables can be harmful to object-orientation, and that most of the time an instance is preferred. I'll ...
-1
votes
2answers
114 views

Should I learn a programming language that compiles to another? [closed]

For about a year now, I've been doing full stack web development. I am doing about 66% backend stuff (in Python), but from a time to time, I need to write HTML, CSS and JavaScript. I really want to ...
1
vote
2answers
532 views

How can i get around of infinite circle of technology change [duplicate]

I have been in web developement for 6 years. I am facing one big problem and i want to know how can i get rid of it. There are many personal projects like web application which i want o build. As an ...
0
votes
1answer
183 views

Is it good practice to shorten functions? [duplicate]

Is it good practice to shorten functions? Like this code for instance: using System; namespace Hello { class Program { public static void ...
28
votes
8answers
4k views

Is throwing an exception an anti-pattern here?

I just had a discussion over a design choice after a code review. I wonder what your opinions are. There's this Preferences class, which is a bucket for key-value pairs. Null values are legal ...
1
vote
1answer
77 views

Best practices for lookup tables in the application - by id or value

I have a complex database application. There are a lot of lookup tables containing a few values, in particular one contains pass / fail / waiting / unknown. In the application I find many of the ...
3
votes
5answers
144 views

Exception handling and 3rd party library

I'm currently having an issue with a 3rd party control library provider. They have an exception occulting culture that gets in the way of my general fail-fast approach when developing software. An ...
8
votes
8answers
3k views

Are there any easy-to-follow/reliable methods for simplifying code? [duplicate]

There is a problem with the way I code. Regardless of how much of a plan I write beforehand, the code becomes overcomplicated quickly. Reading books on good practice and attempting to adhere to their ...
2
votes
5answers
522 views

When, if ever, should I daisy chain functions?

I'll try to be as brief as possible in respect to your time. In a program divided up into many functions by which it is intended that they execute themselves one after another, when (if ever) is it ...
0
votes
1answer
67 views

How can I condense a case class with ~20 constructor arguments into 5 or 6 arguments in Scala?

Let's say I have a case class with ~20 constructor arguments? This is obviously very clunky to type. What would be the best way to condense these arguments into maybe 5 or 6 arguments? There are some ...
0
votes
2answers
69 views

What does one mean by UI Independent client logic?

I was reading this excellent post on Gmail's Blog. And I came across this line in the end which says, If you’re building an application that (a) has significant UI independent client logic ...
3
votes
2answers
161 views

Software development - The industry & general trends / Bad practices [duplicate]

I am a Web Developer and part of a small team working on an abundance of projects. This is my first "actual" real company after graduating with a degree in computer Science and I have about 2 years ...
-1
votes
1answer
61 views

Injecting a javascript code to all requested web pages by a desktop application [closed]

I work in a community school and I have been requested to censor some words in all requested web pages (page content-html level). If I could inject a javascript code I can do that with a simple ...
0
votes
2answers
65 views

How do I organizing 2 different projects with shared code

I know there have been same question asked multiple times on the programmers stackexchange. I think my question is more specific and hence decided to start a new question. My current a project which ...
10
votes
3answers
1k views

Are there any benefits of using this extra variable in the for loop annotation?

I have found the following loop annotation in a big project I am working on (pseudocode): var someOtherArray = []; for (var i = 0, n = array.length; i < n; i++) { someOtherArray[i] = ...
0
votes
1answer
94 views

Is it reliable to use and download libraries needed from GitHub and copy-pasting codes in order to increase productivity? [duplicate]

I'm just wondering. Is it okay or true that some of the best programmers once taught that to become an effective programmer is through being a lazy programmer rather than spend time memorizing lots of ...
24
votes
7answers
3k views

What's the best way to avoid catastrophe caused by negligence? [duplicate]

I have been a programmer for almost 1 year. As an ADHD adult, naturally I don't have the same strength of attention on ordinary stuffs as my colleagues do. And I find the catastrophe made by me are ...
3
votes
1answer
87 views

Should I rename package after Android app name change?

I have an Android app. I have changed the app's name from appname1 to appname2. I would like to know if I should also change my package name from com.myname.appname1 to com.myname.appname2 to reflect ...
-2
votes
2answers
107 views

which is a better practice one method that does everything or a series of different methods?

I'm working with asp.net and c# Lets say I have a bunch of drop-downs and I want to bind data from a database, is it better to make a master-bind method that loops each one and gets the parameters to ...
-1
votes
3answers
138 views

Have you ever purposely memorized code, and was it useful? [closed]

In school, we memorize the basics - the ABC's , the times-table, the capitals of states. Is there a place for memorization in Computer Science? Or is memorization just a waste of time?
1
vote
1answer
74 views

Using conditional feature compilation/inclusion for release versioning

I have been playing with the following idea: commonly when different release series (1.0.x, 1.1.x, development code) of a product are maintained in parallel one uses different branches within a ...
1
vote
0answers
49 views

Java MVC: multiple use of the same event for different actions

I am working on a large Java project which employs the model-view-controller pattern. Should I use a different event for each action (to let the views communicate with their respective controllers)? ...
0
votes
1answer
125 views

Why is using break considered bad practice? [duplicate]

I am currently in a beginning programming course at my University (I've got plenty of experience in the subject already, but I still have to pay for that piece of paper with time and money.) and the ...
0
votes
1answer
79 views

Where does the Liskov Substitution Principle generally lie in different constructor parameter lists?

There are two other questions I've posted that dealt with specific cases of this: Where does the Liskov Substitution Principle lie in a subclass passing extra arguments to similar, tightly-related ...
2
votes
3answers
615 views

Why is it a good practice to keep Javascript code in separate files?

In web development we are commonly used to keep Javascript code in separate files, but sometimes we need this Javascript code to manipulate server side data locally. For example, making an Ajax Call ...
0
votes
2answers
163 views

Which language has most advanced support for proof based programming? [closed]

By proof based programming, I mean, you can somehow prove the correctness of your program without testing. I heard that Ada has a feature called contract, I also heard that, if you can pass Haskell's ...
1
vote
1answer
61 views

Where does the Liskov Substitution Principle lie in a subclass passing extra arguments to similar, tightly-related callbacks?

Take the following examples, which have been abbreviated: BasicButton: public class BasicButton { private var m_fOnClick:Function; public function BasicButton(pOnClick:Function) { ...
2
votes
6answers
362 views

Why sacrificing good software engineering practices is typically the first choice for software development projects assuming “good enough” quality [duplicate]

I have observed a correlation between a customer ordering software of "good enough" quality and the same customer not willing to pay for good engineering practices (unit testing, code reviews and the ...
2
votes
2answers
168 views

When testing is it OK to use a method of the subject to test another method of the subject? [duplicate]

I have two methods in the same helper class one that creates an image (method A) and one that compares two images (method B). I want to check the return of method A against an existing image. To do ...
0
votes
1answer
124 views

What is the correct way to bind few classes with similar functionality?

I want to do this in the right way to learn I have a few classes which have only one method. For example: public class RedColorText { public void AddRedColorText(string text) { ...
0
votes
1answer
116 views

Testing - How to test if you are actually testing the code?

I was thinking about unit tests and code coverage, and I came up with this thought: It is possible to have 100% code coverage and not test 100% of your code. For example: function ...
0
votes
1answer
49 views

Testing - Test for Specific Paths?

When (unit) testing, is is bad to expect the code to use certain paths. For example, should I be testing for specifically "/build/static/public/css/", or just that server.cssPath has been set to a ...
1
vote
2answers
98 views

Should you test development features?

Is it a good practice to test features that only run in a development environment, or just a waste of time? Specifics: The item that is prompting this question is a line of code that dynamically ...
51
votes
11answers
5k views

How do I avoid cascading refactorings?

I've got a project. In this project I wished to refactor it to add a feature, and I refactored the project to add the feature. The problem is that when I was done, it turned out that I needed to make ...
1
vote
1answer
120 views

Special parameters for behaviour, good or bad practice?

I really was questioning to myself where to ask this, as I could not decide myself. This is more of a software design question. Context I currently maintain a small Node.js module on NPM which ...