View Single Post
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 02-25-2018 , 06:22   Re: Snippet: Setting RGB/RGBA values via a command
Reply With Quote #6

Quote:
Originally Posted by Headline View Post
Every code post turns into a pissing contest
It is unfortunate that you interpreted this conversation in this way. I was merely joining you in demonstrating to our OP colleague that there are simpler ways to perform the stated task. Your code is more readable, mine is compacter and more easily editable (for example, if a "target" argument were to be prepended to the list of arguments.)


Quote:
Originally Posted by 404UNF View Post
I prefer to be a thorough programmer, and to think 10 steps ahead and get in the mindset of the end user who will use my plugin. And I think that's the reason we have if/else if/else statements in the first place, for checking values and ensuring bugs don't arise due to whatever circumstances should cause them, right?
This is absolutely correct. If you look at some of my earlier work, especially with Friendly Mode, I went absolutely insane with validating user input. However, this isn't always necessary. In the stated task, there are simpler ways to accomplish this. Validating input isn't that important here (in my opinion!) since the input boils down to a few numerical values. This is why I just implemented a simple 0 <= i <= 255 check. In this particular scenario, I don't think anything else is really necessary.

Quote:
And honestly, who does it hurt if I use Regex And I'm interested in regex, not obsessed with it. I'm in a computer programming course to learn programming, so maybe I should also learn other things related, such as regex.
Ah, but the question is whether or not that particular solution is suitable. There are several things to consider:
  • Is the code readable, so you can go back and update it later without trying to re-learn something, or remembering your motivations for given bits of the code?
  • Is the solution expensive? In the magical world of Sourcepawn, this generally isn't something we need to concern ourselves to much with, but it's always something to keep in mind!
  • Will the code I write be understandable to others who wish to edit my work? Will I end up causing irritating people to add me on Steam, or Discord, or spam me with PMs asking me to modify the plugin because they don't understand the code themselves?
  • Do I intend on posting the solution as an example of a good solution on how to perform the given task?

It's great that you're learning regex. The question is whether or not this particular plugin was the best medium in which to do that. Me, I'm still looking for an excuse to learn regex. And git. And SQL. Or literally any other language outside of Pawn. (Every time I try to just read about one of these subjects without a given project in mind, my eyes just gloss over and I lose any interest I ever had...)

Quote:
given the huge difference in our skill levels (yours being much higher than mine)
I disagree. My knowledge is very general with only a few specializations. You put a plugin in front of me that involves gamedata, or particle effects, or databases, or viewmodels, or regex, or anything cool... And I'll stand there with my thumb in my mouth. You're got at least regex on me, now, and probably lots more.

Quote:
text which was edited out
Oh, your code is fine. If it works, it works. Your method choice, however, is questionable, in the opinion of probably most people here, especially when posted to the public forum as an example of how to efficiently preform the task.

You're doing fine. Please don't interpret this criticism as non-constructive.
__________________
ddhoward is offline