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

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
1answer
60 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, ...
-3
votes
5answers
138 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 ...
-3
votes
0answers
59 views

Good artices on programming conventions [on hold]

I'm young programmer (15 years) and I'm programming (mostly in JavaScript) for 4 years. I have good knowledge of the language, can create some algorithms,... But the thing is, everytime my older ...
24
votes
8answers
755 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
89 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
45 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
80 views

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

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
85 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
2answers
120 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
169 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
16 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 ...
-7
votes
0answers
34 views

How to store pdf files to MySQL and then list, open them using C# [duplicate]

I'm creating a c# employee management system app, I've created a form for Employee files and I don't have any idea how to store pdf files to mysql and then list and open them with c#.
158
votes
15answers
25k 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
71 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
43 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
289 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
107 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
113 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
53 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
113 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
136 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
58 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
317 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
204 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
88 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
152 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
69 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
127 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
162 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
98 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
115 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
173 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
171 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
82 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
96 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
142 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> ...
0
votes
2answers
354 views

Is it necessary to memorize every line of code when it comes to game development? [closed]

I am currently following along a youtube tutorial here and from what I understand we are starting out by creating an engine to run the game. Should I be able to implement all of this by myself without ...
0
votes
1answer
111 views

Best practices in designing a social network app? [closed]

What are best practices when it comes to designing a social network app for Android (possible iOS port later depending on uptake)? It's my first time architecting something this scale from scratch, ...
1
vote
0answers
63 views

Preferred method for handling Failed CRUD operations in Entity Framework (6)?

I am using EF 6 as my ORM. I am trying to decide how to handle CRUD failures. Option 1: Use exceptions (custom or built-in) to inform the web layer that an item didn't correctly save. Handle the ...
1
vote
2answers
68 views

Creating menu structure using DB - is that fine?

Also I have an application that basically consists of a lot of screen so user needs to navigate a lot (like go from A>B>C>D) etc. I have been thinking how to implement this (mainly hold the structure ...
5
votes
2answers
206 views

How to handle a vendor who asks for the solution of an issue they could not solve

Being a small department of developers, it's not uncommon for us to outsource projects. We have a set of companies that we really like to work with, very reliable and good local people who appreciate ...
0
votes
2answers
82 views

Why are some files in programming projects named “commons”?

I have seen numerous projects have a file named commons for example: commomns.go I was wondering, why was this convention adopted and what did the meaning of naming a file or a package or something ...
8
votes
1answer
644 views

I know JavaScript really well, but i bomb coding interviews [closed]

So I'm currently on a hunt for a new position as a Front-End Developer. I know JavaScript very well and can wax poetically about Closures, Currying, Prototypal Inheritance, Design Patterns, App ...
-1
votes
2answers
212 views

Whats the best way to build a HTML/AJAX site that requires login? [closed]

Let's say that hypothetically you wanted to build a website that delivered content to the visitors entirely using HTML and Javascript (AJAX to fetch server side data). The site would require login for ...
3
votes
2answers
313 views

Why to declare a String (as final) and then use it?

In a typical spring mvc validator class, while inserting an errorCode value in the Errors object, what difference does it make between using a String (props.somefield.req) like so ...