Skip to main content
Share Your Experience: Take the 2024 Developer Survey
40 votes

Why are module-specific prefixes widely used for function names in C modules?

Why prefixes in the first place? The prefix for function names is a C practice that intends to avoid naming conflicts. This is especially suitable in big projects, where different teams could easily ...
Christophe's user avatar
  • 77.9k
33 votes

Why are packages and modules separate concepts in Java 9?

The concept of a module is different from the instantiation of that concept. Java has always had modules. A method is a module, so is a class and so is a package. A module is a unit of organisation ...
Neil Bartlett's user avatar
20 votes
Accepted

Classes vs. modules in Python

A python module is nothing but a package to encapsulate reusable code. Modules usually, but not always, reside in a folder with a __init__.py file inside of it. Modules can contain functions but also ...
Eneko Alonso's user avatar
17 votes

Why are module-specific prefixes widely used for function names in C modules?

There are two important types of naming collisions here. You are correct in that the compiler won't have any trouble differentiating between the functions due to scope rules. Your problem is that ...
bta's user avatar
  • 1,123
16 votes

Why are module-specific prefixes widely used for function names in C modules?

There is another reason to use prefixed names even for file-local functions: they can be navigated with simple text search and text indexers without full analysis of language scoping, such as id-utils....
max630's user avatar
  • 2,587
10 votes

C++ namespace name isolation

Your approach is not technically wrong (except a minor detail, see footnote) but it goes against established usage patterns and obfuscates code. I.e. it lowers readability and increases the likelihood ...
besc's user avatar
  • 1,163
9 votes
Accepted

What is the difference between Applicative and Generative Modules, and Type Classes?

Since both are in OCaml, We can explore the difference between generative and applicative functors easily: module type S = sig type t end module M = struct type t = int end (* An Applicative functor....
Drup's user avatar
  • 204
8 votes
Accepted

How does java 9 manage module versions?

It won't, dependency-resolution is a non-goal for the Java Platform Module System (source): Non-requirements Multiple versions — It is not necessary to support more than one version of a ...
NickL's user avatar
  • 260
8 votes

C++ namespace name isolation

Looks like a wrong approach, for several reasons: The things that you don't want to be "visible" to outside, should not go into headers. Instead they go into anonymous namespace in the source file. ...
BЈовић's user avatar
8 votes
Accepted

Does a programming language with ML-style modules need packages?

Modules and packages solve different problems, though they certainly overlap, and can be made nearly synonymous. Packages provide a critical source of namespacing. Modules aren't guaranteed unique ...
Kenogu Labz's user avatar
7 votes
Accepted

What is the idiomatic way to split code between separate files in Rust?

In multi-paradigm languages such as Python, C++, and Rust, it is not always easy to see what should be in the same file. In particular with Rust, it is not even necessary to keep data definitions (...
amon's user avatar
  • 134k
7 votes
Accepted

How to think when grouping functionality into modules

Both of your examples could be valid groupings to create modules. Besides that modules group related functionality, there is another, possibly more important, property to them: Modules communicate a ...
Bart van Ingen Schenau's user avatar
6 votes

Classes vs. modules in Python

If it's a bunch of pure functions, e.g. re, I put them in a module. I use a class when I know there's state I want to keep with that code (e.g. a file that gets read in once, but whose data is used by ...
Greg Bell's user avatar
  • 177
6 votes

C++ namespace name isolation

What problem do you want to solve? That is completely unclear. As for your code, if you were a junior assigned to me, I would say: Your approach doesn't hide implementation details at all - they are ...
Sjoerd's user avatar
  • 2,936
6 votes
Accepted

Should I divide C++ program into multiple interacting applications?

multiple separate executables that would communicated using shared memory This is a fairly bad idea, because suddenly your program is impossible to debug. If process A crashes while looking at some ...
pjc50's user avatar
  • 13.5k
6 votes
Accepted

What is module in Software engineering context?

A module can be an abstract unit of implementation, e.g. larger than an object, perhaps a collection of interacting objects.  Modules are meant to be more loosely coupled with each other than the ...
Erik Eidt's user avatar
  • 34.1k
6 votes

How to think when grouping functionality into modules

Others have posted good reasons, such as communications, making code "easy to find", and mental models. There are also technical reasons for dividing code into modules. Though the Single ...
user949300's user avatar
  • 8,841
5 votes

What is it that is so hard about ES6 modules for Node?

Essentially, it boils down to how to get two very different module systems to work together. CommonJS (CJS) Modules are dynamic and synchronously loaded, ES Modules are static, immutable and ...
curiousdannii's user avatar
4 votes

C++ namespace name isolation

If you really want constructive feedback on this approach, it would have been better to show some actual code that you think benefits from it. Then we'd have something concrete to discuss rather than ...
Useless's user avatar
  • 12.6k
4 votes

How to think when grouping functionality into modules

The number one strategy for dividing software into modules is to make things easy to find. You can actually use more than one organizing principle in the same code base. But you must be clear when you'...
candied_orange's user avatar
4 votes

How to think when grouping functionality into modules

How source code is best organised is related to the mental conceptualisation of the developers who produce that code. The basics of software are data structures and algorithms - at least as the late ...
Steve's user avatar
  • 8,939
3 votes

Should I divide C++ program into multiple interacting applications?

The arguments for splitting are that every part can be developed separately, You don't need separate executables for doing that. You don't even need separate binaries (dll or so) for that. You just ...
17 of 26's user avatar
  • 4,839
3 votes

Making an existing project modular

I want to answer this but the thing is, does modular really refer to how your going to separate programs into repositories? Usually a program being modular would refer to a program and its ability to ...
Rhys Johns's user avatar
3 votes
Accepted

What is the name of the interface-implementation pattern applied to modularisation?

Martin Fowler has previously described something similar using the term Published Interface: Published Interface is a term I used (first in Refactoring) to refer to a class interface that's used ...
Ben Cottrell's user avatar
  • 11.8k
3 votes
Accepted

Separating namespaces from files in Python

I don't think it's sensible to separate the classes from builder if this causes cross-references (and probably cyclic imports to solve). If your goal is simply to expose what is meant to be public or ...
Diane M's user avatar
  • 2,076
3 votes
Accepted

Shared library and modules with versioning

You asked this in a pretty broad fashion, so here is an equally broad answer: it depends. In smaller systems, #1 will be usually desirable, since it reduces configuration management efforts and ...
Doc Brown's user avatar
  • 208k
3 votes
Accepted

How to define vertical slice in a system whose horizontal slices are defined by Java modules?

Slicing projects based on presentation, business and persistence is a very popular way of structuring a project. It is also a pretty costly one. This is the kind of architecture where you try to ...
Robert Bräutigam's user avatar
3 votes

Why does CPython has both C and .python versions of modules?

C code is real code, python is interface code. The c code is the performant code, while the python is for python runtime to correctly handle call sites. Also use the c code Version to get the most ...
Max N's user avatar
  • 112
3 votes
Accepted

Why does CPython has both C and .python versions of modules?

When there are two modules in the standard lib with the same name, what often has happened is that the original module was written in Python. That's because it is a lot easier to prototype and get it ...
Gringo Suave's user avatar
3 votes

Modules Design and Communication Between Them

Replication is redundancy. It won't be a good idea, neither good practice. You would have to make modifications in multiple places in case of a requirement change. User and User types are related, ...
Irfan Irfi's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible