Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [language-agnostic]

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

0
votes
1answer
29 views

(Fuzzy) Data duplication detection - scoring systems strategy

Many systems that store data in a structured manner (although this is marked language agnostic, the origin of this question is an MS SQL database) struggle with duplicates. Taking a physical person/...
0
votes
3answers
265 views

How do I test unreachable code?

Let's say your company sells software that comes with customizable text, and your team's job is to customize it. The client engagement includes a contract in which the client specifies all of the text ...
5
votes
1answer
234 views

Encapsulating moving parts in OO vs Minimizing moving parts in FP

I am from OO background just started learning FP paradigm. Came across quote by Michael Feathers - "OO makes code understandable by encapsulating moving parts. FP makes code understandable by ...
1
vote
3answers
274 views

Are unit tests needed for a function that only calls another function?

Assuming OldModule.oldFunc, if we want to move oldFunc to NewModule and, for backward compatibility, keep oldFunc there merely calling NewModule.newFunc by passing the exact same arguments and doing ...
2
votes
2answers
62 views

Cumulative sum of overlapping increase/decrease over time

I am looking for an efficient way to handle a calculation. I have lots of timestamped events, representing loading and unloading of trucks. I need to construct the filling rate of these trucks over ...
10
votes
5answers
2k views

What should I do when optimistic locking doesn't work?

I have this following scenario: A user makes a GET request to /projects/1 and receives an ETag. The user makes a PUT request to /projects/1 with the ETag from step #1. The user makes another PUT ...
1
vote
2answers
178 views

How to handle “Optimistic Locking” on a collection with ETag headers?

Consider endpoint /projects that returns a list of projects with the following headers: HTTP/1.1 200 OK Etag: "superEtag" The etag value represents a hash of the entire collection and it does not ...
-2
votes
1answer
75 views

How to measure complexity of expressions?

I'm comparing two APIs to generate a method in C# and want to measure how "complex" the code to use them is. Consider: API A: MethodDeclaration(PredefinedType(Token(IntKeyword)), "CompareTo") ....
1
vote
4answers
243 views

What should be the last entry in a switch/case statement?

When writing a switch statement that only ever has to deal with a known set of values (imagine an implicit enumeration), I find myself wondering what should be the last entry in the construct. I'm ...
6
votes
3answers
305 views

Equal length variable names: tricks or alternatives? [closed]

This might be a super nerdy, OCD-like, silly question, but... I love it when related variables have names of equal length, such that when written below one another, it lines up nicely. Eg: min/max: ...
9
votes
1answer
103 views

Name of technique for inferring type arguments of a type parameter?

Setup: Let's assume we have a type called Iterator which has a type parameter Element: interface Iterator<Element> {} Then we have an interface Iterable which has one method which will return ...
6
votes
6answers
491 views

Is it bad practice to code the solution, then redo in TDD?

I might be wrong, but I feel like the best approach to TDD is Solution, Red, Green, Refactor (adding "Solution" to the standard formula). By coding the solution first, I feel like I am much more ...
1
vote
1answer
113 views

How can I used fixed-point arithmetic to convert from Celsius to Fahrenheit?

Disclaimer: I realize this is not the easiest or even best way to handle this and I am asking largely out of a sense of curiosity, not because I'm convinced this is the proper way. It's a fun puzzle I'...
1
vote
3answers
410 views

Does the Perfect Compiler trump source differences

Is it theoretically possible to create a perfect compiler for a language (for example C) meaning that if two different persons make two different implementations of the same algorithm then the ...
8
votes
5answers
377 views

Should methods that are not “pure functions” and that interact with external APIs or hardware be static?

When reading about when to make a method static or not, I've seen a general principle, as summarized by this post, that a method should only be static if it does not modify a state and its result ...
13
votes
4answers
831 views

How can you TDD for a bug that can only be tested after it has been fixed?

Here's one example: My web application contains draggable elements. When dragging an element, the browser produces a "ghost image". I want to remove the "ghost image" when dragging and I write a test ...
1
vote
1answer
53 views

