New answers tagged

0

I would use a templating engine or a preprocessor which can include text (or html) blocks. There are about a dozen examples here: https://css-tricks.com/the-simplest-ways-to-handle-html-includes/


0

Symlinks are usually the only way to have the same file appear within two directories; well, except hardlinks, of course, but hardlinks are not portable and not useful across multiple storage volumes. I don't know of any other way how this should be possible and if there is no other way at all, then the question of the "best way" does not even arise. The ...


1

I think you may be asking the wrong question. Good practice or bad practice for a Dockerfile, because they have so many different applications, depends on what exactly you do with them. However, if your real question is: How should I deal with this potential for breakage? The answer is, only build your docker image once, as the very first step of your ...


0

Your build automation infrastructure would deal with included headers. Consider using GNU make (or ninja, etc...). If your C compiler is GCC (or Clang), notice the -M and related compiler flags. You might also want to use ccache and/or precompiled headers to speed up incremental build time. But read Recursive make considered harmful and consider other build ...


2

There are already a couple of interesting answers here. But some more justification is needed. In the first example, reading or verifying the program requires to: analyse the control flow to identify the logical blocs. follow the control flow in reverse direction to see where the global variables (or in the case of assembler, the registers, but that’s a ...


5

Actually, there are books about the advantages of object oriented programming, written in the 90's, that explain concepts like Locality and encapsulation. And you are not asking about object orientation, you are questioning structured programming. That's a step done around 1980-1985. It's a matter of (human) readability, error prevention, and ...


4

The first code is non-reentrant. What it meant is that you can't call it recursively, from a signal handler, or from multi threaded code without very careful analysis of how things gets called. It's much easier to compose pure, reentrant code into larger, more complicated codebase, where it's no longer possible to keep all of the code path in your head and ...


0

I like the Flater's answer and Martin Maat's comment. But I think the answer should have more specific rules. So I’ll try to explain how I understand it. Let's divide properties and methods into categories: Action (imperative verb) - it allows us to say object do something. SetValue(value), GetValue(), Initialize(), Dispose(), Play(). Statement (third-...


0

There is a school of thought that controllers and actions should be as lean as possible - pushing domain/business logic back into the models as much as possible. There's another school of thought that prefers to be a little more up front and show what's happening in the controller. Then there's the approach of keeping it simple and only passing ...


12

var val = obj.GetValue(); var val = obj.PlayOnAwake; // From Unity It's not first-person, it's imperative. Simply put, it's a command. GetValue() Get the value! PlaySound() Play this sound! DeleteFile() Delete that file! These namings are used for methods, especially methods that perform a task (as opposed to returning a known value). var has = obj....


Top 50 recent answers are included