Tagged Questions

This tag is for questions that aren't specific to a programming language or environment.

learn more… | top users | synonyms

1
vote
2answers
130 views

Deriving from a class only to provide a special constructor

In our codebase, I encountered the following construct: There is a base class B, and then there is a class D which derives from B, but does not override or add any members. In fact, D is completely ...
0
votes
2answers
84 views

Handling repetitive unit testing tasks [duplicate]

This problem arose whilst writing a simple 3D vector class. The class contained methods (Java, so no operator overloading) for addition, subtraction, multiplication, and division. These methods ...
20
votes
8answers
4k views

What is the benefit of a function without parameters which only calls another function

A tutorial (for Javascript) I'm doing suggests we write a function like this one: function sayHello() { //Some comments explaining the next line window.alert("Hello"); } Other than ...
-1
votes
2answers
111 views

How can I refer to the standard language documentation less? [closed]

When I code in a language (ex. Ruby) I find myself looking up things in the standard ruby docs quite a bit. Array#include? for example (I had tried Array#contains?), method names I feel I shouldn't ...
5
votes
2answers
217 views

Is there any language-agnostic specification for “String Natural Sorting Order”

As I painfully try to find a good natural sorting algorithm written in JavaScript I then stumble upon a bunch of different implementations, & interesting blog posts & answers on Stack ...
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, ...
9
votes
4answers
529 views

Is it ever OK for a conditional to have side effects? [closed]

I'm taking intermediate data structures course as a prereq for entry into the CS MS program at a University everyone in America has heard of. One line of code that was written in class caught my eye: ...
2
votes
4answers
504 views

Why aren't we building and using parallel processors *meant* for general computation?

We all know GPUs are much faster than CPUs for a wide range of applications. When someone asks why we are not just programming for GPUs at all, one of the most common answers is that GPUs are not good ...
1
vote
2answers
111 views

Should I throw guard exceptions that will be thrown by internal methods anyway?

