Asked  6 Months ago    Answers:  4   Viewed   24 times

I know what Hungarian refers to - giving information about a variable, parameter, or type as a prefix to its name. Everyone seems to be rabidly against it, even though in some cases it seems to be a good idea. If I feel that useful information is being imparted, why shouldn't I put it right there where it's available?

See also: Do people use the Hungarian naming conventions in the real world?



Most people use Hungarian notation in a wrong way and are getting wrong results.

Read this excellent article by Joel Spolsky: Making Wrong Code Look Wrong.

In short, Hungarian Notation where you prefix your variable names with their type (string) (Systems Hungarian) is bad because it's useless.

Hungarian Notation as it was intended by its author where you prefix the variable name with its kind (using Joel's example: safe string or unsafe string), so called Apps Hungarian has its uses and is still valuable.

Tuesday, June 1, 2021
answered 6 Months ago

I like the underbar prefix for member fields. Mostly I like it because that way, all of my member fields are shown alphabetically before my methods in the wizard bar at the top of the screen.


Wednesday, July 28, 2021
answered 4 Months ago

This is a scheduling/optimisation problem, so the key question is "what quantity are you trying to maximise"? I'd guess you are looking to maximise the total number of hours worked across all your volunteers without clashes, subject to each volunteer's timetabling constraints. You also mention prioritising volunteers with more experience, so it sounds like you are saying "some volunteers are preferred over others".

This is then a classic bipartite matching problem. See e.g. p.498 of The Algorithm Design Manual (2nd ed.), by Steven Skiena. The basic approach is to construct a graph with vertices representing both the set of volunteers, and the set of time slots you are trying to fill. Edges link volunteers to valid time slots. The optimum solution is then the largest possible set of edges where no volunteer or time slot is repeated. This is a matching.

Some of your volunteers may be able to do more than one slot; this can be modeled by replicating that volunteer vertex multiple times.

If you want to implement the prioritising of volunteers, then this effectively adds a weighting to each edge, modeling the experience of that volunteer for that task. In this case, as you thought, you will need something like the Hungarian algorithm. If you can get away without this, then you can transform the problem into an equivalent flow graph, and apply a network flow algorithm. Here is one example of code that implements both weighted and unweighted matching.

If you want more details, including other alternatives, and more links to implementations, I do strongly recommend getting yourself a copy of the Algorithm Design Manual - it is an amazingly clear and practical reference.

Wednesday, August 11, 2021
answered 4 Months ago

I always use one and two letter prefixes in VBA. I'm sure I'm the only one that's going to admit that, but I figured somebody needed to be the contrarian.

Of the 18 million lines of VBA code I've written, I've collaborated on about 1,000. If nobody else sees my code, then I'm free to use a convention that I like. If someone else will be working on your code, you should agree on a convention.

I like that it lets me keep my variable names shorter. I could use FileNumber and FileName or I could use lFile and sFile. I don't find one more or less readable than the other. It also helps me use reserved words as variables. If I want to use Replace as a variable name, I can't. But I can use sReplace or lReplace.

Thursday, September 30, 2021
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :