[PHP] Converting Armagetron Colors to HTML Colors
- Lucifer
- Project Developer
- Posts: 8640
- Joined: Sun Aug 15, 2004 3:32 pm
- Location: Republic of Texas
- Contact:
Re: [PHP] Converting Armagetron Colors to HTML Colors
High school programming teachers are notorious for teaching bad habits, and VB is notorious for encouraging bad habits.
If you really want to get rid of as many bad habits as possible, spend a year working with only Python. Do that and you'll find yourself getting increasingly angry at all the bad php/vb/c++/java/whatever code you encounter.
Not that working with Python makes you an immediate good programmer, just that it does a great job nitpicking common bad habits in other languages.
If you really want to get rid of as many bad habits as possible, spend a year working with only Python. Do that and you'll find yourself getting increasingly angry at all the bad php/vb/c++/java/whatever code you encounter.
Not that working with Python makes you an immediate good programmer, just that it does a great job nitpicking common bad habits in other languages.
Re: [PHP] Converting Armagetron Colors to HTML Colors
Ah I remember the days when I took VB, C++ and Java in school...yep...I downloaded tron and didn't pay a single moments worth of attention to the class.
bye
Re: [PHP] Converting Armagetron Colors to HTML Colors
Ya I did the same Magi (although not java and c++). At my high school, they removed c++ and java as they stated in the report "Too complicated for the student's knowledge at an early age".
So now they are offered at university but not at my nearest university as the financial stability of the market has caused so many people to lose their jobs (especially computing engineers). Good thing my mother's company needs her capabilities (she did code a program that is being used by 22 (can't clearly remember) different countries and that she told me on my birthday and she normally doesn't brag about those things ).
Besides, my mother told me that programming should be my last option if I really want to settle down in life and I agree. I find it more entertaining to play around with numbers (maths). After all, the most enjoyable thing in maths is the amount of complex and difficult questions and I love it!
Besides, apart from me and dad, mum doesn't even touch the computer apart from bringing work to home and spending long hours on them and sometimes forgets to sleep until I smash the door down and tell her to sleep (not literally but you get the point).
And from all of these messages, I'm getting the feeling that you guys are above the age line of 22 or 23 or even above. Man I feel young and that isn't the first. I mean, I went to my old school for work experience in teaching and all of the Maths C students called me "Sir" the moment I entered the room. Seriously speaking, that was the room I spent in for the two years of my senior high school (Grade 11 and 12) studying Maths C and my favourite teacher was there too (back then we called it the "Cold Room" because it was freezing in the mornings whenever you entered it).
Your right Lucifer. VB does tend to make some ways for the lazy side of things but idk how Phyton will help me change but I'll give it a try when I finally get some free time. Right now I need to work on three assignments and then a supplementary exam (forced) due this Friday and then another one next Monday. Seriously, I wish they would stop giving me more than what my hands can hold
Interestingly enough, it's the engineering side of coding that I've never actually gotten to seeing. Like I did first year as a Engineering student before dropping it. During that time my teammates dealt with the programming of a robot. It was mad. They coded it so that the robot could dance! It was epic! However, when I looked at their code, it blew my mind. I understood the basic functions but the way they coded it, I was surprised that the robot even moved
So now they are offered at university but not at my nearest university as the financial stability of the market has caused so many people to lose their jobs (especially computing engineers). Good thing my mother's company needs her capabilities (she did code a program that is being used by 22 (can't clearly remember) different countries and that she told me on my birthday and she normally doesn't brag about those things ).
Besides, my mother told me that programming should be my last option if I really want to settle down in life and I agree. I find it more entertaining to play around with numbers (maths). After all, the most enjoyable thing in maths is the amount of complex and difficult questions and I love it!
Besides, apart from me and dad, mum doesn't even touch the computer apart from bringing work to home and spending long hours on them and sometimes forgets to sleep until I smash the door down and tell her to sleep (not literally but you get the point).
And from all of these messages, I'm getting the feeling that you guys are above the age line of 22 or 23 or even above. Man I feel young and that isn't the first. I mean, I went to my old school for work experience in teaching and all of the Maths C students called me "Sir" the moment I entered the room. Seriously speaking, that was the room I spent in for the two years of my senior high school (Grade 11 and 12) studying Maths C and my favourite teacher was there too (back then we called it the "Cold Room" because it was freezing in the mornings whenever you entered it).
Your right Lucifer. VB does tend to make some ways for the lazy side of things but idk how Phyton will help me change but I'll give it a try when I finally get some free time. Right now I need to work on three assignments and then a supplementary exam (forced) due this Friday and then another one next Monday. Seriously, I wish they would stop giving me more than what my hands can hold
Interestingly enough, it's the engineering side of coding that I've never actually gotten to seeing. Like I did first year as a Engineering student before dropping it. During that time my teammates dealt with the programming of a robot. It was mad. They coded it so that the robot could dance! It was epic! However, when I looked at their code, it blew my mind. I understood the basic functions but the way they coded it, I was surprised that the robot even moved
Re: [PHP] Converting Armagetron Colors to HTML Colors
While it sure helps getting rid of some bad habits, python brings new ones as (one of) their philosophy is "devs should be able to do what they want, even if they shouldnt". The only thing that comes to mind is changing constants, as im just getting started with Py.Lucifer wrote:High school programming teachers are notorious for teaching bad habits, and VB is notorious for encouraging bad habits.
If you really want to get rid of as many bad habits as possible, spend a year working with only Python. Do that and you'll find yourself getting increasingly angry at all the bad php/vb/c++/java/whatever code you encounter.
Not that working with Python makes you an immediate good programmer, just that it does a great job nitpicking common bad habits in other languages.
There's a difference between knowing your shit, and knowing you're shit. Grammar does matter.
Re: [PHP] Converting Armagetron Colors to HTML Colors
Well one way or the other, you end up with bad habits anyway
Re: [PHP] Converting Armagetron Colors to HTML Colors
Of course, no language is perfect at teaching good habits, thats why incrementing the languages you use helps a lot. But what you should do is read different guidelines and pick what you like. There are several examples of this everywhere, the one i like the most and the one which pushed me to be constant with my own coding style is eyeOS's.LOVER$BOY wrote:Well one way or the other, you end up with bad habits anyway
There's a difference between knowing your shit, and knowing you're shit. Grammar does matter.
- delinquent
- Match Winner
- Posts: 760
- Joined: Sat Jul 07, 2012 3:07 am
Re: [PHP] Converting Armagetron Colors to HTML Colors
Just to drop my own tuppence in here, I am extremely behind you all in "coding skill" if you like, but I can see how the comments are a little messy to read. Loverboy, might I suggest that instead of wrapping up explanations where it is difficult to read them, you simply add a text file with a few notes on explaining the functions of some key lines? That way, someone like nux, who is perhaps more adept at programming doesn't have to put up with them, and the information is there for those who need it?
- Lucifer
- Project Developer
- Posts: 8640
- Joined: Sun Aug 15, 2004 3:32 pm
- Location: Republic of Texas
- Contact:
Re: [PHP] Converting Armagetron Colors to HTML Colors
An excellent way to figure out which comments you should make and which ones you shouldn't is to learn how to use doxygen. Write your apidocs to be read in a web browser, and the rest of your comments are to help read how the code itself works.
Re: [PHP] Converting Armagetron Colors to HTML Colors
Actually that's a good idea delinquent. I might as well perform that from now on instead of commenting in the script
Is that ok guys?
Is that ok guys?
Re: [PHP] Converting Armagetron Colors to HTML Colors
http://www.youtube.com/watch?v=07So_lJQyqw finally found a good use
bye
-
- Adjust Outside Corner Grinder
- Posts: 2003
- Joined: Tue Nov 07, 2006 6:02 pm
- Location: paris
- Contact:
Re: [PHP] Converting Armagetron Colors to HTML Colors
I think you should try doing this, then taking bits of it and putting them at the appropriate places in the code, resulting in no more comments, no less comments(mostly) than in the file you wrote. You'll get much closer to what is desirable than commenting each individual line.LOVER$BOY wrote:Actually that's a good idea delinquent. I might as well perform that from now on instead of commenting in the script :)
Is that ok guys?
Re: [PHP] Converting Armagetron Colors to HTML Colors
LOL Magi
Right epsy. I might as well try and control my feverish addiction to putting comments all over the place
Besides, I usually don't leave comments as I find it hard (especially when im not in the mood).
Right epsy. I might as well try and control my feverish addiction to putting comments all over the place
Besides, I usually don't leave comments as I find it hard (especially when im not in the mood).
Re: [PHP] Converting Armagetron Colors to HTML Colors
So for example, this:
In this simple map rotation [Ordered] script of mine, I simply wrote very few comments so simply state the purpose of those variables. Is that how I should keep doing from now on?
Code: Select all
<?php
//! Pre-Declared Variables
$map_count = 0;
$map = 0;
//! This contains the list of your maps
$maps = array("author/category/map1.version.aamap.xml", "author/category/map2-version.aamap.xml");
While (1)
{
$line = rtrim(fgets(STDIN, 1024));
if (preg_match( "/^ROUND_COMMENCING/", $line))
{
$map_count = count($maps);
if ($map < $map_count)
{
$map++; // add counter
}
else
{
$map = 0; // reset counter
};
echo "MAP_FILE ".$maps[$map]."\n";
echo "WAIT_FOR_EXTERNAL_SCRIPT 0\n";
sleep(3);
echo "WAIT_FOR_EXTERNAL_SCRIPT 1\n";
};
};
?>
- DDMJ
- Reverse Outside Corner Grinder
- Posts: 1882
- Joined: Thu Jun 08, 2006 12:15 am
- Location: LA, CA, USA, NA
- Contact:
Re: [PHP] Converting Armagetron Colors to HTML Colors
IMO, those comments aren't even needed.
Usually when you set something to 0 at the top of the code you're initializing it, so it's kind of redundant to so say in the comments.
It's an array called maps, which should be self-explanatory. Now, if the array was called $googoogaga, maybe then you'd need a comment.
++ means add 1, so this comment isn't necessary either
$map started at 0, you were incrementing it above, so it's kind of obvious that setting it back to 0 would be resetting it
Sorry to be critical. I guess the most important thing to commenting is that if you're reading the script (and have a decent knowledge of the language), the code should be almost self-explanatory. If you have to do some weird jumping through hoops and sneaking around corners to get things to work properly, first try and clean it up, but if that doesn't work, then add some comments so people can follow your thought process.
Code: Select all
//! Pre-Declared Variables
Code: Select all
//! This contains the list of your maps
Code: Select all
// add counter
Code: Select all
// reset counter
Sorry to be critical. I guess the most important thing to commenting is that if you're reading the script (and have a decent knowledge of the language), the code should be almost self-explanatory. If you have to do some weird jumping through hoops and sneaking around corners to get things to work properly, first try and clean it up, but if that doesn't work, then add some comments so people can follow your thought process.
Re: [PHP] Converting Armagetron Colors to HTML Colors
Dont comment the code itself, comment why you are using that code. I see that and cant figure out why you want to increase $map or why you want to reset the count. I can clearly see that you are looking for ROUND_COMMENCING from the server output, but why are you? Whats the purpose of this script? How is it supposed to be called?
There's a difference between knowing your shit, and knowing you're shit. Grammar does matter.