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

learn more… | top users | synonyms

2
votes
1answer
43 views

Pattern for “Assembling” result from multiple datasources

I'm creating a server in Java (although this question is language agnostic) that will do the following: Pull a set of "leads" from a database every 10 minutes For all leads with a certain marker, ...
-1
votes
1answer
160 views

Why is 'continue' the keyword for skipping the rest of the loop iteration? [closed]

Many programming languages contain a 'continue'-keyword, which is used to skip the rest of a loop body. I've always felt like this was a misnomer, since IMO the term 'continue' in real life refers to ...
0
votes
2answers
147 views

Are private members useful anymore? [duplicate]

Watchpoints and data break points make it possible to watch the changes of a value in memory in many languages. Much of the justification I have seen for getters and setters and private variables ...
2
votes
4answers
200 views

Using variable + method invocation or repeating invocation?

Here is two methods that does the same thing. One is repeating the call to the method Print where the other one does not but has an additional variable. class Program { static void Main(string[] ...
7
votes
3answers
304 views

Origin of “a method should return a value or have side-effects, but not both”

I read once that a method should either have a return value (and be referentially transparent), or have side-effect(s), but not both. I cannot find any references to this rule, but want to learn more ...
4
votes
2answers
316 views

Is this data model a list or tree?

Using python syntax with below environment diagram, teacher taught us that there are 11 trees(orange boundary) in this diagram, including leaf. It has been taught here, lists are represented as a ...
1
vote
1answer
70 views

What is a good metric for guiding a switch from a prototyping language to a production language? [duplicate]

By "prototyping language", I mean one which was chosen by virtue of it's relative ease of quickly accomplishing the sort of design changes common to prototyping in a particular context. (such as data ...
2
votes
1answer
30 views

Storing exception information as a member variable for query later, bad practice? [duplicate]

I looking at the best way to handle exceptions, the answer to this question may be to handle the exception in a different place or to not handle to exception at all but to control the flow of the ...
3
votes
2answers
131 views

What is a proper way to chain instructions if previous one is ok [duplicate]

I'm currently working on a big file I have to parse and process and each step needs to be done in an order as I do SQL queries and need inserted IDs to make other insertions ... The problem is I often ...
0
votes
1answer
107 views

Passing same argument to multiple small functions versus doing everything in one big function?

I have inherited a class method from another developer, which looks like below: (Note: Class:X means X is a member of Class in the OOP paradigm.) Class:BigFunction() { ImportantValue = ...
1
vote
1answer
126 views

Why sequences are recommended as conventional interfaces?

From the reference of berkeley's version of sicp text, It is mentioned that: Expressing programs as sequence operations helps us design programs that are modular. That is, our designs are ...
6
votes
3answers
176 views

What is the functional programming answer to type-based invariants?

I am aware that the concept of invariants exists across multiple programming paradigms. For example, loop invariants are relevant in OO, functional and procedural programming. However, one very ...
75
votes
7answers
7k views

Short circuit evaluation, is it bad practice?

Something that I've known for a while but never considered is that in most languages it is possible to give priority to operators in an if statement based on their order. I often use this as a way to ...
1
vote
2answers
56 views

Module based project vs Normal project [closed]

I am writing code on top an established Enterprise application. I see that the application has 4 modules as shown below. -Srk -SrkEJB -SrkUtils -SrkWeb I have gone through the code and I see that ...
2
votes
4answers
163 views

How wrong it is to have multiple associations between classes?

I'm modeling a college process, in which I have three classes: Student, Subject and Degree Degrees have their own subjects, students have a list of subjects they have passed, and also students should ...
1
vote
2answers
68 views

How to implement rounding in an all-purpose stack language using different types?

Disclaimer: If you are not terribly interested in numerics and mathematical processes, this is most likely nothing for you. I am currently a bit stuck in a development process of a private project I ...
2
votes
1answer
138 views

Sorting a large number of unknown items with multiple stacks

Here is a problem I'm trying to solve for a personal project. I'm not exactly sure how best to even approach it. Problem: I have a single stack already populated with several thousands of unknown ...
0
votes
5answers
546 views

Fastest way to determine if a value is in a list?

I'm aware there may not be a good solution to this problem. I'm looking for a fast algorithm that determines whether or not a value (let's say an integer) exists in a set of values, however I need the ...
3
votes
1answer
135 views

What data type is this?

I have a list of items I am adding to, however this special list will delete anything past a given capacity. Note the order is maintained. For the life of me, I can't think of the name of such a ...
0
votes
3answers
76 views

Handling source code table alignment

Sometimes there is need to have tables (big or small) in source code. ItemType const SomeTable[] = { // id name min max ITEM( 3, "Foo", 70, 180), ITEM(13, "Bar", 30, 50), ...
2
votes
1answer
93 views

Ambiguity of seemingly clear method names in APIs

(The question is language-agnostic, but to illustrate the point, I wrote the examples in C#.) Say I'm trying to model the behavior of "components" that communicate via "ports". I might model this ...
0
votes
2answers
241 views

Why does Java (and other langs too) have seemingly redundant functions like “str.startsWith(String str, int fromOffset)”?

I was wondering why Java and other programming languages implement (seemingly) redundant functions such as: "foobar".startsWith("bar", 3); // same as "foobar".substring(3).startsWith("bar"); // or ...
0
votes
1answer
54 views

User sessions in a web server; speed or persistence?

I'm looking to implement sessions for a web server that I'm developing in my free time. Currently, it had cookie support, so users could implement their own session management, but this is something ...
1
vote
1answer
278 views

How would a compiler turn an else-if cascade into a switch?

I don't like switch in C and its descendants. Maybe it's the need for a break or the clumsiness of the syntax requiring a shifting of mental gears, I don't know. Whatever the reason, I will almost ...
3
votes
3answers
152 views

Approach to designing a workflow web app that contains some automation

I have been tasked with creating a web application which will provide end-users with a self help workflow, asking them questions and skipping to another part of the workflow depending upon the ...
109
votes
9answers
9k views

When is it a good idea to force garbage collection?

So I was reading a question about forcing the C# garbage collector to run where almost every single answer is the same: you can do it, but you shouldn't - except for some very rare cases. Sadly, ...
-6
votes
2answers
192 views

Why don't we have a default character for the opposite of 0? [closed]

We often have first and last, next and previous, etc... Why not having the opposite of 0 by default as well?! I think it could become very useful if we had one. I hardly ever use it because we don't, ...
0
votes
2answers
123 views

Is there accepted decimal-based Unicode notation for technical audiences?

When writing for technical audiences, there are various ways to type Unicode representations, but they all seem to be Hexadecimal: \uFFFF - From C# / Java Strings \U0000FFFF - From C# / Java Strings ...
0
votes
0answers
35 views

Limiting repetitions in Backus Naur forms

Is there a method using Backus-Naur Form (BNF) to limit the number of repetitions? Let's take the description of a decimial number. A decimal number will consist of 1 to many digits. Is there a ...
15
votes
5answers
2k views

If Else - Repeated Code Logic

My boss gave me a project with a particular logic. I have to develop a web page which has to lead the navigator through many cases until he/she arrives at the product. This is the path scheme of the ...
5
votes
1answer
161 views

Is it poor decision making that using promises for GUI inputs?

So as you know the context: DOM with JavaScript, even though I think it is mostly a language agnostic issue (I know I put both language-agnostic and JavaScript tags, but it's only to let you see ...
3
votes
1answer
219 views

Why the practice of writing unit tests in a different language isn't that popular?

When Microsoft released Visual Studio 2008, there was a thing they were talking a lot about at the conferences and in their online tutorials: the idea of writing the actual code in one language, and ...
1
vote
1answer
68 views

why are the evaluation strategies call-by-value etc. only discussed in the context of function calling?

I am referring to various discussions on the differences and nuances in the semantics of pass-by-value, pass-by-reference, e.g. in SO or in the Wikipedia article on the subject. My question is why do ...
0
votes
2answers
143 views

Why is the “period of a (pseudo)random number generator” important?

I've been trying to understand (pseudo)random number generator code from various sources and the concept of the period continues to elude me. To satisfy the minimum level of understanding, I've tried ...
1
vote
0answers
61 views

Designing an Action abstract class with GUI

I have an Action class, where an Action can do a range of things, including: Performing a sequential list of other actions Performing an action if a condition is true Allowing the user to pick ...
3
votes
2answers
231 views

Should log/data files be stored in the database? [duplicate]

I'm working on a project where we produce lots of data in the form of simple .txt files. These usually contain a set of columns that will later be loaded in to Matlab to be analysed. I've implemented ...
4
votes
1answer
97 views

Mathematically correct A* heuristic / distance estimator for a latitude / longitude graph

I have a graph in which each node is a geographical point on the surface of the earth, defined by it's latitude / longitude coordinates. Correct ways to calculate the distance between two such points ...
0
votes
1answer
137 views

Changing an object's (apparent) class at runtime

I'm looking for a design pattern to solve the following problem: An object (let's say representing a document) can change its type dynamically during its lifetime (e.g. when it is saved with a ...
0
votes
1answer
86 views

How to design method that returns a compact representation of sourcecode

Let's say we have a class that stores some textlike content like sourcecode as a string. We want the class to be able to not only show the sourcecode itself but also a more compact representation. My ...
3
votes
1answer
426 views

Introduce Data Transfer Objects or expose complex data model in REST

We are working on an MVVM application. Jersey (backend) exposing a REST interface and AngularJS (frontend) being the only consumer of this interface. The application uses a complex database model ...
1
vote
1answer
94 views

Why do UTC Dates have different days of the week for some months?

I've been using the Javascript Date API for a calendar application, and I noticed that for every month between 3 and 9 (April and November) the methods Date.getDay() and Date.getUTCDay() return ...
1
vote
0answers
67 views

Pre-Compilation Processor:

What I want to do: Parse source code, search for a beginning and closing tag of my own definition (one that does not conflict with any defined patterns in the programming language), and then replace ...
1
vote
2answers
663 views

Are there other ways to limit recursion depth for a function?

I am trying to prevent a function/method (in Java) from performing recursion more than a depth of 3 self calls. I've learnt about the accumulator trick from odersky's scala coursera course. public ...
2
votes
2answers
83 views

Method for all objects for checking conditions which also includes method chaining and avoiding variables

(I am currently using groovy but it should apply to most OO languages so I also put the langauge-agnostic tag) I try to program in a function style which also includes method chaining and avoiding ...
1
vote
2answers
149 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
107 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 ...
5
votes
2answers
336 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
81 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
554 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: ...