Questions tagged [programming-practices]

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.

Filter by
Sorted by
Tagged with
8
votes
10answers
2k views

What should be first - functionality or design? [duplicate]

I've started reading a book from Head First series about OOP and Design. In a first chapter it is stated I have to worry about design of my application just after basic functionality is ready. Basic ...
6
votes
1answer
2k views

Strategies to manage multiple clients able to simultaneously edit same data

How can I deal with situations when multiple clients might edit same object at the same time? For example, I have a web app with admin console, which lets you edit profile data. Several users want to ...
0
votes
1answer
1k 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 can'...
14
votes
10answers
2k views

Will correctness proofs of code ever go mainstream? [closed]

All but the most trivial programs are filled with bugs and so anything that promises to remove them is extremely alluring. At the moment, correctness proofs are code are extremely esoteric, mainly ...
13
votes
8answers
1k views

Should you promise to deliver a feature that you aren't sure if its implementable?

In an article from HN, I came across the following advice: Always tell your customer/user "yes", even if you're not sure. 90% of the time, you'll find a way to do it. 10% of the time, you'll go ...
11
votes
7answers
1k views

Which specific practices could be called “software craftsmanship” rather than “software engineering”? [closed]

Although not a new idea there seems to have been a big increase in the interest in software craftsmanship over the last couple of years (notably the often recommended book Clean Code's full title is ...
8
votes
1answer
216 views

Integrated ads in phone apps - how to avoid wasting battery?

Considering the PCWorld review that came out in March: Free Android Apps Packed with Ads are Major Battery Drains ...Researchers from Purdue University in collaboration with Microsoft claim ...
5
votes
3answers
1k views

How to prepare for rewriting an application's glue [closed]

Assume you have a project that (in your opinion) is mostly decently well written, modularized, etc. and you want to keep much of it's functionality. However, an essential portion of this project is ...
4
votes
1answer
1k views

Redundant ElseIf-Else Blocks [duplicate]

These types of if-elseif-else blocks appear all over the place, and in no small number (so the less the better). Every time I have to think and decide: Do I want the simpler or the more thorough of ...
3
votes
1answer
3k views

Where should variables be declared [duplicate]

Considering I have a for loop in a method of a class. Should the incremented variable be declared as member of the class, or should it be declared in the method it uses it(or even in the for loop, ...
15
votes
7answers
24k views

Non-zero exit status for clean exit

Is it acceptable to return a non-zero exit code if the program in question ran properly? For example, say I have a simple program that (only) does the following: Program takes N arguments. It returns ...
15
votes
5answers
6k views

Is monkeypatching considered good programming practice?

I've been under impression, that monkeypatching is more in quick and dirty hack category, rather than standard, good programming practice. While I'd used from time to time to fix minor issues with 3rd ...
10
votes
4answers
966 views

Forgetting basic language functions due to use of IDE, over reliance? [duplicate]

Possible Duplicate: Should newbies use IDE autocomplete (Intellisense)? Is it wrong or bad to use autocomplete? Having used an IDE for the last 3-4 years, the other day a few of my coworkers ...
8
votes
4answers
2k views

How to deal with complex codes in (huge) projects

I am preparing a memoir about "Why do (some) IT projects become too complex and how to avoid it ?". If you have ever encountered projects having complex codes or were hard to maintain, how did you ...
8
votes
3answers
46k views

Multiple Same Object Instantiation

What exactly happens in Java when you instantiate the same object multiple times? For example: Test test = new Test(); then later on I will call it again, Test test = new Test(); again or inside a ...
7
votes
1answer
4k views

When defining directory path, should a trailing slash be included?

Say I'm defining a directory and then including files from it. Is it better practice to do: define('PATH', 'C:/xampp/htdocs/includes/'); require PATH.'header.php; or: define('PATH', 'C:/xampp/...
6
votes
5answers
2k views

What is more important? SOLID or KISS?

What is more important? SOLID or KISS? To be consistent with SOLID I would have to inject Decorator and Footer classes and create interfaces for them. public class HelloService { String name; ...
6
votes
3answers
3k views

How important is encapsulation? [duplicate]

As a student in programming, I learned that encapsulation is one of the most important principles of object-oriented programming. However, I only follow that principle when I feel like it suits my ...
6
votes
11answers
1k views

Starting all over again? [duplicate]

Have you ever been developing something and just came to a point where you think that this is rubbish, the design is bad and although I will lose time it will be better to just start all over again? ...
5
votes
4answers
336 views

Should I include dependencies for which I have the source as projects in my solution?

We have various projects in source control for web and desktop applications. Invariably, many of them use third-party open source projects or even common libraries within our organization as ...
4
votes
3answers
301 views

Agile methodology in pure technical terms

I often hear about agility processes, but it seems to me that it is (nearly) always tied to team organization and delivery processes. It (nearly, once again) never comes to the bottom of the bottle: ...
4
votes
5answers
957 views

Should Developers Perform All Tasks or Should They Specialize? [closed]

Disclaimer: The intent of this question isn't to discern what is better for the individual developer, but for the system as a whole. I've worked in environments where small teams managed certain ...
4
votes
2answers
6k views

Why put a simple query into a stored procedure in a web service?

I'm working as a junior programmer, and the senior programmer above me has instructed me to follow a certain unofficial policy for constructing new queries on our web development projects. Generally, ...
3
votes
8answers
5k views

Declaring functions in order to avoid explicit nested loops

My programming professor has told me that it is a good programming practice (at least in C/C++) to declare a function with the inner loop when nesting loops (not for loops, since when, i.e. looping ...
3
votes
2answers
2k views

Is coupling a good thing or bad thing when I'm developing standalone modules in a framework?

Encapsulation is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit. Client code is expected to inherit from system-supplied classes and then ...
3
votes
2answers
3k views

What is the best practice for method parameter validation in a library? [closed]

I develop a game library in javascript, containing many classes. I hesitate on the behavior that I should follow concerning method parameter validation: Should I check the validity of parameters ...
3
votes
3answers
5k views

How do you find the most optimized way to write code? [closed]

In my programming career, I have written Java and PHP, Javascript and a little Ruby. I am not a CS major but got into web development from a more broad Internet Professional associates degree, which ...
3
votes
3answers
1k views

Parallel Class/Interface Hierarchy with the Facade Design Pattern?

About a third of my code is wrapped inside a Facade class. Note that this isn't a "God" class, but actually represents a single thing (called a Line). Naturally, it delegates responsibilities to the ...
1
vote
1answer
4k views

Global variable vs. local-static variable for storing state [duplicate]

I am writing an application for my graduation coursework, in C, using GTK+ UI library. Sometimes I ask for user input, which I need to save for later use. The doubt comes on how to store this data. I ...
1
vote
2answers
964 views

Mutual exclusion over network - pattern?

I want to do the following: I have a number of computers. On each computer a programm will run. There is no centralized server. The program can choose by defined criteria to give another computer ...
21
votes
4answers
11k views

What is the limit to the number of a class methods?

In different design books that I read, sometimes big emphasis is put on the number of methods that a class must have (considering an OO language, as java or C# for instance). Often the examples ...
9
votes
7answers
3k 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, ...
8
votes
7answers
3k views

Best practice to “continue” from inside a nested loop?

Here is a simplified sample. Basically, it does checks on a string from a string list. If the check passes, it will remove that string (filterStringOut(i);), and it is no longer ...
6
votes
14answers
5k views

How to minimize typos when you code? [closed]

I make a lot of typing mistakes when I program. I have a good keyboard writing speed but I try to write faster and in the process end up making typos. I want to type faster, but make less errors. Can ...
6
votes
1answer
2k views

Eventual consistency in Banking systems

I keep hearing people say Banking systems like ATM use Eventual consistency model for data synchronization, but I am wondering if it is true. Definitely the amount you withdraw might be delayed ...
6
votes
4answers
1k views

Should I comment Tables or Columns in my database?

I like to comment my code with various information, and I think most people nowadays do so while writing some code. But when it comes to database tables or columns, I have never seen anyone setting ...
6
votes
3answers
2k views

Is it right to skip unit testing and go straight writing integration tests if there's no point of testing the unit in isolation?

According to Martin Fowler's article, https://martinfowler.com/bliki/TestPyramid.html It is advisable to write more unit tests than integration tests. Does this mean ideally that every unit of work ...
6
votes
8answers
8k views

What are the benefits of using comments

I just accepted a new job. Our application is in the 50,000 lines of code area. None of which is commented. I am finding it difficult to understand how the application works. Id like to prevent this ...
5
votes
4answers
383 views

Is it normal to write all logs into a single file?

Our teamlead said that many files much worse than a single, despite of we are working on a big project. He argued that our customers could more easily send logs to us if there will be just a single ...
5
votes
5answers
2k views

I have generally read that having many (>4) arguments to a function/constructor is a bad practice. Is this still considered a bad practice? [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 ...
4
votes
5answers
6k views

If possible, would it be a bad practice to use Nullable for non value types?

After writing this question I found out that Nullable<T> has a type constraint of struct on T so you cannot actually use Nullable for reference types. However, some good answers interpreted ...
4
votes
8answers
580 views

Testing loses its effectiveness if all programmers don't use them

Let's assume you are convinced that the extra time spent unit testing has merit and improves production. Does that still hold up when everyone working on the same code doesn't use them? This question ...
3
votes
2answers
198 views

Writing effective use cases

While writing personal projects as well as well in the job, I often struggle to proceed on the current task because either I get stuck on what I was thinking or didn't thought about all the corner ...
3
votes
2answers
75 views

Deleting Lookup Item

I was wonder what people do in this situation. You have an admin area of a system where you let users define a list of values they want to see in a dropdowns across the system. What do you do in ...
3
votes
2answers
351 views

Is there a name for being able to quickly find the relevant code? [closed]

I notice that a property of codebases that I like hacking on is that it's quick to find the relevant code for some feature, without knowing much about the code base at all. For example, searching for ...
3
votes
3answers
3k views

Does mobile based (Android) development, benefit from Object Oriented Programming?

My development on Android is based on scientific programs and while I'm building these most of the code is in one or two long classes. When I come to deploy these programs I try to decouple everything ...
2
votes
2answers
662 views

history and application areas of 'pull'/'push' programming paradigm

Recently reading a lot materials on Reactive Programming, one thing frequently mentioned is the 'PUSH' versus 'PULL' style of application. Event driven ( Reactive programming ) Some of the authors ...
1
vote
1answer
241 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) { ...
1
vote
2answers
1k views

Wrapping specific checked exception in domain unchecked ones? [duplicate]

Uncle Bob says in Clean Code book that Unchecked Exceptions should be used. Now JDK has some checked exceptions: IOException, IllegalAccessException etc. which cannot be avoided. In my application ...
1
vote
1answer
516 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; ...