New answers tagged

6

Of course, anyone can change the permissions and ownership to their liking after downloading the project (or maybe they are on other platforms) but is there a best-practice on what to set owner, user and group to initially? Just leave the ownership to default values. Once someone clones a repository on their machine, they'll become the owner. Same for ...


0

Macro is executed during compilation, and function is executed at run time. Example: #include <stdio.h> #define macro_sum(x,y) (x+y) int func_sum(x,y) { return x+y; } int main(void) { printf("%d\n", macro_sum(2,3)); printf("%d\n", func_sum(2,3)); return 0; } So during compilation the code is actually changed to: #include <...


1

In slightly more abstract terms, a macro is to syntax as a function is to data. A function (in the abstract) encapsulates some transformation on data. It takes its arguments as evaluated data, performs some operations on them, and returns a result which is also just data. A macro in contrast takes some unevaluated syntax and operates on that. For C-like ...


0

A macro generally refers to something that is expanded in place, replacing the macro "call" during compilation or pre-processing with individual instructions in the target language. At runtime, there will generally be no indication of where the macro begins and ends. This is distinct from a subroutine, which is a reusable piece of code which is located ...


2

In the C language family a macro definition, a preprocessor command, specifies a parametrized template of code that is substituted at the macro call without being compiled at the definition. This means that all free variables should be bound in the context of the macro call. Parameter arguments with a side effect like i++ could be repeated, by plural usage ...


59

Unfortunately, there are multiple different uses of the term "macro" in programming. In the Lisp family of languages, and languages inspired by them, as well as many modern functional or functional-inspired languages like Scala and Haskell, as well as some imperative languages like Boo, a macro is a piece of code that runs at compile time (or at least ...


7

Note I would like to add the following clarification after observing the polarising voting pattern on this answer. The answer was not written keeping technical accuracy and broad generalization in mind. It was a humble attempt to explain in simple language, difference between macros and functions to a programming newbie, without trying to be complete or ...


1

Simple. Keep a notebook which records all work done that day and lessons learnt. Make a record every time you stop work. I use // to indicate breaks in work but do whatever suits you. This is also a valuable tool for project management queries when they're asking why you didn't finish X, Y & Z on a given day. For a more senior (i.e. older) developer ...


0

Do you follow AGILE ? If you do then you can have sprints, with Kunban charts... So it could point you out to the feature \ bug you were working on... How it going to help OP ? When user stories are broken down to tasks, ideally tasks should be less then a day, so when you come after 2,4,8 weeks holidays, you will work on next task assigned to you :) ...


2

Personally, I leave an intentional compile error. I write a short comment to myself in the code. Then I uncomment it. When I get back, by force of habit I start up my IDE, build, and...hey, something's broken! I go there, and there's my note, telling me what I was working on.


0

I sometimes use a counter-intuitive approach, especially over a weekend. Start on something and leave it slightly unfinished, may not compile, fail a unit test etc. When I come back, this jogs my memory sufficiently to continue working. P.S. This approach may not work for everyone. :)


7

The most obvious recommendation is to always stop at a point where all of the work is "done". So when you return, you start on something new instead of trying to remember where you left of. Instead of looking at it as a vacation time, look at it as if you worked in some different part of the application. So after few weeks, you return to module you worked ...


7

Copious notes. Write down your thoughts, your progress, in as much detail as needed to clear your mind. It's no different from when you do a problem analysis tracking down a bug and someone else is going to execute the fix (or yourself at some indeterminate point in the future). Write down EVERYTHING of consequence. When I do it I won't usually write in the ...


4

How do you know where you stopped in your codes after a 2-week break? The same way I know where I stopped after I take a bathroom break. Notes. You take notes, you make to do lists, you don't walk away from the 2 hours of work that it took to get an idea spun up in your brain without writing it down. Add method names, file names, ideas worth exploring, ...


-1

My take on this is that you may have seen some code somewhere that does sloppy or brittle things with file names, but that does not mean that "storing metadata in filenames" is bad in a general sense. I say this because file names are metadata- they are data about the data in the file, independent of the file data itself. In fact, filenames are so old that ...


2

So why create a nested class? I can think of couple of important reasons: 1. Enable encapsulation Many times nested classes are implementation details of the class. Users of the main class should not have to care about their existence. You should be able to change them at will without requiring the users of the main class to change their code. 2. Avoid ...


0

Nested Class can be used whenever you want to create more than once instance of the class or whenever you want to make that type more available. Nested Class increases the encapsulations as well as it will lead to more readable and maintainable code.


0

I use public nested classes for related helper classes. public class MyRecord { // stuff public class Comparer : IComparer<MyRecord> { } public class EqualsComparer : IEqualsComparer<MyRecord> { } } MyRecord[] array; Arrays.sort(array, new MyRecord.Comparer()); Use them for related variations. // Class that may or may not ...


8

The programming paradigm that organizes the software into functions is called procedural programming. For example, C is a procedural programming language. Most dynamic languages like JS or Python can be used in a procedural style. While you are also organizing your code into separate files, there is no commonly used name that describes this. For example, ...


1

From the example what you seem to want to do is get all the users who have commented on any post in a particular thread. Generally if you find yourself doing complex queries to try and get a specific set of data that is a sign that what you actually need is just a new resource Something like GET /threads/{threadUuid}/all_users_that_commented and let the ...


-1

If I understood your question well, you don't want to pick from a pregenerated list of possible combinations because it will mess up the probabilities per level. One way to deal with that is to make a random pick level-by-level, after you've filtered out disallowed items based on previous picks. Since you've said you're doing this in Python, here's some code ...


0

It is a common pattern to combine multiple service behind a facade, especially if the link between your client and server would be a bottle neck (especially if it could be a mobile device). It might be worth checking out GraphQL before you completely re-invent the wheel yourself: https://graphql.org/


0

You can impose validation in every layer of your application. Where to impose which rules depend on your application. For example, entities implement methods that represent business rules while use-cases implement rules specific to your application. If your building an e-mailservice like Gmail one could argue that the rule "users should have a unique e-...


Top 50 recent answers are included