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

12
votes
3answers
226 views

Is staying implementation agnostic really worth it?

I have a project that I'm working on currently using Tomcat, Spring 4, Spring Security, MySQL, and JPA w/ Hibernate. I picked JPA from the standpoint that it's suppose to make swapping out the ...
0
votes
0answers
20 views

Add new/modify existing callback to/in API

I am working on a common API for a user interface. My colleagues use this framework in all their projects, but the UI is not our main aspect here, so the knowledge of the UI framework is somewhat ...
4
votes
1answer
461 views

How dangerous is it to take shortcuts when coding Web based applications? [closed]

I started working as a Web developer few months back. Previously, I had no prior professional experience in programming besides school classes and fun-side projects I did on my own. I am the only ...
0
votes
1answer
113 views

Method Parameters Ordering [closed]

I was recently changing a method to add in an additional parameter, and I couldn't help but wonder if there were "best practices" or "generally accepted rules" in deciding what order parameters of a ...
3
votes
1answer
66 views

Difference between patterns: Specification, Guarding, Conditions, Monads, Validation,

I'm currently trying to get my head around a few patterns (especially the ones mentioned in the title above) that are made to address different problems and are being used in different parts of the ...
3
votes
9answers
690 views

Is it better to have separate functions or add more arguments to a function? [closed]

Which is the better style to follow for say, changing the voltage on a 4 channel PSU: setChannelOneVoltage(voltage) setChannelTwoVoltage(voltage) setChannelThreeVoltage(voltage) ...
36
votes
9answers
5k views

Is creating subclasses for specific instances a bad practice?

