Previous Thread
Next Thread
Print Thread
Rate Thread
#102392 03/05/2001 11:11 PM
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
P.I.T.A. / Programmer
Offline
Joined: Sep 2000
Posts: 755
I've been looking at a lot of code lately, and it pains me to see how unstructured and randomly formatted it is.

A nice, clear, consistant layout of the code goes a LONG way to debugging code, or understanding it.

With that in mind, I would suggest a reading of the Perl Style Guide as it contains the recommended style for Perl code.

Upon reading it, the first question people always ask me is "what's an uncuddled else?"

this is cuddled:

Code
code:

This is the preferred way:

Code
code:

(with the else on its own line)

Everyone has there own style of how they do things. That's fine. If you don't want to go with all of the recommend Perl styles that is ok. BUT, whatever style you choose, please be consistant throughout your code. Don't follow other people's example's and make a mishmash of sloppy looking code.

Code that looks professional gains much higher respect then code that doesn't.

--mark


"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
Sponsored Links
#102393 03/07/2001 12:16 AM
Joined: Mar 2000
Posts: 615
Member
Member
Offline
Joined: Mar 2000
Posts: 615
I personally like the

if (something) {
dosomething;
} else {
somethingelse;
}

better

#102394 03/07/2001 5:53 PM
Joined: Feb 2001
Posts: 18
Junior Member
Junior Member
Offline
Joined: Feb 2001
Posts: 18
I agree with Mark that a script should have consistency, but I prefer:

Code
code:

Though the other looks good too; but John, that snippet of yours looks fine there but in a script the size of UBB (or even half the size) it makes it a pain.

#102395 03/07/2001 8:49 PM
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
P.I.T.A. / Programmer
Offline
Joined: Sep 2000
Posts: 755
The reason I don't prefer the cuddled elses is because it makes more sense to have them exactly lined up under their corresponding if statement. Plus the makes the blocks more segmented.

Personal preference, I prefer the way the style guide mentions.


"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
#102396 03/07/2001 10:11 PM
Joined: Mar 2000
Posts: 615
Member
Member
Offline
Joined: Mar 2000
Posts: 615
Quote
quote:
Um, yours is the same as mine....

Sponsored Links
#102397 03/08/2001 9:04 AM
Joined: Feb 2001
Posts: 18
Junior Member
Junior Member
Offline
Joined: Feb 2001
Posts: 18
Quote
quote:
You have no indentation on yours. That's what I was referring to.

#102398 03/11/2001 7:23 PM
Joined: Feb 2000
Posts: 4,625
Member
Member
Offline
Joined: Feb 2000
Posts: 4,625
I personally prefer:

Code
code:

One liners, ya know? If i must use else, which for most of my code i dont, i prefer:

Code
code:

[ March 11, 2001: Message edited by: MasterMind ]


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240430)