DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • July 23, 2018, 08:38:06 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: 1 [2] 3   Go Down
  Print  
Author Topic: Coding Tips  (Read 20883 times)
0 Members and 1 Guest are viewing this topic.
Talisman
Administrator
Mod God
*****
Offline Offline

Posts: 5479



View Profile WWW
« Reply #15 on: August 18, 2006, 04:35:30 PM »

the tips are ok, but for 1.x.x

*cough*

 Support for version 0.9.7 (Obsolete)  |  v0.9.7 Technical Help

<--forum topic ^^

Coding tips are timeless  Wink
Topic moved
Maybe someone will compile and add to wiki...
Logged

Play the latest beta version here on DragonPrime
Harassim
Guest
« Reply #16 on: August 27, 2006, 09:23:10 AM »

1.  Try to "close your lines".  This is important for translation of your module:
[...]
Instead, just do it all in one line or break it up:
output("This is how I used to write text until I");
output("learned that it made it difficult for translation.");

You might want to use this instead:

output("This is how I "
."code this "
."kind of thing");
Logged
Nightborn
Guest
« Reply #17 on: August 27, 2006, 10:10:59 AM »

1.  Try to "close your lines".  This is important for translation of your module:
[...]
Instead, just do it all in one line or break it up:
output("This is how I used to write text until I");
output("learned that it made it difficult for translation.");

You might want to use this instead:

output("This is how I "
."code this "
."kind of thing");

do so and I'll eat you.

This is translation-ready for the system, but it is not a good style... also the Translationwizard Filescanner will only get the first part.

For sake of nice code, *please* don't.
Logged
Elessa
Faerie
Mod God
*****
Offline Offline

Posts: 3598


short, sweet and to the point


View Profile
« Reply #18 on: August 27, 2006, 10:19:12 AM »

do so and I'll eat you.

This is translation-ready for the system, but it is not a good style... also the Translationwizard Filescanner will only get the first part.

For sake of nice code, *please* don't.


hmmm... nightborn has cannibalistic tendencies. is this a good thing?  Wink
Logged

Uuma ma ten rashwe, ta tuluva a lle

Play the latest beta version here on LoGD DragonPrime - Axebridge
Kalisiin
Guest
« Reply #19 on: April 05, 2007, 11:26:03 AM »

This is actually quite useful, as if-else loops tend to drive me bananas.  I end up with parse errors a lot of times because of missed parenthesis, etc...Crimson Editor is very helpful in that regard, because it will show you which parenth is matched with which one.

If you are hovering right over a parenth in Crimson, and it does not underline it - then you have a parse error, because it's not pairing up.  If there is an underline, you can scroll up or down to find the other parenth that is underlined, and thus, you know which one it is paired up with.

What drives ME crazy, though, is people who code in notepad, and then, when the text gets translated, you end up with solid square blocks indicating <ENTER> and you end up with double and triple-spaced lines for no good reason.  And then you have to go in and take them all out.
Logged
Nightborn
Guest
« Reply #20 on: April 05, 2007, 12:13:05 PM »

hmmm... nightborn has cannibalistic tendencies. is this a good thing?  Wink

Only if it's for the sake of decent code...

^^

@K
notepad++ beats crimson in my humble opinion. =) had both installed and running for some time.

If all would use TAB instead of simply putting 3 spaces in the world would be a better place.
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #21 on: April 05, 2007, 12:15:24 PM »

Zend Development Environment beats notepad++ by lengths... Wink Automatic code analyzation rul0rz!!! Grin Grin Grin
Logged

Running for more than three years now:
Nightborn
Guest
« Reply #22 on: April 05, 2007, 12:17:32 PM »

 Roll Eyes do you buy me that?

else, I have no money. Zero, nada.

That's why I use opensource where I can.
Logged
SaucyWench
Mod God
*****
Offline Offline

Posts: 2238


I'm a good girl.


View Profile WWW
« Reply #23 on: April 07, 2007, 08:11:06 AM »

If you put the closing brace in when you put the opening one, before filling the contents, you won't leave them open...

You also do not have "parse errors" when you have braces open. You have faulty code. A parse error is only one of several possible errors. I don't always have "engine failure" when my car is not driving. Occasionally it's a flat tyre.
Logged

SaucyWench
Owner of GemDust.com and Darton City proudly hosted by LunarPages
Kalisiin
Guest
« Reply #24 on: April 07, 2007, 09:44:41 PM »

Ok, ok...but that is what I always get, anyway.  Parse errors.
Drives me crazy to look for them.

That's actually a good idea to put the closing bracket or parenth in right away.

I give credit where credit's due....
Logged
Talisman
Administrator
Mod God
*****
Offline Offline

Posts: 5479



View Profile WWW
« Reply #25 on: March 09, 2008, 04:19:01 PM »

I would ask that those posting in this thread restrict themselves to things they KNOW, as opposed to guessing.

Comments are essential in files.
Changelogs are NOT an irritation.
PHP is not an archaic BATch language which parses each line multiple times in the execution of a file.
Comments do not slow down a module.  Bad coding and SQL queries do.
Logged

Play the latest beta version here on DragonPrime
Nevhiliel
Guest
« Reply #26 on: March 13, 2008, 05:33:48 PM »

The usage of lots of variables doesn't slow down a script. (F.e. while calculating something, it will be quite useful to declare some variables between)
Code:
$number1 = 1;
$number2 = 5;
$result = $number1 + $number2;

output( 'The sum of '.$number1.' and '.$number2.' is '.$result );

Creating lib-Files for a huge project may increase the survey of codes.
PHPeclipse seems to be a pretty good OpenSource-PHP-Editor.
++$variable and $variable++ are still not the same. :-P
Caching is a good thing, unless you know what to cache, and what not. (F.e. file-caching of the accounts-data on a well-visited lotgd-server - Good Bye Server )
Logged
MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1744


View Profile
« Reply #27 on: March 13, 2008, 06:23:51 PM »

To add to the curly bracket thing, always use them and always put them on their own lines to make code easier to read and don't be afraid to space things out.

IMO bad.
Code:
if($something=='3'){
    if($another=='thing'){
        //stuff goes here
    }else{
        //Other stuff
    }
}

Better.
Code:
if( $something == '3' )
{
    if( $another == 'thing' )
    {
        //stuff goes here
    }
    else
    {
        //Other stuff
    }
}

By putting the curly brackets on their own lines, you're giving your code room to breath and allowing your eyes to see everything better.

I tend to us the coding guidelines that are used for phpBB. Smiley
Logged

Check My Modules for the latest versions.
Maeher
Codemeister
****
Offline Offline

Posts: 362


There's nothing to see here...


View Profile
« Reply #28 on: March 13, 2008, 06:55:34 PM »

I have to disagree.

In my opinion (That may very well be influenced by the Java Conventions) the first code is much simpler to read.
Opening brackets in their own line always keep my from reading code smoothly.
Logged

There is no signature...
MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1744


View Profile
« Reply #29 on: March 13, 2008, 07:08:35 PM »

I used to format my code like that when I used Perl many years ago and was always getting lost. heh For me, the way I do it now makes it much easier, to spot mistakes etc. Smiley
Logged

Check My Modules for the latest versions.
Pages: 1 [2] 3   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Version 1.1.2 is the current supported version and is available for download.

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
32 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search