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

69
votes
7answers
6k views

Short circuit evaluation, is it bad practice?

Something that I've known for a while but never considered is that in most languages it is possible to give priority to operators in an if statement based on their order. I often use this as a way to ...
-2
votes
1answer
43 views

Copying desired bits from variables [on hold]

What's the best way to copy desired bits from char, int or any other variables? I want to see all possible and the most efficient techniques for this purpose. I have for example 16bit variable 0000 ...
2
votes
1answer
53 views

Making use of constant data

My team is working on an android app. A co-worker and I have different ideas on how to load constant data. To clarify, the data we are going to use are 100 × (n × 〈integer-integer pair〉) where 10 ...
229
votes
16answers
39k 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 ...
1
vote
0answers
29 views

Using AngularJS to develop easy to implement modules for customers, wondering if this is a good way to implement this functionality?

Where I'm working, we currently have quite a few clients, both using Wordpress and custom site solutions that require our data to be sent via JSON to their site where they can then display it without ...
18
votes
6answers
10k views

What are the pros and cons of HTML5, native and hybrid mobile app approaches?

I want to develop a mobile application. I recently read an article on Telerik Forum, which compares among three types of mobile application and I don't know which one should I select to begin with. ...
-2
votes
1answer
63 views

How to name variables without plural in a for-each loop? [closed]

How do you name loop variables when the list item is named after something without a plural? For instance (in python): [x for x in sheep]. x is not a great name, but sheep have/has no plural that ...
7
votes
3answers
265 views

Construct your solution logic in syntax or in a faster and more efficient mental model?

I am a newbie, studying programming and I came across this question today: How can I make sure that I'm actually learning how to program rather than simply learning the details of a language? A ...
3
votes
0answers
44 views

Can I bill the client for my time learning his system? [migrated]

I'm working on some bug fixes on web project for a client/friend. He has everything set up and working, but called me to fix a handful of bugs. I've never used his system, I barely know how it runs, ...
15
votes
5answers
81k 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 ...
1
vote
2answers
97 views

Is it a good idea to install more libraries than you need? [on hold]

I decided to try Anaconda, it seems that too many large companies are using it. I was amazed by the number of libraries included by default installing: python-2.7.9-2 ... installing: ...
169
votes
17answers
10k views

How do you balance between “do it right” and “do it ASAP” in your daily work? [on hold]

I find myself pondering over this question from time to time, again and again. I want to do things the right way: to write clean, understandable and correct code that is easy to maintain. However, ...
2
votes
1answer
251 views

ViewController in programming [closed]

ViewController is a term for classes that handle views in a framework. This is especially used in MVC frameworks. I go through various projects, written by various programmers, who implement MVC in ...
0
votes
2answers
318 views

What algorithm should I use for a lot of if else(s)?

I have to implement a lot of if else statements and I'm thinking of using Decision Tree but I'm not sure if it's going to be the right algorithm. I don't want to insert a piece of html code based on ...
0
votes
1answer
28 views

Sense user-agent to determine HTML - Keep HTML and Logic separate?

I am of-the-understanding that you should try to keep HTML out of your logic, and keep logic out of your HTML. E.G.: You don't write HTML in (C# strings or Javascript Services) and pass them into the ...
2
votes
1answer
256 views

Should all functions be fully self-contained (is it bad practice to share a variable between functions)?

