Overengineered a little?



  • So there is a bulletin board in the hall where I work where people post
    recent accomplishments... you know, to boost morale and such. Last
    week's accomplishment was... my hands tremble to type this... it's
    almost too much to bear.... are you ready?

    A utility to add line numbers to source code listings.


    Wow.

    Nevermind that there is already a GNU tool nl on every Unix box made
    since 1970 that will do that for you. Or heaven forbid we should write
    the one line of Perl to do it.



    Now, can you guess what language was used to create this
    masterpiece, nay, this paragon of programming?



    Yes, the answer is Java, along with a 4 KB JAR file.



  •  People use an IDE without built-in line numbering?  I bet this guy writes his code in Notepad.



  • If there's one thing we've all learned on this forum, it's that both good and bad code can be created in every language.

    Blame the carpenter, not the hammer.



  • @aevernon said:

    Nevermind that there is already a GNU tool nl on every Unix box made
    since 1970 that will do that for you. Or heaven forbid we should write
    the one line of Perl to do it.
    nl? perl? Don't be daft. The proper way is to read the file, insert each line in a database table with an auto increment id and then just list these two table columns. Just don't forget to recreate the table each time so the id starts at 1.

     



  •  having a quick look at the man page for nl, i see it takes the following option

           n      number no lines

      im sure there is a perfectly sensible and useful reason for this.

     

    edit: indeed there is, entirely unamusing as well.



  • @DOA said:

    nl? perl? Don't be daft. The proper way is to read the file, insert each line in a database table with an auto increment id and then just list these two table columns. Just don't forget to recreate the table each time so the id starts at 1.

     


    I'm sorry, that method doesn't seem enterprisey enough to scale enough for the corporate global line number rollout. Is there anyway you can make it use XML and a web service? Oh and don't forget to provide localization. After all we don't want to upset our fellow workers in the outsourced division!


    Management



  • @DOA said:

    Just don't forget to recreate the table each time so the id starts at 1.
     

    Clearly you haven't thought this through.  All sorts of things can go wrong this way.  The correct approach is to use TRUNCATE TABLE.



  • @OzPeter said:

    I'm sorry, that method doesn't seem enterprisey enough to scale enough for the corporate global line number rollout. Is there anyway you can make it use XML and a web service? Oh and don't forget to provide localization. After all we don't want to upset our fellow workers in the outsourced division!


    Management

     

    Good job quoting clichés.  I almost considered thinking about chuckling for 1 microsecond.



  • @bighusker said:

     People use an IDE without built-in line numbering?  I bet this guy writes his code in Notepad.

     

    Notepad? Notepad! NOTEPAD??!!?!?!!

    Everyone knows real programmers use vi.

    Apart, of course, from those legendary ancient ones, whose names are only uttered in respectful whispers, whose legendary achievements include writing enterprise applications by toggling the switches on the front panel.

     



  • @havokk said:

    Notepad? Notepad! NOTEPAD??!!?!?!!

    Everyone knows real programmers use vi.

    Notepad got too modern after XP, line numbers, go-to-line... I can feel Intelisense is coming...



  • Even Perl is over-engineering it.

     

    If you don't want to use nl, then there's always awk. It's a very under-valued utility, especially by those who have been seduced by the Dark Side of the Force Perl.


  • Discourse touched me in a no-no place

    @glassx said:

    Notepad got too modern after XP, line numbers, go-to-line... I can feel Intelisense is coming...
    Did I miss something? I totally just ran notepad on my Vista64 box, and it still doesn't have those features.



  • @Weng said:

    @glassx said:

    Notepad got too modern after XP, line numbers, go-to-line... I can feel Intelisense is coming...
    Did I miss something? I totally just ran notepad on my Vista64 box, and it still doesn't have those features.

    You have to switch it into scientific mode for that.

    But if seriously, line numbers are shown in the status bar and Goto is in the Edit menu (the shortcut is Ctrl-G). This is for XP32, but I doubt they changed it.



  • @DavidInCambridgeUK said:

    there's always awk.

    Pfft! Why use awk when sed is perfectly adequate?



  • @CDarklock said:

    Why use awk when sed is perfectly adequate?

    on windows you can use [code]findstr /n /r .[/code]

    You should be able to omit the /r but that makes it more readable. findstr being what it is, this also works with grep. Q: is there a command line utility with more than 16 options that can't be used for numbering lines?



  • @strcmp said:

    @CDarklock said:
    Why use awk when sed is perfectly adequate?

    on windows you can use <font face="Lucida Console" size="2">findstr /n /r .</font>

     

    You should be able to omit the /r but that makes it more readable. findstr being what it is, this also works with grep. Q: is there a command line utility with more than 16 options that can't be used for numbering lines?

    Depends on how you define "utility" and whether there are any additional restrictions, such as that it has to be a text-processing utility.  For example, oggenc has about 30 options and I'm pretty sure it won't number lines.

    Or perhaps we were looking for options that can't be used to number lines, and a utility that has more than 16 of them?


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.