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

14
votes
8answers
2k views

Is it normal for a programmer to not have 100% clarity over their own code at times? [on hold]

I'm not an expert programmer so this may be why, but I've come to notice that whenever I create complex code (like a Chess game I recently made), I am able to write the correct code to get the program ...
-5
votes
0answers
79 views

How do i create a program that scans any source code and defines it [closed]

I really wanted to know how to scan code so i can make changes after i have found its definition ? My prefered language to do it in is C++ Example: scan(){ //read //source code ...
-3
votes
0answers
23 views

Problem referencing resources [closed]

I'm still a newbie to android programming, so I tried a tutorial that was to create a music app, at a stage of the tutorial I was asked to create a new class that extends BaseAdapter and at a point in ...
0
votes
0answers
23 views

Manual repetitive conversion between file types

Let's say i have an interest in file conversions, but everything should be made by hand and i have multiple output formats (say: csv and excel). Once i get contacted by a client, i have to link ...
-4
votes
0answers
45 views

C++ Project Design [closed]

1)What is a broad way to view c++ to understand anything about it and to be able to use anything at my will and not happen to go through all of the confusion of the language and the complicated ways ...
3
votes
0answers
132 views
+50

How to move php documentation closer to standards?

I have an large php project. I used to document it with NaturalDocs, but I didn't include the documentation generation in the build process for a long time ( years ). I recently started using ...
6
votes
5answers
492 views

How to do Test Driven Development

I have just 2+ years of experience in application development. In those two years my approach towards development was as following Analyze requirements Identity Core component/Objects, Required ...
3
votes
1answer
92 views

Bringing coding best practices for non programmers (economists) [closed]

I now work in a team of economists, many of them specializing in a branch known as econometrics, that is heavy on statistics. I am the sole engineer on the team. They make use of EViews(a ...
1
vote
0answers
99 views

Program Architecture: How to manage objects that are interdependent

Consider the following case, image I making a simple chat program; I want it to be extensible such that it would be fair easy to add add different scripting and user interfaces. I want the core ...
3
votes
2answers
188 views

How and Why should class modifiers enforce or prevent inheritance and the ability to override

This isn't really related to anything I am working on currently, its more of a question I really couldn't find an answer for. Class modifiers like MustInherit or NotOverridable to me, seem like they ...
3
votes
3answers
308 views

Should we add constructors to structs

We often use c++ structs to define data structure as opposed to class which can be a complete module with member methods. Now deep down, we know they both are the same (loosely speaking). The fact ...
2
votes
5answers
82 views

Using DDL commands in programming language [duplicate]

Hello I am a student with no industry experience. My question may sound dumb, but, me and my friends were having discussions on use of DDL directly in programming language (any language may be Java, ...
-2
votes
2answers
157 views

Why doesn't array declaration guarantee proper memory allocation whereas malloc does? [closed]

In C++, when I declare an array like int array[10];, it sometimes uses memory assigned to other variable where as this problem is non-existent when I use an integer pointer and malloc to allocate ...
0
votes
0answers
83 views

How increment ++ really works and how to adapt it to exclude an invalidity? [migrated]

The context: As part of a class project, I created this code (Original Version). It works great, had almost full grade. As I was learning new materials, I challenge myself to rewrite the original ...
32
votes
6answers
6k views

Code that converts a value into a different representation, then converts it back to where it started is bad, but how? [closed]

I was reading an article about bad programming practices. It mentioned - "Yo-Yo code" that converts a value into a different representation, then converts it back to where it started (eg: ...
19
votes
5answers
571 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
21 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
482 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
119 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
106 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
707 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
103 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
208 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
211 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
220 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
2answers
80 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
216 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
99 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
54 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
94 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 ...
1
vote
3answers
195 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
214 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
31 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 ...
160
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
124 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
59 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
293 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
110 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
121 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 ...
-5
votes
1answer
220 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
151 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
71 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
320 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
211 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
111 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
191 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
87 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
151 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 ...