jaytea commented on a Page, mIRC Remote (SwiftIRC Only)  -  May 26, 2011

less repetition? looks neater? looks better? better coding habits?

less repetition? you've replaced text events with if conditions and kept the contents of those groups of commands the same. you are 'repeating' if statements in the same way that the OP was 'repeating' text events. each of those events do different things, why must we try to take away from its simplicity by combining them?

the purpose of combining code is not to just eliminate any and all repeated code - this is a mechanical process that anyone can learn to do and does not require a great deal of thought - what is more important is deciding what to combine and why.

in this case, every text event contains 3 identical lines of code that can be abstracted and put into a single alias. but not just for the sake of it: those 3 lines together constitute a clear identifiable function, namely 'validate the user and memorize his nick'. it is a function that is the same regardless of where it appears in the code, and becomes easier to manage if its kept in one place:

on *:TEXT:~kill:*:{

  validateAndSave

  set -u3 %command scon -at1 quit
}
on *:TEXT:~part:*:{

  validateAndSave

  set -u3 %command part $iif($2 == $null,$chan,$$2)
}

...

alias -l validateAndSave {
  if (!$istok($names,$nick,32)) halt

  .msg NickServ status $nick
  set -u3 %killorder $nick
}

now, if the validation method ever changes, or the variable/identifier names should be changed, only one portion of code needs to be modified.

[quote]
I don't use regex

lol i was referring to that smart-ass =P
[/quote]

he doesn't want to use a bit of code he doesn't understand, i think that's perfectly reasonable. he may have a certain unwillingness to learn it, but that doesn't make him a smart ass. in his place, i wouldn't be sold either if all i'm shown is that regex has the ability to eliminate a few very basic if statements for me ;P in a day where regex is used for all the wrong reasons, can you really blame him for his POV?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.