Using a permissions object pervasively inside a project to mimic an effect system

There's a design pattern of sorts that I've thought about but haven't seen implemented where every function / method passes around a permissions object. I'm wondering whether using it in a project is ...
3
votes
2answers
119 views

API across multiple languages. Use idiomatic code for each or support the same API structure

I'm currently working on a project which requires to support multiple languages as first class citizens and I'm facing a dilemma. I can choose between implementing the API as closely as possible for ...
0
votes
1answer
164 views

AST design: Call is both expression and statement?

I'm designing the AST for a compiler and found that I don't actually know how to represent the Call node. Currently, the relevant part of the AST looks like this (where the arrows denote inheritance):...
1
vote
2answers
254 views

RabbitMQ as backbone for services written in different languages

I'm seeking advice from people using RabbitMQ to connect services written in different languages. Currently my organization is using RabbitMQ exclusively with C# and it's all working quite well. In ...
1
vote
2answers
112 views

Distinction between “timestamp” and “datetime” [closed]

Is it common to use "timestamp" to mean with time zone and "datetime" to mean without time zone?
1
vote
2answers
118 views

How is code coverage measured?

For many languages there are various tools which measure code coverage. But how exactly does this work? I have some ideas, how this could work: Do coverage tools just run the code in the debugger ...
12
votes
7answers
802 views

In object oriented languages, when should objects do operations on themselves and when should operations be done on objects?

Suppose there is a Page class, which represents a set of instructions to a page renderer. And Suppose there is a Renderer class that knows how to render a page on screen. It is possible to structure ...
7
votes
6answers
662 views

How to name a method which may or may not perform an action depending on a condition?

I stumble across this case somewhat often, and I'm surprised about finding so few similar discussions around the web. This question is very related, but my problem is that I want a method that does ...
2
votes
1answer
778 views

How to update the view when the model changes?

Since I'm learning the MVC pattern, this might be a very naive question. I know that when something happens on the view (e.g. user clicks a button), the view calls the controller which in turn ...
-3
votes
1answer
69 views

Proof that computer communication only exists of function calls and events

I am writing a paper about the use of a message broker for inter-process communication where I state that all computer communications can be broken down into two categories: Function calls Events My ...
9
votes
4answers
394 views

How exactly does a compiler recover from a type error?

I've read several papers, articles, and section 4.1.4, chapter 4 of Compilers: Principles, Techniques, and Tools (2nd Edition) (a.k.a "The Dragon Book") which all discuss the topic of syntactical ...
3
votes
5answers
405 views

Why don't OOP languages offer a feature to clone a parent into a child class?

Consider the following c# example: public class MyParentClass { public int MyInt { get; set; } } public class MyChildClass : MyParentClass { } public class AnotherClass { public MyChildClass ...
3
votes
2answers
299 views

How to avoid generating verbose code when compiling from a higher level language to a lower one?

I apologize in advance for the vague title. I didn't want to make it overly verbose, so allow me to explain more in-depth below: I've currently been developing a strong, statically typed language ...
68
votes
9answers
13k views

Is it good practice to replace division with multiplication when possible?

