22 votes

Small functions vs. keeping dependent functionality in same function

The problem you're dealing with is called temporal coupling You're right to be concerned about how understandable this code is: private func setupNodes() { createNodes(); connectNodes(); } ...
candied_orange's user avatar
12 votes

How do you explain the importance of writing classes over writing procedural functions to a programmer?

Python is a multi-paradigm language in which procedural code is quite common, and the decision to write a class or a function is taken on a case by case basis. Python recognizes that a class is not ...
Karl Bielefeldt's user avatar
10 votes

Small functions vs. keeping dependent functionality in same function

Separate functions, for two reasons: 1. Private functions are private for exactly this situation. Your init function is public, and it's interface, behavior, and return value is what you need to worry ...
Jen's user avatar
  • 693
10 votes
Accepted

What's the best way to handle a large multi-file class in Javascript?

In situations like this, when I have one part of my program that needs to stand alone as a single, self-contained module but contains many thousands of lines of code, I prefer to take a compositional ...
Ken Halbert's user avatar
9 votes
Accepted

Are checksums in file formats obsolete?

The other thing you haven't considered is that files typically don't just exist on disk: They are copied across networks in various ways and under various circumstances. They are copied from one ...
Stephen C's user avatar
  • 25.2k
8 votes
Accepted

When designing a directory structure should filenames include folder names?

Although you ask "from a developers perspective" I think there are considerations outside that narrow constraint: If the files are only going to be maintained by future developers, then your first ...
kiwiron's user avatar
  • 2,338
8 votes

Is there a proper way to create a file format?

From someone who has had to parse a lot of file formats, I have opinions on this from a different point of view to most. Make the magic number very unique so that people's file format detectors for ...
Hakanai's user avatar
  • 237
7 votes

Is there a better alternative to the folder-based file system, and will it be replaced any time soon?

Some experimental operating systems don't even have any files. They have some orthogonal persistence machinery. Look at some academic OS projects (Coyotos, Grasshopper, IsaacOS, etc...). And old Lisp ...
Basile Starynkevitch'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
6 votes
Accepted

Is it appropriate to use Semantic Versioning for the specification for a key/value file format?

Semantic versioning's main advantage is to other developers who rely on your interface. It would be a great way to signal to other developers whether or not the changes to the file format might break ...
david25272's user avatar
5 votes

Would you use Byte Arrays or XML if size was not an issue?

It is certainly possible that the JPEG and PNG people might have used XML-based headers if file size were not an issue. Using text would make it more obvious what all the fields mean and so forth. ...
Nicol Bolas's user avatar
  • 11.9k
5 votes
Accepted

Where do you put the "main function" of a Python app?

If the whole application fits into a single file, that is the most simple solution. Otherwise, it is best to create a complete package. When you create a setuptools-based setup.py file, you can ...
amon's user avatar
  • 134k
5 votes
Accepted

Best way to structure NoDB (flat-file) website with multiple categories and subcategories for performance and maintainability

Don't use folders as tags. Don't cram it into a tree structure if it isn't a tree. A dress shouldn't need to live in two folders because it can be worn at different kinds of parties. Each dress ...
candied_orange's user avatar
5 votes

Is there a better alternative to the folder-based file system, and will it be replaced any time soon?

I think the folder based, tree-like file system is common but it's not the best. Indeed i believe a good classification of a file is better than to place a file in a certain 'place' e. g. folder. ...
brighty's user avatar
  • 151
4 votes

Considerations when designing a file type

Your first and most important decision is whether to use a binary format or a text based one. Binary is the way to go when you have to dump big amounts on non-string data. But it has significant ...
cmaster - reinstate monica's user avatar
4 votes

Small functions vs. keeping dependent functionality in same function

You may also find (depending on how complex each of these tasks are) that this is a good seam for splitting out another class. (Not sure if Swift works this way but pseudo-code:) class YourClass { ...
willoller's user avatar
  • 141
3 votes
Accepted

Structure of complex file formats

Suppose I want design and implement a a large and complex file format, like pdf or docx If you are alone, I would try hard to avoid such a large specification effort. In particular, consider instead: ...
Basile Starynkevitch's user avatar
3 votes

Would you use Byte Arrays or XML if size was not an issue?

Byte arrays are human readable. I've been reading them since I was 10 and I've been human for longer than that. This was before I even had a fancy hex editor. Peek and Poke commands are old friends....
candied_orange's user avatar
3 votes

How do database storage engines handle new columns?

It Depends... If you are really interested in all of the possible ways find yourself a book on database engines, something like An Introduction to Database Systems The Dumb Way Treat every record ...
Kain0_0's user avatar
  • 16.2k
3 votes
Accepted

Why does the Django Rest Framework encourage separating Model, Serializer and Views for the same object across multiple files?

This was a common convention at the time django was developed, followed by other frameworks of the time like Rails where you had a models directory with all your models, a controller directory with ...
Cormac Mulhall's user avatar
3 votes
Accepted

Selecting the endianness of data in files generated by an embedded system

If your goal isn't interoperability with independently written software, endianness conversion is probably overkill. You're already doing it for network data, which would not strictly be necessary - ...
Hans-Martin Mosner's user avatar
2 votes
Accepted

Strategy for Binary File Format Description to C++ Implementation

I am wondering if there are good examples or ideas on simplyfing the process of converting documentation of the file format into code with goal being to load data into a class that can be loaded/saved/...
utnapistim's user avatar
  • 5,305
2 votes

Is there a proper way to create a file format?

I was simply going to Serialize my objects into binary and create a header that would tell me how to parse the file. Is this a bad approach? From someone who's been on the receiving end of someone ...
Phill  W.'s user avatar
  • 12.2k
2 votes

Would you use Byte Arrays or XML if size was not an issue?

You example XML isn't even a good example, as you're still using a byte array. A 'true' XML for an image, to contrast with byte arrays, would be something like: <s:Image xmlns="www.w3c.org" width="...
whatsisname's user avatar
  • 27.7k
2 votes

Would you use Byte Arrays or XML if size was not an issue?

Two things: The benefits of your scheme are small and questionable: yes I can parse and extract metadata a bit more easily. But you only really need one C library to parse an image format and then it'...
walpen's user avatar
  • 3,231
2 votes

Small functions vs. keeping dependent functionality in same function

In addition to this being the exact purpose of private methods, Swift gives you the ability to use inner functions. Inner methods are perfect for functions that have only a single call site, but feel ...
Alexander's user avatar
  • 4,894
1 vote

Fast storage format for huge point clouds (fast read/write)

I'm not an expert in the field, nor do I know your exact constraints/data, but I may have an idea. Or at least something that would be worth trying if the points are spread more or less uniformely. ...
dagnelies's user avatar
  • 5,465
1 vote

How do you explain the importance of writing classes over writing procedural functions to a programmer?

Classes are not a code organization methodology. Classes encapsulate state and have methods to modify that state. If that is not your use case, procedural functions are perfectly adequate. The cure ...
Tony BenBrahim's user avatar
1 vote

Are checksums in file formats obsolete?

Reworked answer following discussion in comments Checksums in file formats The checksum in a file format has a different purpose than checksums in the file system. It aims at verifying the ...
Christophe's user avatar
  • 77.3k

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