I have some fairly simple code (C#): /// <summary> /// Truncates a string to a maximum length. /// </summary> /// <param name="value"> The string to truncate. ...
2
votes
1answer
80 views

class hierarchy with structurally different subclasses

I want to implement a protocol layer which sits on top of the TCP/IP stack. There is a limited set of PDUs that can be sent and for each PDU there is a class which represents it in a structured form. ...
0
votes
2answers
62 views

Map multiple functions over a single data item [closed]

I'm in the process of learning Scala and I came across a scenario today where I need to map multiple functions over a single piece of data and wondered if there was a formal name for this. It sort of ...
0
votes
1answer
78 views

Avoid Code Repetition in Condition Statements [duplicate]

I have been programming for over 15 years now. I consider myself a very good programmer, but I understand (like all of us) there are things that I need to work on. One of these things is code ...
2
votes
5answers
260 views

Do first-class methods exist?

Okay, I know first-class functions are cool, closures even better, etc. But is there any language with first-class methods? In my mind, I see a first-class method as an "object" that has both a ...
-3
votes
2answers
100 views

How to name a clamp function that only clamps from one side? [closed]

Clamp() is a function that ensures that provided variable is in provided range. You can find such function in .NET, in Unity, and probably anywhere. While it is useful, I often need to clamp my value ...
17
votes
1answer
695 views

Where did the notion of 'calling' a function come from?

I've always wondered why one calls a function as opposed to, for example, executing it. A Google search for function call etymology and similar terms turns up nothing useful, Wikipedia doesn't ...
1
vote
2answers
202 views

How do you guard against hidden overflows

consider the following: (i+j)/2 i and j are both 32 bit integers and the result should also be. But in the little equation, there's a hidden overflow, i+j could become larger then a 32 bit integer ...
-3
votes
3answers
138 views

What is the verb for “to make something into a plugin”? [closed]

What is the verb for "to make something into a plugin"? Example use: "Developer can you make Module Foo into a plugin?". "Yes sir, I can some verb Module Foo". Terms I have considered: pluginify, ...
-2
votes
3answers
186 views

Is there an official programming format? [closed]

A person can make their code readable and neat in their own way. However, is there a standard programming format that professional programmers are compliant to?
2
votes
2answers
255 views

Does it make sense to use interfaces if you don't have polymorphism?

Suppose I have distinct classes that have the same behavior, which can be represented like this: public interface Behavior { void operationA(); } public class ImplementerA implements Behavior { ...
0
votes
1answer
124 views

Traverse a matrix using a linear index to get an evenly distributed values sample

I'm looking for an algorithm idea on how to traverse a matrix using a linear index while avoiding row/column based traversals to get a more diverse distribution of values. To understand this better, ...
4
votes
3answers
504 views

Functional programming strategies in imperative languages

I've been convinced for awhile now that some strategies in functional programming are better suited to a number of computations (i.e immutability of data structures). However, due to the popularity of ...
3
votes
1answer
306 views

How can I rewrite this linked-list manipulation as tail-recursive?

This is an interview question I was once asked, and now I ask many of my interviewees. I have yet to see anyone come up with a tail-recursive solution during the interview. Given a liked list, I'd ...
37
votes
11answers
2k views

When should the programmer's spoken language be used during development? [duplicate]

I'm an Italian developer, but I have a good understanding of English. Sometimes, when developing an application targeted for an Italian audience, I wonder whether it is correct to use the Italian ...
8
votes
1answer
623 views

What's the copyright status of boilerplate code?

I check Open Source Compliance for commercial code. I have recently found a few examples where the commercial source is matched against quite a few OSS projects. The matches are very similar, but ...
13
votes
5answers
1k views

Dealing with not knowing parameter names of a function when you're calling it

Here's a programming/language problem I'd like to hear your thoughts on. We have developed conventions that most programmers (should) follow that aren't a part of the languages syntax but serve to ...
1
vote
1answer
113 views

How to manage version control company wide? [duplicate]

Are there any industry standards or best practises on how to manage a rapidly changing code base? The types of applications I am developing always have a custom aspect to them. So there will always ...
3
votes
1answer
155 views

Can the possibility of a data race be ignored in some cases? (while having concurrent threads) [duplicate]

I am programming a game engine as a hobby project, and I would like to separate physics and drawing into two separate threads. The position vectors of entities are subject to modifications by the ...
0
votes
0answers
126 views

Junior - How to understand the flow of the code? [duplicate]

A junior asking... First a rather large chunk of background Assume you have done some programming and now you want to take the next step out in the real world or at least learn more. I have no ...
1
vote
2answers
102 views

Logging events for reporting purposes

Are there any design patterns or best practices around logging events for use in reporting and BI systems. For example in a system which manages orders from a website, it would be beneficial if a ...
9
votes
12answers
2k views

Why don't more languages have the ability to compare a value to more than one other value? [closed]

Consider the following: if(a == b or c) In most languages, this would need to be written as: if(a == b or a == c) which is slightly cumbersome and repeats information. I know my above sample ...
2
votes
1answer
91 views

Assert Message in Unit Tests

I've just begun reading "The Art Of Unit Testing" by Roy Osherove, and while I'm mostly finding the material very helpful, he makes a statement about not using messages in your Assert statements. ...
15
votes
3answers
422 views

Should I include myself as an author after modifying 3rd-party code?

It's common practice to make some tweaks or fixes in 3rd-party code (be it a simple gist or an entire library). But it's also common that many of these code have they own licensing rules and ...
-4
votes
2answers
333 views

How to really understand programming? [duplicate]

I have started to learn to program. I am interested in it and dont mind how long it takes to learn. But I am using books to start out and I find that there are some things I get and some things I have ...
21
votes
9answers
3k views

Able to read Code but struggling majorly to write it [closed]

I had my first programming exam recently...and well I pretty much flopped it. Did not do great at all. I have only myself to blame as outside of college time, I pretty much did nothing. Now I have ...
2
votes
4answers
219 views

How to explain the difference between a variable and a key in a key-value pair?

Variables and the keys in key-value pairs are both identifiers for values, so, on a conceptual level, these seem very similar ideas. How would you explain the difference between these two concepts? ...
19
votes
2answers
1k views

What is the advantage of wrapping exceptions [duplicate]

It's very common in .NET for an exception to be wrapped in several layers of "outer exceptions" which give marginally more contextual data. For example, in EF if your update fails, you get exceptions ...
10
votes
3answers
920 views

Are these programming “classics” still relevant today and should I read them? [closed]

I have come across numerous older posts that highly recommend the following language agnostic programming books: Code Complete by Steve McConnel The Pragmatic Programmer - Andrew Hunt and Dave ...
21
votes
9answers
2k views

What is the benefit of having the assignment operator return a value?

I'm developing a language which I intend to replace both Javascript and PHP. (I can't see any problem with this. It's not like either of these languages have a large install base.) One of the things ...
4
votes
4answers
2k views

Returning null or a empty value/throw exception? [duplicate]

Various programming books suggest that methods should not return null values (Clean Code for example). Instead of returning null default values (0 or empty string or empty object) should be returned ...
2
votes
2answers
102 views

Form cancellation. Where should any data rollback occur?

You have a form that has an object injected into it. The user interacts with the form and updates the injected object via the UI. If the user then 'Cancels' the form, whose responsibility is it to ...
5
votes
5answers
487 views

Finding most Important Node(s) in a Directed Graph

I have a large (≈ 20 million nodes) directed Graph with in-edges & out-edges. I want to figure out which parts of of the graph deserve the most attention. Often most of the graph is boring, or at ...
3
votes
4answers
268 views

How to handle affinities?

Assume we have an abstract class having several concrete classes which interfaces publish an information under several equivalent forms, with the difference that each class has a preferred form which ...
0
votes
2answers
83 views

Placing arguments on their own lines [closed]

This question applies to both parameters and arguments, since I've seen this style used in both. I usually write parameters like this someFunction(arg0, arg1, arg2) but I've recently noticed that ...
14
votes
2answers
664 views

Which is better: a bunch of getters or 1 method with a selection string parameter?

Our knowledge domain involves people walking over a pressure-recording plate with their bare feet. We do image recognition which results in objects of the 'Foot' class, if a human foot is recognized ...
1
vote
1answer
234 views

Will we go back(?) to fixed-point arithmetic in the near future? [closed]

As far as I recall, this has been the ongoing trend of the past, I'm just a student, so I might be wrong: Long ago: Integer numbers and calculations. Very precise, however cannot present a big ...
2
votes
1answer
161 views

Draw graph of a function whose characteristics are unknown [closed]

Suppose I have a function. I have code that, given an x value, produces a y value. I can assume that the function is somewhat mathematically sane, not something crazy like an ...
5
votes
3answers
2k views

Should I refactor a F class from code climate? [closed]

According to code climate (static quality analysis), a class is F, aka the worst mark you could be granted. I did submit a pull request to rearrange it here Which has been refused because the new ...
0
votes
1answer
121 views

Is there any use for layout managers beyond Java? [closed]

I am a beginning programmer and I was recently working on some primitive GUI apps in Java. That's where I encountered different layout managers. I browsed the web and it says that for advanced GUI ...
-1
votes
2answers
119 views

What are some examples of inverted classical inheritance? [closed]

Are there any examples of inheritance in languages where classes call their subclasses' methods rather than their super classes' methods? It should not behave like traditional inheritance like the ...
1
vote
3answers
284 views

is using a PUT with side affects acceptable (REST)

I want to create an undo history whenever the user updates a form. Because it's an update, I want to use a PUT request. However, I read that PUT needs to have no side effects. Is it acceptable to ...