What is the most efficient/elegant way to parse a flat table into a tree?

Assume you have a flat table that stores an ordered tree hierarchy: Id Name ParentId Order 1 'Node 1' 0 10 2 'Node 1.1' 1 10 3 'Node 2' ...

Git workflow and rebase vs merge questions

I've been using Git now for a couple of months on a project with one other developer. I have several years of experience with SVN, so I guess I bring a lot of baggage to the relationship. I have...

Why can't I define a static method in a Java interface?

EDIT: As of Java 8, static methods are now allowed in interfaces. Here's the example: public interface IXMLizable<T> { static T newInstanceFromXML(Element e); Element toXMLElement(); } Of...

Why is 'this' a pointer and not a reference?

I was reading the answers to this question C++ pros and cons and got this doubt while reading the comments. programmers frequently find it confusing that "this" is a pointer but not a reference....

HTML naming conventions for ID, class and to include element type prefix?

Does anyone know of a good resource to explain good naming conventions for HTML ID and classes and whether to prefix with IDs with an element type i.e. btn or button or similar? Should classes be...

Simple Getter/Setter comments

What convention do you use to comment getters and setters? This is something I've wondered for quite some time, for instance: /** * (1a) what do you put here? * @param salary (1b) what do you...

Why doesn't Python have a sign function?

I can't understand why Python doesn't have a sign function. It has an abs builtin (which I consider sign's sister), but no sign. In python 2.6 there is even a copysign function (in math), but no...

Referring to javascript instance methods with a pound/hash sign

This question is similar to https://stackoverflow.com/questions/736120/why-are-methods-in-ruby-documentation-preceded-by-a-pound-sign I understand why in Ruby instance methods are proceeded with a...

Do comments slow down an interpreted language?

I am asking this because I use Python, but it could apply to other interpreted languages as well (Ruby, PHP, JavaScript). Am I slowing down the interpreter whenever I leave a comment in my code?...

How to document class attributes in Python?

I'm writing a lightweight class whose attributes are intended to be publicly accessible, and only sometimes overridden in specific instantiations. There's no provision in the Python language for...

Python name mangling

In other languages, a general guideline that helps produce better code is always make everything as hidden as possible. If in doubt about whether a variable should be private or protected, it's...

Where does the TODO convention come from?

I suspect this question has been asked before, but it's not easy to Google for. I am a fairly new coder and I see a lot of code, in a lot of different languages, with comments beginning...

How to "comment-out" (add comment) in a batch/cmd?

I have a batch file that runs several python scripts that do table modifications. I want to have users comment out the 1-2 python scripts that they don't want to run, rather than removing them...

Entity Framework Ignore property by conventions

I have a code-first model where all entities are derived from a Entity base class. I have a property IsDeleted in base class which I want to ignore in all entities (I cannot remove/comment...

How/under which circumstances does the <see> tag in Delphi xml comments actually work?

I wonder how these XML references work, I'm just not getting why they work or why they don't work and I found nothing about that. Here's an example: type TOuterClass= class strict private ...

Calculate 4 points of a square based on 2 points of a line

I am trying to calculate 4 points of a square in three dimensional space that is perpendicular to a line formed by two given points. This square must be: Perpendicular to the line defined by two...

How does Django's default template form rendering ( {{ form }} ) work?

The most basic way to render a form in a template in Django is to add an instance of the form to the context: context['form'] = MyForm() And then, in your template, render the form by calling it...

Java Math.toRadians(angle) vs hard-calculated

This question is related to another stackoverflow discussion distance between long&lat points Here is the code from the top voted answer: /* * Calculate distance between two points in latitude...

Functionality of Python `in` vs. `__contains__`

I implemented the __contains__ method on a class for the first time the other day, and the behavior wasn't what I expected. I suspect there's some subtlety to the in operator that I don't...

Error when attempting to use the data binding provided context variable with BaseObservable

Per this comment and the Android Data Binding tutorial I should have a context variable available when data binding: A special variable named context is generated for use in binding expressions...

Loop/reflect through all properties in all EF Models to set Column Type

My client has a standard of storing SQL Server decimals with a decimal(13,4) specification. As a result, in a very large and still-growing schema, I have nearly a hundred statements like...

If there is possibility to add comments to C++ code in VS Code that are displayed in IntelliSense window?

I use Visual Studio Code for nearly half a year, and I actually wonder if in Visual Studio Code there is possibility of adding comments to C++ code that can be viewed while IntelliSense window for...

Version C and Fortran90 : optimization for filling subarrays before MPI_Gather

I have coded a little MPI program that computes with an iterative scheme on a 2D domain : I apply a filter for each cell values (5 points stencil). In my code, I split global domain into multiple...

Values from linked appsettings.json file in dotnet core cannot be read

In an aspnetcore 2.0 project I'm trying to setup a single, shared appsettings.json file throughout my web application and several of my xunit test projects. First off, everything works fine when I...

EF Core 2.1.0 set default string length and column type

Since Entity Framework uses nvarchar(max) as default for strings I would like to set something else as...

Why use /app/lib instead of /lib in Rails?

In the sidekiq documentation, there is this quote about preferring to use /app/lib instead of /lib in Rails projects related to autoloading errors: A lib/ directory will only cause pain. Move the...

associative arrays in openscad?

Does openscad have any language primitive for string-keyed associative arrays (a.k.a hash maps, a.k.a dictionaries)? Or is there any convention for how to emulate associative arrays? So far all I...

Sonarqube supports rules to enforce coding standards or not

Sonarqube produces issues with the code like bugs and security-related issues as vulnerabilities and code smell that could cause issues. Is there a way to add the coding standards to enforce...

Why cython embeded plugins has higher performance in cpython interpreter than rust-c interface versions?

I would like to ask some questions about the underlying principles of python interpreters, because I didn't get much useful information during my own search. I've been using rust to write python...

Calling convention and stack walking in .NET

I am in the process of studying the book Inside Windows Debuggingand cannot fully understand the technique used in the chapter Listing parameters and Locals for System Code. As the name suggests,...