Long variable names can be helpfully descriptive, but ...



  • I just found this.

      public class Xyz {
        private Queue durablePersistentRabbitMQSeriesQueueToTransferDataBetweenProgramXandProgramYForPurposeZ;
        private Queue durableNonPersistentRabbitMQSeriesQueueToTransferDataBetweenProgramXandProgramYForPurposeZ;
        private Queue durablePersistentActiveMQSeriesQueueToTransferDataBetweenProgramXandProgramYForPurposeZ;
        private Queue durableNonPersistentActiveMQSeriesQueueToTransferDataBetweenProgramXandProgramYForPurposeZ;
    
    public static void createDurableRabbitMQSeriesQueueWithPersistenceEnabledForTheXyzProjectToTransferDataBetweenProgramXandProgramY()  { ... }
    public static void createDurableActiveMQSeriesQueueWithPersistenceEnabledForTheXyzProjectToTransferDataBetweenProgramXandProgramY()  { ... }
    public static void createDurableRabbitMQSeriesQueueWithPersistenceDisabledForTheXyzProjectToTransferDataBetweenProgramXandProgramY() { ... }
    public static void createDurableActiveMQSeriesQueueWithPersistenceDisabledForTheXyzProjectToTransferDataBetweenProgramXandProgramY() { ... }
    

    }

    Yes, I know auto-complete will help, but come on.



  • CREATE DURABLE RABBIT;
    DROP DURABLE RABBIT;
    CREATE DURABLE RABBIT;
    GO;


  • How dare you use something that refers to XY chromosomes (males) and NOT use something that refers to an XX chromosomes (females), you sexist and insensitive clod!


  • Considered Harmful

    @snoofle said:

    Yes, I know auto-complete will help,

    Your choice of words here makes it sound like this kind of behavior is right some of the time. Bad code is wrong all of the time!



  • @joe.edwards said:

    @snoofle said:
    Yes, I know auto-complete will help,
    Your choice of words here makes it sound like this kind of behavior is right some of the time. Bad code is wrong all of the time!
    I don't have a hard rule about the length of variable / function names; sometimes more info is better, but I'm pretty sure these are way over that line.


  • ♿ (Parody)

    @snoofle said:

    @joe.edwards said:

    @snoofle said:
    Yes, I know auto-complete will help,

    Your choice of words here makes it sound like this kind of behavior is right some of the time. Bad code is wrong all of the time!
    I don't have a hard rule about the length of variable / function names; sometimes more info is better, but I'm pretty sure these are way over that line.

    Right or wrong, camel case sucks.

    durablePersistentRabbitMQSeriesQueueToTransferDataBetweenProgramXandProgramYForPurposeZ

    durable_persistent_rabbit_mq_series_queue_to_transfer_data_between_program_x_and_program_y_for_purpose_z



  • @snoofle said:

    durablePersistentRabbitMQSeriesQueueToTransferDataBetweenProgramXandProgramYForPurposeZ;

    A better data structure would help. You have persistent queues and non persisitent queues; and program x, program y, purpose



    How about something like Queue(Persistent,ProgramX,ProgramY,PurposeZ)


  • Discourse touched me in a no-no place

    I was going to accuse that code of being a contribution from a Smalltalk language-exchange student, but with identifiers that long it would be more like Largetalk.



  • @boomzilla said:

    Right or wrong, camel case sucks.

    durablePersistentRabbitMQSeriesQueueToTransferDataBetweenProgramXandProgramYForPurposeZ

    durable_persistent_rabbit_mq_series_queue_to_transfer_data_between_program_x_and_program_y_for_purpose_z

    Underscores are easier to read for overly-long names like that (which arguably is an argument against them), but camelcase is fine for short names. Personally I prefer camelcase just because it's easier to type than trying to hit the underscore.


  • Considered Harmful

    In Javascript you can use spaces in property names.

    window[ 'durable persistent rabbit mq series queue to transfer data between program x and program y for purpose z' ] = function() {
    
    }


  • @joe.edwards said:

    In Javascript you can use spaces in property names.

    window[ 'durable persistent rabbit mq series queue to transfer data between program x and program y for purpose z' ] = function() {
    
    }

    Shit, dude, you can use control characters in property names:

    window['\x07\x00\b'] = ...

  • Discourse touched me in a no-no place

    @morbiuswilters said:

    @joe.edwards said:
    In Javascript you can use spaces in property names.

    window[ 'durable persistent rabbit mq series queue to transfer data between program x and program y for purpose z' ] = function() {
    
    }

    Shit, dude, you can use control characters in property names:

    window['\x07\x00\b'] = ...

    Isn't this where Ben L chimes in about using unicode characters in Go?



  • @FrostCat said:

    @morbiuswilters said:
    @joe.edwards said:
    In Javascript you can use spaces in property names.

    window[ 'durable persistent rabbit mq series queue to transfer data between program x and program y for purpose z' ] = function() {
    
    }

    Shit, dude, you can use control characters in property names:

    window['\x07\x00\b'] = ...

    Isn't this where Ben L chimes in about using unicode characters in Go?

    No, I think this is where he tell us that his CHROMEBOOK supports control characters in file names.


  • Considered Harmful

    @morbiuswilters said:

    @FrostCat said:
    @morbiuswilters said:
    @joe.edwards said:
    In Javascript you can use spaces in property names.

    window[ 'durable persistent rabbit mq series queue to transfer data between program x and program y for purpose z' ] = function() {
    
    }

    Shit, dude, you can use control characters in property names:

    window['\x07\x00\b'] = ...

    Isn't this where Ben L chimes in about using unicode characters in Go?

    No, I think this is where he tell us that his CHROMEBOOK supports control characters in file names.


    Oh, is Ben L using a Chromebook?



  • @morbiuswilters said:

    @joe.edwards said:
    In Javascript you can use spaces in property names.

    window[ 'durable persistent rabbit mq series queue to transfer data between program x and program y for purpose z' ] = function() {
    
    }

    Shit, dude, you can use control characters in property names:

    window['\x07\x00\b'] = ...

    Holy fuck property names can contain 26 kinds of whitespace

    window['   ᠎           ​  ⁠ '] = ...


  • @joe.edwards said:

    @morbiuswilters said:
    @FrostCat said:
    @morbiuswilters said:
    @joe.edwards said:
    In Javascript you can use spaces in property names.

    window[ 'durable persistent rabbit mq series queue to transfer data between program x and program y for purpose z' ] = function() {
    
    }

    Shit, dude, you can use control characters in property names:

    window['\x07\x00\b'] = ...

    Isn't this where Ben L chimes in about using unicode characters in Go?

    No, I think this is where he tell us that his SURFACE RT supports control characters in file names.


    Oh, is Ben L using a Surface RT?

    What's not to like. It's a product that left a 900 million dollars hole in Microsoft's pockets... which is still less than what they pay to have Nokia use Windows Phone. (Yes that's what they did this year with my $100 yearly Office subscription and my $50 SkyDrive storage upgrade).



  • @Ben L. said:

    Holy fuck property names can contain 26 kinds of whitespace

    window['   ᠎           ​  ⁠ '] = ...

    That's fucking evil. You could write an entire Whitespace program in a variable name. Think of the possibilities.

    No, on second thought, don't. There are enough insane people in the world on this forum already.



  • @RobFreundlich said:

    That's fucking evil. You could write an entire Whitespace program in a variable name.
    A while ago I thought to myself@Zecc's brain said:
    Hey, minifiers usually work by removing whitespace. Wouldn't it be cool if there was an obfuscator/packer that actually turns code into mostly whitespace?
    It was just a random thought though, and I didn't even investigate whether someone had done that already or not.



  • Of course, significant whitespace in JS is only valid inside strings, so you'd be better off just implementing a plain old Whitespace interpreter. But you could use whitespace instead of any property name.


  • Discourse touched me in a no-no place

    @RobFreundlich said:

    That's fucking evil. You could write an entire Whitespace program in a variable name. Think of the possibilities.


    You could define a language where identifiers are the result of evaluating a Whitespace program, which should be normalized to the lexicographically smallest program that generates the particular identifier...

    Oh well, it beats sitting through Yet Another Genome Browser presentation.


  • Considered Harmful

    (function(){
    	function lpad( s, w, c ) {
    		while( s.length < w ) s = c + s;
    		return s;
    	}
    	var charwidth = 16;
    	var map = { '0': '\u200b', '1': '\ufeff' };
    	function decode( s ) {
    		var r = '';
    		for( var i = 0; i < s.length; i += charwidth ) {
    			var c = s.substring( i, i + charwidth );
    			for( var mc in map ) if( map.hasOwnProperty( mc ) ) {
    				c = c.replace( new RegExp( map[ mc ], 'g' ), mc );
    			}
    			r += String.fromCharCode( parseInt( c, 2 ) );
    		}
    		return r;
    	}
    	function encode( s ) {
    		var r = '';
    		for( var i = 0; i < s.length; ++i ) {
    			c = lpad( s.charCodeAt( i ).toString( 2 ), charwidth, '0' );
    			for( var mc in map ) if( map.hasOwnProperty( mc ) ) {
    				c = c.replace( new RegExp( mc, 'g' ), map[ mc ] );
    			}
    			r += c;
    		}
    		return r;
    	}
    	eval( decode( '​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​' ) );
    }());

    The code is encoded in zero-width whitespace. Go ahead, paste it into the Javascript console.

    Edit: The encode function is provided so others can play with it, you can rip it out and minify the rest when you deploy your hidden script. Or change eval to alert if you don't trust me.


  • Considered Harmful

    A little more compact, but still readable:

    (function(){
    	function decode( s ) {
    		s = s.replace( /\u200b/g, '0' ).replace( /\ufeff/g, '1' )
    		var r = '';
    		for( var i = 0; i < s.length; i += 16 ) r += String.fromCharCode( parseInt( s.substring( i, i + 16 ), 2 ) );
    		return r;
    	}
    	eval( decode( '​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​' ) );
    }());

Log in to reply