Slashdot Mirror


User: vaz01

vaz01's activity in the archive.

Stories
0
Comments
41
First seen
Last seen
Profile
(view on slashdot.org)

Comments · 41

  1. Re:Editing the minimum # of lines possible on Best and Worst Coding Standards? · · Score: 1

    If a firm is that afraid of changing anything about their code for fear of the whole thing collapsing, then they must not know anything about testing code, which means they pretty much don't have any business making it in the first place.

  2. Re:braces on Best and Worst Coding Standards? · · Score: 1

    Some compilers get a bit weird about what order they want to execute things in a comma-separated statement.  I think you're generally not supposed to assume things will happen in the order you wrote them, which kinda defeats the purpose of C being imperative programming.

    (I might be wrong, but I think I remember reading that.)

  3. Everyone has their quirks on Best and Worst Coding Standards? · · Score: 1

    Some things I tend to do that that I'm not quite convinced are good ideas, but I do them anyway:

    // When things take multiple lines I try to line them up...  space before '{' here
    class SpaceDog extends RegularDog
                   implements AdaptedForSpace {
      // variable declarations lined up
      private String             name;
      private CanineSpaceMission mission;

      // a method like this... no space before brace when after a paren
      boolean bark(){
        // control structures written the same as function calls (no space after if);
        // one-lining simple conditionals
        if(inThePresenceOfAtmosphere) return true;

        if(Space.noOneCanHearYouBark()){
          // and a try block like this...
          try {
            frivolouslyAlterPhysicalLaws();
          }
          catch(NewtonianOutrageException e){
            beSadButDoItQuietly();
            return false;
          }
          // empty blocks without line break
          catch(PtolemianOutrageException ignored){}
        }
        produceIllogicalArf();
        return true;
      }

      // annoyingly verbose java getters and setters on one line if they're trivial
      public SpaceMission getMission(){ return mission; }

      public void destroyEnemy(EarthCat earthCat){
        // I do this sometimes, it lines up and the inside of the if block still indents once from the condition,
        // instead of indenting the second line further ahead and having the block un-indent
        if(EarthCat.inherentlyEvil()
        && earthCat.threatensCanineMission())
          destroy(earthCat);
      }
    }

    I'm not so sure about a lot of these habits... what do you think?  Do you have any style habits you're not so sure of?

  4. Re:braces on Best and Worst Coding Standards? · · Score: 1

    Agreed. I don't think it ever looks good to have an opening and closing brace on the same line (especially since you don't need the braces at all, unless you have multiple statements in there, which would make it even worse to read). Especially since the first thing I thought when I looked at that was, did he close the else block on the same line as its last statement? Then I saw the closing brace below and starting looking for a nested (multi-line) block, and then noticed the unnecessarily {}'s on the one line.

    I think

    if(something) do_something();

    is just as good as (or better than)

    if(something)
      do_something();

    for simple one-line conditionals, especially for things like

    if(x > 0) return x;
     
    // or to get a bit Java-ish
    if(bad_thing) throw new BadThingException();

    but these are simple conditionals that are really clear in one line. If you're going to tack on any elses, be consistent in how you indent all the blocks, so

    if(something)
      a_simple_statement();
    else {
      other();
      stuff();
    }

    I think this is a bit more than just personal preference, if you have a list of alternatives they should all be indented equally so they get equal attention.

  5. Re:braces on Best and Worst Coding Standards? · · Score: 1
    Those crazy long lines do seem to happen a lot in C, and C++ and Java too (new instance passed to new instance passed to new instance, maybe). Maybe it's just habit? It's not ever necessary, I don't think.

    I like taking any chunks of logic that are secondary to a function's algorithm and giving them their own function, even if I'm not currently using it more than once. Unless you're developing for a platform with limited memory or a profiler tells you a function it taking too long, there's no reason this could be a bad thing. It can really help make code more self-documenting if you use more and smaller functions with clear names... you can afford the space to write out a longer, clear name if you're moving secondary logic to functions of their own.

    Also, I'm a fan of splitting up long expressions (like in conditionals) over lots of lines and lining them in a nice way, it's clear and easy on the eyes. Same with a group of assignment statements at the start of a block, declaring a class's instance variables, etc.

  6. Re:That's no moon... on Russia To Study Martian Moons Once Again · · Score: 1

    I find it really odd that I haven't seen any mention of "In Soviet Russia, martian moon probes you"... or something to that effect.

    If Russia had a dollar for every time that's been posted on /., it'd have itself a free Phobos-Grunt.

  7. Re:There is no answer, it depends on what you want on Should the Linux Desktop Be "Pure?" · · Score: 1

    hax hax hax hax maphack n00b hax

    (what goes through my mind when I think about open source console games online)

  8. Re:Free vs Open on Should the Linux Desktop Be "Pure?" · · Score: 1

    Because.... because it's just too impractical to require an open source mouse! People need to be able to get things done! ...except don't apply that logic when it comes to software, because then it's wrong. For some reason. ;)

  9. Re:Why not both? on Should the Linux Desktop Be "Pure?" · · Score: 1

    You must be new here.

  10. Re:Please on W3C's Role In the Growth of a Proprietary Web · · Score: 1

    I lol'd.

  11. Re:Blu Ray on Pioneer Promises 400GB Optical Discs · · Score: 1

    Flash drives offer an even neater version of that, whenever they get big enough and cheap enough... no moving parts is a plus.

  12. Re:Guitar Tab doesn't qualify as fair use because on Your Mashup Is Probably Legal · · Score: 1

    I see where you're coming from, copyright protects you in particular then by assuring people know that your songs are yours.... Unfortunately, I'm pretty sure that, say, Nirvana or RHCP or whoever people are looking for tabs on don't have the same problem. Once your songs are well-known no one's going to go into a coffee shop and pretend they wrote it. And the tabs on these sites are for well-known songs... It really is just a matter of "does anyone care?" I guess.

  13. Re:Guitar Tab doesn't qualify as fair use because on Your Mashup Is Probably Legal · · Score: 2, Insightful

    You can't just copy it word-for-word. In other words, while the facts aren't copyrighted, their organization and expression in a fixed medium (the shop manual) is.

    So shouldn't the fact that most of these (usually user-submitted) tabs on most tabs sites are either greatly simplified or completely wrong be their saving grace? I'd call it paraphrasing the work at best.

  14. Re:Impiuos Imp? on Intel Says to Prepare For "Thousands of Cores" · · Score: 1

    Invisble?! Bow down... wait, what does that have to do with grammar?

  15. Re:Awesomebar? on A Few Firefox 3 Followups · · Score: 1

    I wasn't so sure about the awesomebar when I read about it, but in practice I actually like it a lot. What I did was turn off my history completely. If I want it to remember a page to "search intelligently" later on, I can star it so it goes in unsorted bookmarks, and tag it if I want. Being able to type "/." and have slashdot come up as a match is pretty nice. I'd rather have it search intelligently through things I ask it to remember than search dumbly through everything I've visited since I last cleared my history. :)

  16. Re:Ethic-less? on Facebook Widget Installs Zango Spyware · · Score: 5, Funny

    You must use facebook a lot.