Jump to content

  • Log In with Google      Sign In   
  • Create Account

ChaosEngine

Member Since 09 Jun 2000
Offline Last Active Today, 02:45 PM

Posts I've Made

In Topic: Do you usually prefix your classes with the letter 'C' or something e...

Today, 02:46 PM

 

The idea has mostly fallen out of favour these days, but that's where it came from.

I'd say that the idea is pretty much just common sense and gets used everywhere. Except instead of as abbreviated prefixes, people use all sorts of forms of it, e.g.
scrnCoordSomething
somethingScreenCoordinate
something_sc

etc

 


Sorry yes, I meant the abbreviated prefixes rather than the concept as a whole.

I think ideally, as SeanMiddleditch pointed out, we have strong typedefs so you couldn't do

typedef int Row;
typedef int Column;

Row x;
Column y;

x = y; // error, requires cast of some sort

In Topic: Introducing Stanza: A New Optionally-Typed General Purpose Programming Langua...

Yesterday, 04:25 AM

I actually don't have a problem with a language enforcing a coding style.

It neatly avoids all the stupid disagreements over style.

In Topic: Do you usually prefix your classes with the letter 'C' or something e...

26 May 2016 - 05:14 PM

 

 

Note that the original "hungarian notation" is actually recommending that you write variable names like m_xPosition vs m_yPosition

Am I going blind, what's the difference there?

 

That's probably not a great example from Hodgman.

 

Imagine you have two coordinate systems, screen coordinates and world coordinates.

 

It wouldn't make sense to do something like 

someScreenCoordinate = someWorldCoordinate

even if they are the same type.

 

So the original hungarian notation proposed prefixing them with a "subsystem", so you would end up with

scrnCoord = wrldCoord

The idea was to make this look wrong. So when you were reading the code, you would see this and go "damn, that should be"

scrnCoord = WorldToScreen(wrldCoord)

The same idea would apply in a business app for example, if you had a fee that could be expressed as an absolute value or a percentage. Code like 

amount *= valFee 

// should be 

amount *= rteFee

The idea has mostly fallen out of favour these days, but that's where it came from.


In Topic: Do you usually prefix your classes with the letter 'C' or something e...

26 May 2016 - 05:02 PM

 

1) Prefix class names with 'C'
2) Type 'C' in an IDE with code completion
3) Regret 1 as your code completion list fills up with a billion unrelated class names
4) ...
5) End up being found 2 weeks later, living in a cave as far from the coast as possible ranting about the ocean coming to get you...

 

The same applies to "m_", "g_", "lpsz" and similar wretched nonsense.

 

Not really.

 

If you're using "m_" for members, then it should only bring up member variables that are in scope (i.e. in whatever class you're editing). It's really no different than using "this->", but less error prone and an easy way to distinguish members from parameters. 

 

If you have fifty squillion members in a class, you're doing it wrong.

 

Same goes for "g_". I'm with Promit in that globals should be ugly and stick out like a sore thumb.

 

But agreed using lpsz or whatever is beyond pointless.  


In Topic: USC Canceled Video Game Panel For Too Many Men

25 May 2016 - 05:20 PM

What "biology" do you think causes women not to be interested in programming?


Breasts. They keep hitting the keyboard. :P


PARTNERS