23
votes
Accepted
Is duplicating files to avoid programming branching a good or anti pattern?
If changing the sound files for each single grade without modifying the code is the requirement here, I would externalize the configuration (mapping).
Create entries in your configuration mechanism (...
11
votes
Is duplicating files to avoid programming branching a good or anti pattern?
It is neither good or bad, and definitely neither a "pattern" nor an "anti-pattern". This is all about what your (non-functional) requirements are.
You wrote you want to be able "to change grade 0 to ...
8
votes
Why would I use a queue to list all files and subfolders recursively
Because
Depth
First
Traversal
Is
A
Silly
Way
To
Display
Files
6
votes
Accepted
Why do disks write data in chunks of page size?
That's due to the mechanics.
A disk is a surface which rotates around its axis at a high speed (in reality several surfaces). The surface is divided into concentric tracks, and a motor controls the ...
4
votes
Accepted
Why would I use a queue to list all files and subfolders recursively
There are two options to traverse a tree what a filesystem traditionally is.
Traverse it using recursion.
Use loops and a stack or queue to keep track of the remaining nodes to process
Recursion often ...
3
votes
How does the MVC pattern actually work?
In short: Views send UI Events to Controllers, Controllers figure out from Events what to send to Models, and Models, once processed data from Controllers, let Views know data has changed.
The short ...
3
votes
Accepted
How might encapsulated source be broken into into multiple files?
The result of your suggested code organization does logically not differ from
a single header file mystruct.h with the struct itself and all function declarations, plus
a single code file mystruct....
3
votes
Why do disks write data in chunks of page size?
Your mechanical hard drive reads and writes data at 100 MB per second, using a strong magnet. To change a single byte, you’d have to turn that magnet on for ten nanoseconds. In order to not destroy ...
3
votes
Best approach to persist settings in files
Have you tried SQLite? It's a self contained embedded lightweight SQL database. A lot of applications use it to store user settings and other persistence use cases in Desktop Apps - all the major ...
2
votes
Accepted
What's the best approach for using Git for a project containing a largish binary database (4 GB, 4000 files)?
Best approach I can think of is:
do not put the large binary files directly into version control, instead, put them in a folder with a version number on a network share (or whatever kind of file ...
2
votes
Is duplicating files to avoid programming branching a good or anti pattern?
Is using the { character twice in your program a violation of DRY? I hope you will say, naturally not.
When evaluating if something is a violation of DRY, you must not only consider the similarity ...
2
votes
Why do disks write data in chunks of page size?
All memory devices at every level of the memory hierarchy (from L1 cache, main memory, disk...) offer sequential access as a faster mode compared to random access. Random access requires ...
2
votes
How to append a chunk of fixed size data to a file and make sure this chunk doesn't get fragmented on disk?
You don't. At least in the physical disk access sense.
There may be a way for particular platforms to allocate multiple contiguous chunks (e.g. ask for them all in one go), but it doesn't matter if ...
2
votes
Inheritance: Folders and Files & Liskov Substitution Principle
The "substitution" from LSP does not mean that the subclass ultimately behaves same as way the super class. It cannot do it always anyway, simply because it is another class.
What it does mean is ...
2
votes
Best practice for storing a static pdf file in a web app
I would include it in a resource folder and include it in source control - it's a document that explains how your application works, so it makes sense that its version history is maintained along with ...
2
votes
How does the MVC pattern actually work?
I’m completely lost on what actually belongs in each layer and the best way to organize the code as a whole.
You have come to a crucial realization: MVC is not a comprehensive software architecture.
...
1
vote
How might encapsulated source be broken into into multiple files?
Don't bother using #include to combine many C files into one file. They will behave fine as separate compilation units if they include the right headers.
(There are a few build systems which ...
1
vote
Move from mft to api REST style to get or post large data 200mb , is it best practice?
In your diagram it's somewhat unclear in which direction the data flows. Your arrows are bidirectional, does that mean each participant sends as well as receives files? It is also not clear which ...
1
vote
Is there a paradigm for working with data semantically instead of file-based?
The example given sounds like a textbook example on the basics of Abstraction in Computer Science. Wikipedia refers to it as Data Abstraction:
Data abstraction enforces a clear separation between ...
1
vote
Inheritance: Folders and Files & Liskov Substitution Principle
If you are creative enough you can make one descend from the other and satisfy Liskov. But you would have to bend semantics, like with square and rectangle. And that would not benefit your model or ...
1
vote
Accepted
How to append a chunk of fixed size data to a file and make sure this chunk doesn't get fragmented on disk?
I can't reliably talk about all filesystems and all platforms. But I have some experience in dealing with file allocation reflecting disk/volume/partition/region structure.
The most obvious way is ...
1
vote
Why would I use a queue to list all files and subfolders recursively
As this is an exercises question I won't answer directly, just provide a hint (as @CandiedOrange's hint is a bit cryptic).
There are two basic ways to traverse a tree: depth-first and breadth-first. ...
1
vote
Why are the sizes of programs so large?
A lot of the size comes from built in libraries. Many applications these days are built using electron which bundles a huge amount with the application. If you install applications on Linux they are ...
1
vote
Why do CSV file formats normally use quoting instead of escaping?
The CSV originates from the early seventies (Defined in IBM Fortran 77), it was introduced to give a better data transfer with less errors in punch cards as the previously used fixed length format was ...
1
vote
What is the optimal algorithm for estimating number of lines of text in a file?
An estimation is
lines in file = size of file / averaged line size
where size of file is easy to get, and you can read the first x of megabytes to do the average, a Python example
def line_estimation(...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
files × 64database × 6
file-handling × 6
file-systems × 6
c++ × 5
java × 4
python × 4
git × 4
data × 4
design × 3
algorithms × 3
web-applications × 3
version-control × 3
file-storage × 3
architecture × 2
programming-languages × 2
c × 2
performance × 2
naming × 2
coding-standards × 2
linux × 2
operating-systems × 2
assembly × 2
persistence × 2
binary × 2