Consider the following design public class Person { public virtual string Name { get; } public Person (string name) { this.Name = name; } } public class Karl : Person { ...
0
votes
1answer
100 views

translating a list of words (word1, word2 and word3) [closed]

We are trying to globalize an application and we have run into a situation where I'm not sure how (of if) we would go about formatting the string for globalization. It's a paragraph explaining ...
4
votes
2answers
181 views

@SuppressWarnings in coding test submission

I am working on a coding test for an employer. It is not a particularly hard question but I am trying to do it as well and technically correctly as possible for obvious reasons. I ran into a problem ...
3
votes
1answer
197 views

How big are the teams where you have worked? [closed]

Anyone have numbers on how big a "traditional" software teams are across the industry? At what point do big companies like Microsoft, Facebook, Google, etc. split teams of developers up? Agile books ...
0
votes
1answer
212 views

When should a class be final? [duplicate]

I've only really seen this on Java's wrapper classes (String, Integer, etc.), but never in open-source projects, and I was never taught about it in any books or classes. I know it means the class ...
0
votes
0answers
86 views

Is there a disadvantage to not using text file extensions? [migrated]

I recently learned that file extensions (at least for plain text) in a Unix-like environment generally don't have meaning. Whether a bash script has a .sh,.log,.txt, or .hgfjgfdjgd, it can still run ...
0
votes
2answers
78 views

How to predict a future simulation state

We have a program that combines the simulation of an aircraft system and predefined pedagogical scenarios for trainee pilots to learn how to use this system. When we follow the normal scenario, ...
0
votes
5answers
201 views

Breaking a function into smaller ones is great… except for what about code-folding? [duplicate]

I'm currently reading Robert Martin's Clean Code book. So far I'm enjoying it. Martin talks a lot about separating long functions into short functions, each doing exactly one thing at one level of ...
28
votes
8answers
1k views

Is it okay to use exceptions as tools to “catch” errors early?

I use exceptions to catch problems early. For example: public int getAverageAge(Person p1, Person p2){ if(p1 == null || p2 == null) throw new IllegalArgumentException("One or more of ...
0
votes
3answers
98 views

Does it make sense to have a separate init function?

I'm created an opaque type and I have two options for its management. The first looks like this: type_t *a = type_init(); int err; err = type_do(a, "foo", "bar", FLAGBIT1|FLAGBIT2, NULL); if (!err) ...
0
votes
2answers
51 views

Should `setX(Object o)` methods perform deep or shallow copies of objects?

My particular situation is related to Java, but I believe this is a more general OOP question than just Java programming. The Question: Should "mutator" methods perform deep or shallow copies? An ...
1
vote
1answer
86 views

Standardization and official guidelines for C++ template parameter naming [closed]

What are some explicit and official guidelines or standards for template parameter naming in C++? I've done something like this in the past: template<typename TContainer, typename TKey> void ...
-4
votes
1answer
94 views

Does the head of any linked list must contain any data [closed]

Is there any rule that says the head of any linked list should contain data. Is it because by doing it so we save a space for one node. Why for some implementation of head contains data and for other ...
1
vote
3answers
188 views

How to abide the “allocate in caller” rule when the size is computed in the callee?

Let's say we have an opaque type handle_t that is managed through a simple interface with functions such as: handle_t *handle_init(void); int handle_do(handle_t *); void handle_free(handle_t *); ...
-1
votes
1answer
184 views

Competitive Programming [closed]

I think this may just be one of the most frequently asked questions by a novice (like me) on this site. Please pardon me for that. My question is I wish to get better at solving the harder problems of ...
0
votes
0answers
17 views

how to combine logs coming from multiple virtual machines for processing?

Scenario: Two virtual machines produce logs. I want these logs to be sent to a central server for processing (as soon as a line of these logs is generated-->streaming ). The condition here is that I ...
159
votes
15answers
26k views

What's wrong with comments that explain complex code?

A lot of people claim that "comments should explain 'why', but not 'how'". Others say that "code should be self-documenting" and comments should be scarce. Robert C. Martin claims that (rephrased to ...
2
votes
1answer
90 views

Best practice for unused inherited virtual functions (implementing superclass methods)

Let's assume I have a hierarchy of several classes each derived from each other using virtual functions. The base class acts as an interface and defines functions, which may not be required by all of ...
0
votes
1answer
48 views

Macro guard in Objective-C

I have noticed that many famous libraries written in Objective-C (eg. AFNetworking) use the macro guard inside their header files. Im aware that the #import directive, which works exactly like ...
0
votes
4answers
290 views

How can if (sscanf(buf, “%i”, &mode) != 1 || TRUE) be rewritten to if (TRUE)?

I got lost in the opening of this post on reddit. How can if (sscanf(buf, "%i", &mode) != 1 || TRUE) be rewritten to if (TRUE)? Does this assume that the sscanf never fails?
2
votes
1answer
108 views

Is there a pattern or best practice for passing a reference type to multiple classes vs a static class?

My .NET application creates HTML files, and as such, the structure looks like variable myData BuildHomePage() variable graph = new BuildGraphPage(myData) variable table = BuildTablePage(myData) ...
-1
votes
2answers
119 views

Data Access Objects old fashioned? [closed]

A couple of weeks ago I delivered some work for a university project. After a code review with some teachers I got some snarky remarks about the fact that I was (still) using Data Access Objects. The ...
-2
votes
1answer
59 views

Common phrases to know which resources are no longer available [closed]

I'm working on an script for tracking urls on a web page. This script runs daily to identify resources that are no longer available. If a page returns a status code like 404 I know the resource is ...
-5
votes
1answer
149 views

CAPTCHA blocking for my scraping script? [closed]

I am working on a scraping project which involves getting web data and parsing them for further use. I have been working using PHP and CURL to make scraping scripts which crawls web data and I make ...
0
votes
1answer
143 views

Best Practices For Temporary Scripts (Python)

I am running two separate programs which are similar enough that they share a lot of code. I run these programs often and after I evaluate the output. This is a very fluid process and everytime is ...
1
vote
0answers
68 views

MVC Controller - keeping methods small

I'm reading uncle Bob's Clean Code and it completely revolutionizes my programming style. In this book author claims that best methods are small methods. What about controller's action methods in ...
1
vote
2answers
319 views

How to approach program design with respect to data strucutres and algorimths - is there an equivelant of the OO design process for d.s.'s + algs? [closed]

My applogies for probably the worst written body of text I have produced in my life and many thanks to those willing to plough through it all. I was (and still am) not able to clearly express what I ...
0
votes
3answers
209 views

Is it a newbie mistake to avoid branching? [duplicate]

My team is new to versioning and we're trying to keep things simple, as to not overwhelm ourselves with tools-headaches. Also, our product can't be compiled and run locally, so our work is actually ...
0
votes
1answer
94 views

Python case statement? [duplicate]

I made a simple Python script that takes user input in order to generate a series of mathematical responses. In one part I did this: while True: And iterated through the loop until I used an if ...
-3
votes
1answer
164 views

Explain what this means, “Bulldozer Code” [closed]

I ran across an article on things programmers should avoid doing and came across this term: Bulldozer Code. The author defined it at as "giving the appearance of refactoring by breaking out chunks ...
0
votes
4answers
73 views

Proper sequence of actions for merging using SVN?

I'm totally new to CVCS (SVN specifically). I find that most resources focus very strongly on the command-line commands (irrelevant; we use Windows Explorer + TortoiseSVN) and about structure (e.g. ...
1
vote
1answer
136 views

Develop in trunk and then branch off, or in release branch and then merge back? [duplicate]

Say that we've decided on following a "release-based" branching strategy, so we'll have a branch for each release, and we can add maintenance updates as sub-branches from those. Does it matter ...
-2
votes
2answers
167 views

What to do with a long unfinished project? [closed]

I am a programmer hobbyist (self learnt), and once in a while I like to make games and interactive scripts (nowadays mostly in JavaScript for its ease). Sometimes I start long projects that end up ...
19
votes
6answers
1k views

Should I place functions that are only used in one other function, within that function?

Specifically, I'm writing in JavaScript. Let's say my primary function is Function A. If Function A makes several calls to Function B, but Function B is not used anywhere else, then should I just ...
1
vote
5answers
125 views

Many Arguments in Case Classes [closed]

I have generally read that having many (>4) arguments to a function/constructor is a bad practice. Is this still considered a bad practice? And is there a non-obvious reason? In something like a ...
0
votes
2answers
124 views

Alternatives to the use of the Id/Name properties with non-inputs elements in HTML

I'm migrating a website that use Javacsript/HTML/PHP using reusable javascript code, in certain moment I saw the opportunity to simplify code in functions that use almost the same code. Let's say: I ...
1
vote
1answer
190 views

OnClickListener good practice

Which one of the ways has better performance, or is a good programming practice, making the holder activity extend OnClickListener and make a Switch() clause for getItemId() or making one ...
5
votes
4answers
2k views

Should you ever use private on fields and methods in C#?

I am somewhat new to C# and just found out that: in C# all of the fields and methods in a class are default private. Meaning that this: class MyClass { string myString } is the same as: class ...
4
votes
2answers
1k views

When is it appropriate to do calculations in front-end?

My team is developing a WEB based finance application and there was a bit of an argument with a colleague where to keep the calculations - purely in back-end or keep some in front-end too? Brief ...
40
votes
6answers
3k views

Is making a small change, testing it, then “rinse and repeat”, a bad habit?

I am a programmer with a number of years of experience. I realized I got a certain habit. I'm not sure whether it's really a bad habit or not. I get a list of tasks to perform for a solution, even ...
3
votes
1answer
173 views

Java-Like 'throws'-information in method signature C#

From Java I know that the signatures of methods that can throw exceptions contain a throws block, that contains the Exception(s) that might be thrown. In C# there is no such thing and it is also not ...
1
vote
1answer
108 views

Should data be stored to local database in Android when heavily using REST services?

Let's say I have an application that has constantly changing data. Changes are so frequent that you basically need to refresh data every time you open some screen and keep refreshing it. Is it worth ...
1
vote
2answers
101 views

Unit testing - should tests for a method validate the results of other methods?

One thing bothers me while I'm writing unit tests of my code. did tests of method should include validation of outcome from other methods? Of course, public methods. Let's go to - rather trivial - ...
5
votes
1answer
144 views

How to avoid reinventing the wheel when using complex frameworks?

For the backstory, I'm developing a GUI application in C#/WPF. I already had in my code quite many instances of <ComboBox ItemsSource="{Binding Items}"> <ComboBox.ItemTemplate> ...