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

learn more… | top users | synonyms

2
votes
1answer
111 views

Word game algorithm

Back in the days of 8-bit machines there existed an educational word game. I have no idea what it was actually called but for the sake of this question (since it involves pyramids) let's call it ...
2
votes
4answers
118 views

Is the var token necessary to signal variable declaration?

When creating a variable foo, Python lets you just write foo = bar. However many languages, like C# or JavaScript, require additional syntax like var foo = bar or foo := bar to signal the same thing. ...
1
vote
2answers
145 views

How are non-folder files called? [closed]

Maybe it looks like a weird question, but what term should be attributed inside the code for files that are not folders to differentiate them from folders? If I need write 2 functions isFolder() and ...
9
votes
3answers
155 views

Indentation in a multi-language file [closed]

In files that contain multiple languages (ie. template files), are there any best practises regarding indentation? I mostly use this: <div> IF FOO <div> ...
2
votes
2answers
211 views

Avoid This Pointer

PROBLEM: this points to different instances at different stages of execution (as it should). But it is not always obvious which instance is that. On the other hand we could minimize the use of this, ...
6
votes
3answers
339 views

What would be a good approach to generate a tree of folders?

Say I have an array of strings, like this: var folders = new[] { "Foo", "Bar", "Foo\Bar" "Foo\Bar\Baz" }; And that I have an object that represents a folder - something like this: ...
4
votes
4answers
124 views

How to prevent user from requesting API method multiple times in parallel?

Let's say we have an app where the users gain points and can exchange them for rewards. The exchange request, in pseudo-code, could look like this: function exchangePointsForReward(userId, rewardId){ ...
3
votes
3answers
202 views

How to “program to an interface”

I've read these questions: Understanding "programming to an interface" What is the point of an interface? Does it always make sense to "program to an interface" in Java? I ...
5
votes
6answers
538 views

Is it an overkill to write unit tests for a small code base? [duplicate]

I am the sole maintainer of a code base of about 2000 lines of code. It's not big, but over time the code became so unmaintainable my boss agreed to give me time to rewrite it from scratch. Since the ...
2
votes
1answer
39 views

How to integrate modified generated code into the build process?

I'm using a code generator which has the following workflow: Configure stuff Generate code Modify generated code with user code at specifically annotated positions. If changes are required to the ...
-1
votes
2answers
63 views

Abstract Syntax Tree with parent or not? [closed]

My question is as simple as the title says -- should I implement AST with parent or not? Currently I implemented it with parent -- the benefit of that approach is, that whatever I use, I can go up or ...
0
votes
0answers
38 views

How to ensure feature parity of a product across different platforms

this question looks like How to plan/manage multi-platform (mobile) products but the answers there suggest using abstractions to ensure a common code repo, which is something that we decided not to ...
20
votes
1answer
754 views

Is there really a fundamental difference between callbacks and Promises?

When doing single-threaded asynchronous programming, there are two main techniques that I'm familiar with. The most common one is using callbacks. That means passing to the function that acts ...
16
votes
4answers
603 views

How to write maintainable, not brittle, unit tests for a GUI?

I tried writing UI unit tests for my GUI apps and I face the problem that, while they work well when I initially write them, they turn out to be brittle and they break whenever the design changes ...
3
votes
3answers
91 views

How to design access to different type objects in protocol response

I have written a communication library for an industrial device protocol. The response frame contains a byte array as payload data. The payload data consists of several "objects“ of different types, ...
22
votes
3answers
2k views

What's the name for the 'spec' of a function/method?

I'm pretty sure there is a special name for the 'spec' of a function/method. It's a word that refers to how many arguments it takes the order of arguments which arguments are optional Is there a ...
16
votes
7answers
1k views

Writing comments for some small code with rather large background [duplicate]

So I had to write some code related to splitting Bezier curves into parts. I read through several references and particularly referred this rather detailed one. The final code outcome is however ...
19
votes
2answers
389 views

How different is garbage collection in pure languages?

In a pure language like Haskell, all data is immutable and no existing data structures can be changed in any way. Additionally, many algorithms on immutable data and functional programming patterns ...
0
votes
4answers
309 views

How to represent an algorithm as a class?

I am trying to understand how to design classes which take an input, do some processing, and return a result. More specifically, should the object store the intermediate results between function calls ...
0
votes
2answers
141 views

two repositories with kind of different behavior serving same object

I have a simple object like this public class Book { public List Chapters { get; private set; } public TableOfContent BookTOC { get; set; } public string Identifier { ...
2
votes
1answer
49 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, ...
0
votes
2answers
167 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
209 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
365 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
328 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
75 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
36 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
140 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
127 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
165 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 ...
7
votes
3answers
215 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 ...
78
votes
7answers
8k 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
68 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
184 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
78 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 ...
4
votes
1answer
304 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
739 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
154 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
91 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
110 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
269 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
79 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
321 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
258 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 ...
115
votes
9answers
13k 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, ...
0
votes
2answers
153 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
50 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
202 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 ...
4
votes
1answer
340 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 ...