Whenever I need division, for example, condition checking, I would like to refactor the expression of division into multiplication, for example: Original version: if(newValue / oldValue >= ...
8
votes
4answers
687 views

Is having a generator language facility such as `yield` a good idea?

PHP, C#, Python and likely a few other languages have a yield keyword that is used to create generator functions. In PHP: http://php.net/manual/en/language.generators.syntax.php In Python: https://...
4
votes
5answers
280 views

Does only the concept of mathematical functions justify why methods need only to return one value

Most modern programming languages do not allow multiple return types (excluding scenarios like C#'s out parameters or the newest use of Tuples). This is because all languages implement the concept of ...
3
votes
1answer
113 views

Tool for validation of new code syntax in existing language

Does a programming language team have any tool to validate their new ideas about new code syntax? As an example, let's assume the Java language team starts developing new feature, which requires new ...
2
votes
2answers
202 views

Get value from UI element or from variable

I had a debate with a friend and I'm looking for a way to resolve it and decide which approach is better for maintenance and whether there's some consensus about a best practice regarding it: If an ...
1
vote
1answer
555 views

Limits of dependency injection

I use dependency injection with Guice and most of the time, I'm rather happy with it. But sometimes, it's difficult to get the dependencies to where they're needed and sometimes, it's plain impossible....
2
votes
2answers
635 views

Making a language agnostic Plugin system

I want to make some software which relies heavily on Plugins. I plan on writing it in C++ and will most likely be getting plugins built in C++, Python and possibly Java But most likely C++ and python ...
3
votes
1answer
113 views

Is there a name for the three step backwards compatibility software release? [closed]

The release method I am talking about is this: Release code that works with both old and new clients (forwards and backwards compatible) Release client that only works with the new code released in ...
6
votes
5answers
1k views

Writing a language agnostic API?

I'm planning on writing a C++ program which is heavily influenced by plugin modules. Initially I had only thought of making the APi available as an abstract class that others extend. After talking to ...
-2
votes
3answers
95 views

Adding qualitative information to function names

I started adding informations about the behavior of functions to their name recently. Two big examples: pure - this function has no side effects (besides the returned value), which I would use in ...
1
vote
3answers
116 views

Is it considered a bad practice to import symbols in bulk to a global namespace irrespective of the programming language?

In the C++ community it is considered an extremely bad practice to type: using namespace something; in the scope of the file for any reason, even if the project size is only a few hundred lines at ...
0
votes
1answer
904 views

Is repetition expressed in Backus–Naur form by recursive production definitions?

When reading grammars defined using Backus–Naur form (BNF), I've noticed that the grammars never seem to use an explicit repetition symbol, such as * or +. This is opposed to Extend Backus–Naur form ...
12
votes
3answers
381 views

What is the common way to handle visibility in libraries?

This question about when to use private and when to use protected in classes got me to think. (I'll extend this question also to final classes and methods, since it is related. I'm programming in Java,...
2
votes
2answers
435 views

What are the private method responsibilities when we design class in OOP?

In different design books I have read that First identify the purpose of class (abstraction). Class should only do one thing (SRP). methods are defined as responsibility of the class. As per my ...
3
votes
1answer
160 views

Do any languages make evaluation of the right-hand of an “AND” operation optional?

The C# language has two "AND" operators when dealing with Boolean values, & and &&. (Leaving aside the bit-wise operators.) When the left-hand value is False, the difference between these ...
0
votes
3answers
113 views

What to rename my order table? [closed]

I have a database table named order. It contains eCommerce orders. Problem is, that's a reserved word in MySQL, and while I can use back-ticks to prevent issues, it's probably a good idea not to use a ...
-2
votes
2answers
195 views

Change in constructor parameter or ways to decompose the constructor? [duplicate]

Class Book { private int year; private String session; private int volume; private int number; private String khand; private Date proceeding_date; private int pageNo; Book(year,session,...
0
votes
0answers
156 views

Event correlation engine design: Nesting events vs. using event ids

I am currently (re)designing an event correlation engine and found myself to be uncertain about the design for the events themselves. I have come up with two possible solutions, but both of them seem ...
22
votes
6answers
4k views

What is the common procedure used when compilers statically type check “complex” expressions?

Note: When I used "complex" in the title, I mean that the expression has many operators and operands. Not that the expression itself is complex. I've recently been working on a simple compiler to x86-...
3
votes
1answer
2k views

Tournament bracket algorithm

I am looking for algorithms to make single elimination and double elimination brackets. The first step was figuring out the seeding algorithm, byes included, which I found in several places in SO: ...
1
vote
1answer
295 views

What is the common practice for implementing a microservice architecture? [closed]

so I'm trying to understand how microservices are set up in a language agnostic manner for purely experimental purposes. For the sake of having a more concrete example, how would a microservice ...