There are two ways to do the same thing (pseudo code) Define databaseHandle in the parent function, and use it as a global in this scope: function API() { function openDatabase() { ...
-3
votes
2answers
122 views

Yoda conditions: if you use more than one language? [closed]

Ive started coding for Wordpress and the coding standards recommend using Yoda conditions. if ( true == $the_force ) { $victorious = you_will( $be ); } But I also do some Android development, ...
9
votes
6answers
2k views

Checking if a method returns false: assign result to temporary variable, or put method invocation directly in conditional?

Is it a good practice to call a method that returns true or false values in an if statement? Something like this: private void VerifyAccount() { if (!ValidateCredentials(txtUser.Text, ...
5
votes
3answers
2k views

Should a method do one thing and be good at it? [duplicate]

"Extract Till You Drop" is someting I've read in Uncle Bob's blog, meaning that a method should do one thing alone be good at it. What is that one thing? When should you stop extracting methods? ...
138
votes
13answers
32k 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 ...
152
votes
23answers
15k 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 ...
2
votes
3answers
172 views

Using System.err.println() for debugging in Java

System.err The "standard" error output stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output ...
3
votes
3answers
109 views

Is it better to make database calls or external API calls first in the context of a single Web request?

Say you have a Web app that uses data from both a database and an external API, and for certain pieces of functionality, you need to call in to both in order to read/write the necessary data. Is it ...
3
votes
3answers
362 views

Use interface or abstract class?

Now the title might seem like the question has been asked before but let me explain my situation and you'll see why I am asking this question. Let's consider this interface : public interface ...
23
votes
4answers
895 views

Prefer examples over documentation. Is it a behavioral problem?

Whenever I come across a new API or programming language or even simple Linux man pages, I always (ever since I remember) avoided them and instead lazily relied on examples for gaining understanding ...
0
votes
3answers
453 views

Should I keep all my class definitions in the same class library?

I am starting to work with class libraries in my C# class. We were told to write code that can be used more than one time. Should I keep all my class definitions in one class library for the length of ...
5
votes
1answer
239 views

Compute Adjacent Pair

I was given the following problem: Integer V lies strictly between integers U and W if U < V < W or if U > V > W. A non-empty zero-indexed array A consisting of N integers is given. A ...
1
vote
1answer
136 views

How much trouble can the use of Singleton class as Model cause?

In my latest WPF applications I've been using a Singleton class, that I call Model, to contain all my application's logic, such as file reading, information handling, etc.. In the WPF Views or ...
1
vote
1answer
247 views

Why is it common to put an underscore before a method in JavaScript? [closed]

For example, I noticed that in the jQuery UI widget factory, methods like _init, _start, _on, ect.
4
votes
2answers
97 views

Is it considered good practice to declare base interfaces without mutators, supplying mutatators in a sub-interface

I asked a question on StackOverflow on how to properly implement an ImmutableMap that abides by the SOLID principles. Due to Java's Map interface containing put and putAll, it violates the interface ...
-1
votes
1answer
50 views

One symbol - one meaning?

It's well known recomendations that: 1) class or function should have one responsibility 2) variable should not be reused in different contexts We can generalize this recomendations to general ...
8
votes
2answers
177 views

Role-based REST API?

I'm building a REST API for which several users with different roles will have access to the resources it contains. To keep the scope simple let's take the "student/teacher/class" domain: GET ...
0
votes
5answers
473 views

Is String processing more complex than number processing in programming languages?

I feel that string processing is always more complex than Numbers or mathematical processing. Are our programming languages are designed this way that mathematical operations are pretty much straight ...
0
votes
2answers
672 views

I cannot understand the application of oops How can I develop the understanding of application of oops? [closed]

I am a developer in PHP technology, I am aware of almost all the basics of OOPS, but still cannot find out the way to apply these concepts over a procedural programming. I do it in very orthodox way, ...
1
vote
1answer
285 views

Methods for structuring JavaScript SDKs

I've built a REST API and have been using Backbone models throughout a couple different applications to communicate to it. I would really like to build a single JS SDK that can be used in any ...
1
vote
1answer
191 views

Human names in programming examples [duplicate]

In small programming examples, it is established that one will probably use foo, bar, and/or baz as variable/function names. Are there accepted human names one can use? For example, if a program is ...
1
vote
3answers
48 views

Clarification on Acquire/Release Semantics in multithreaded programming

In an attempt to fundamentally understand any concept, I try to understand the meaning of the words within the context it is being used. Currently, I am trying to fundamentally understand the whole ...
0
votes
1answer
113 views

Project has become so complex and big that I am lost [closed]

Hello this has never happened with me before . I am making an online shopping android app which has become huge and complex . While developing the code I have followed all the clean naming ...
0
votes
1answer
99 views

How do you build the confidence to work on large projects? [duplicate]

So I'm a programmer who works in telecom. I'm currently in school as well and I'm also an avid gamer (shocker). I said this to form my question: Take a big game title such as DotA 2 - how do you know ...
23
votes
14answers
6k views

Is it ever a good idea to hardcode values into our applications?

Is it ever a good idea to hardcode values into our applications? Or is it always the right thing to call these types of values dynamically in case they need to change?
11
votes
1answer
537 views

Slicing up the Development Stack - diagonally?

We've got a new project going on, and at the moment developers have been split into two teams, team A and team B. This project has 2 parts to it which require development throughout the development ...
-2
votes
2answers
102 views

Having one server for the whole team [closed]

I'm currently in a team where it lacks of its resources. The dev't team had only one websphere server for testing and we could not deploy our project in our local desktop because the websphere is only ...
1
vote
3answers
197 views

C# Subject Observer Architecture question

I'm making a C# application using the Subject Observer design pattern in a slightly different way. I am passing the Provider Class, implementing IObservable (this has the OnNext() method that ...
2
votes
1answer
101 views

Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?

I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
0
votes
1answer
131 views

Has pre-increment operators become that common? [closed]

Bit of background to explain the reasoning: I've been programming for a good while, but took a break between 2012 and 2014 for other stuff. Before that break, I would hardly ever hear about "++i", let ...
1
vote
2answers
135 views

Is lazy loading always required?

I know lazy loading is required when an expensive database call is being made. It would make sense using lazy loading in this example. The below example is in the context of asp.net so it's thread ...
-1
votes
3answers
65 views

What is an initial skeleton of the website called? A Framework? [closed]

I am building a website but I am wondering can I call the initial set of pages a framework? Say I have a project to build a website for a school. Before I start implementing the requirements I have ...
3
votes
2answers
133 views

Are there standard formats for keeping a “programming notebook” or any sort of paper planning for software development? [closed]

Personally, I've had several programming notebooks since I've started coding, but most of the time I don't keep a standard format between projects or even within projects. My ideas end up a little ...
0
votes
0answers
65 views

Test-first iterative development in Common Lisp environment

Given: I want to practice proper test-first, continuous delivery-style software development in Common Lisp environment. Problem: How each red-green-refactor iteration of the process should look ...
7
votes
5answers
897 views

Why are objects instantiated this way?

Some times I see an object instantiated this way. ICustomer oCustomer = new Customer Obvious but the Customer class is implementing ICustomer interface in this example. Are there any advantages of ...