Page 2 of 3

Posted: Fri Aug 18, 2006 10:01 am
by feyd
ole wrote:Wow, that's confusing, i would never mix like that.
:D He wanted to see real situations. There they are.

Posted: Fri Aug 18, 2006 10:04 am
by Jenk
also for multiple conditions, I like to contain them within there own parenthesis..

Code: Select all

if (($a == 0) && ($b == 1) && ($c == 2))
Also applies for sub-definitions/conditions:

Code: Select all

while (($pos = strpos($a, $b)) !== false) //etc

if (($num = func_num_args()) != 0) echo $num;
I've only recently started using single line if's, though my while loops are always braced.

Posted: Fri Aug 18, 2006 12:24 pm
by alex.barylski
Wow...

We all have our own style...I have a bit in common with all of you :P

I think it's going to be difficult to standardize anyone without pay...

The only thing I can't justify is the spacing between keywords, etc...as it's strictly personal taste, I can't stand extra padding...

I do have an argument as far as extra bytes, but like feyd has noted it's less and less important...but at the same time, the larger an application gets, the more important extra bytes become... :P

hyphens in files names...I tried that a while back, but I experienced problems when displaying filenames in a PHP script...the hypen would break the filename onto a new line I think even if I used the entity like: ‐

Spaces, are horrible for that reason...all those %20 entities...

We can all agree on that it seems...spaces in file names is a BIG NO!!! :)

Ok that that's one convention...

Now we need to argue why hyphen's should be used over underscores or visa-versa...also why no seperation is needed at all or is it???

I say underscores, just because you don't need to str_replace('-', '&hyphen', $str) filenames before sending them to screen when developing a file manager when using 'underscores' in filenames...

Also underscore is one of the valid characters in used in programming namespaces(0-9a-z_) or whatever the exact regex is...point is...might as well stick with convention as it's easier to remember that way... :)

It appears most agree spacing is important in file names...so for the above reason...I vote underscore???

Can I get an all in favour or all opposed vote? :)

I think this is the best way to come to a conclusion of what's best, but seriously lets try and stay pragmatic...truely try and avoid personal preferences...

I'm flexible as much as I preach my own standards, I do so for a reason...as I think I've adapted every coding style on the planet...from MSDN to linux Kernel...from Java to PHP...and so on...

I want to change for the better, but I don't want to change all the time unless it's an important reason to change...

So back to the voting...on filename spacing...

Posted: Fri Aug 18, 2006 12:42 pm
by feyd
Hockey wrote:...underscores...Can I get an all in favour or all opposed vote? :)
Image

Posted: Fri Aug 18, 2006 1:21 pm
by Ollie Saunders
I'm with Feyd. Underscores in constants that's it, no hypens either, camelCaps all the way!

Posted: Fri Aug 18, 2006 1:44 pm
by alex.barylski
Ok fare enough, but can you justify with an answer why you want to use camel caps in filenames?

I stated my reasons for using small case always using underscore to seperate words...it has to do with case-sensitivity, in switching from Windows to Linux servers and referencing files and accidently forgetting to capitalize a letter...

Also with camelcase, my concern (nothing else - Like I said i'm open to change) is what happens when you encounter an acronym? It's common practice in every industry to capitalize acronyms, but that could make files looks ugly and what about editors, listing toosl, etc which force CAPS or lowercase? The semantic behind using CamelCase is lost...???

If you follow one or the other (CAPS vs lower) it wouldn't matter...obviously I choose lowercase because CAPS ALL THE TIME IS ANNOYING :P

The way I see there are more issues with using camelcase in files names than just using lowercase and underscores to seperate words...???

This is my argument anyways...as either direction works for me...I just want a concrete direction...so can anyone rebuttle my arguments???

Posted: Fri Aug 18, 2006 1:44 pm
by s.dot
ole wrote:I'm with Feyd. Underscores in constants that's it, no hypens either, camelCaps all the way!
Err.. camelcaps for file naming? I'd go with an underscore rather than camelcaps, since filenames are case sensitive. :P My personal preference would be an underscore. But it seems I'm disagreed with. :-P

[edit] Hockey beat me!

Posted: Fri Aug 18, 2006 1:59 pm
by feyd
Hockey wrote:Ok fare enough, but can you justify with an answer why you want to use camel caps in filenames?
One word: consistency. As long as the class is named accordingly, then I'll deal with whatever is chosen. But considering I use camelcase for class names, it's pretty simple that I'd choose camelcase for filenames too.
Hockey wrote:I stated my reasons for using small case always using underscore to seperate words...it has to do with case-sensitivity, in switching from Windows to Linux servers and referencing files and accidently forgetting to capitalize a letter...
You you can't keep your case consistent then you aren't a very good C/C++ programmer! Image
Hockey wrote:Also with camelcase, my concern (nothing else - Like I said i'm open to change) is what happens when you encounter an acronym? It's common practice in every industry to capitalize acronyms, but that could make files looks ugly and what about editors, listing toosl, etc which force CAPS or lowercase? The semantic behind using CamelCase is lost...???
ACROStuff; DNASha256; HKYSilly. Pretty simple.
Hockey wrote:The way I see there are more issues with using camelcase in files names than just using lowercase and underscores to seperate words...???
Sorry, I don't see any more issues. I don't see any less either; I don't really see any issues either way.


You like question marks, don't you? Image

Posted: Fri Aug 18, 2006 2:51 pm
by alex.barylski
One word: consistency.
I can agree with that logic...
You you can't keep your case consistent then you aren't a very good C/C++ programmer!
Thats why conventions are so important :P
ACROStuff; DNASha256; HKYSilly. Pretty simple.
Savage looking files names if you ask me :) Besides...what about when an application or script your are using converts the filenames to upper or lower as it's own convention...?

ACROSTUFF or acrostuff...by using camel casing, you've lost the sematic purpose behind using camelcase...grante less and less editors, FTP, etc are going to do this as time goes on and they will display files names accurately, but they do still exist...

The point is, in these situations an underscore stays the same regardless of case

Besides that...again with acronyms...

What happens if you use SomeDOMFile.php

Is the acronym DOMF or is it DOM (here the answer is obvious as we all know what DOM is) SomeDOMfile breaks the camelcase convention...

DOMSomeFile.php doesn't help much...

Again, I know this isn't a big issue, because any problems caused by a mixup would be and could be quickly rectified as the error messages generated by including a mis-typed include() are fairly obvious...

What I am trying to do is eliminate that chance completely, by using all lower case and underscore to seperate, there is very little chance of a mistake...are there are no questions needed to be asked...

*every* word is seperated by an underscore, regardless of whether it's preceeding word was an ancronym or not, etc...

Also, in sticking convention...extensions are almost 100% of the time lowercase...that may be why I choose lowercase...just to keep the file names pretty, relative to their extensions... :P

Anyways, I think I've completely made my point...does anyone have anything else to argue...

So far it's 2 for 2...

Can Mod's somehow modify this post and make it an actual poll?

File names: CamelCase or lowercase with underscores???

As we progress, would it be possible to change the polls? Have them run for a week or so, letting people read in on how we debate, and make choices based on arguments made???

Just like the house of commons??? :)

I think this way will would eventually hammer out the ideal convention document...

Cheers :)

Posted: Fri Aug 18, 2006 3:02 pm
by Oren
lowercase_and_underscores all the way 8)
I don't have much to say since Hockey obviously made his (and my) point.

Posted: Fri Aug 18, 2006 3:06 pm
by feyd
Hockey wrote:I think this way will would eventually hammer out the ideal convention document.
You're the first to bring up this "need." No moderator that I know of has ever brought up that we "need" a convention on the boards, and we can't expect anyone to follow it here. The only time an agreed upon convention becomes (mildly) important is when we're working on projects with other programmers, and even then, you can't expect it to be 100% the same for everyone. That's what beautifiers are for.

If you can't tell, all along I've pretty much sided with Arborint about this being a silly discussion. We know we aren't likely to sway each other in any one direction, we like the things we like for whatever reason. Now, that being said.. I don't think the moderators will do the poll creation for you. I think you're approaching being an island in this case. I don't know, it's up to the other moderators if they want to do it. But that's the feeling I'm predicting.


edit: You originally asked for my opinion on the various parts, and I will continue to do that, but in ratifying a codestyle, I will not be apart of. Sorry if you find that disappointing or infuriating, I just think the subject of conventions where it's impossible to enforce or ridiculous to even try is just patently silly.

Posted: Fri Aug 18, 2006 3:46 pm
by alex.barylski
feyd wrote:
Hockey wrote:I think this way will would eventually hammer out the ideal convention document.
You're the first to bring up this "need." No moderator that I know of has ever brought up that we "need" a convention on the boards, and we can't expect anyone to follow it here. The only time an agreed upon convention becomes (mildly) important is when we're working on projects with other programmers, and even then, you can't expect it to be 100% the same for everyone. That's what beautifiers are for.

If you can't tell, all along I've pretty much sided with Arborint about this being a silly discussion. We know we aren't likely to sway each other in any one direction, we like the things we like for whatever reason. Now, that being said.. I don't think the moderators will do the poll creation for you. I think you're approaching being an island in this case. I don't know, it's up to the other moderators if they want to do it. But that's the feeling I'm predicting.


edit: You originally asked for my opinion on the various parts, and I will continue to do that, but in ratifying a codestyle, I will not be apart of. Sorry if you find that disappointing or infuriating, I just think the subject of conventions where it's impossible to enforce or ridiculous to even try is just patently silly.
Hmmm...ok then :P

I didn't quite see it as a universal convention, but rather as a possible convention everyone could follow if they wanted their code peer reviewed and posted in a special Code Section forum...

Obviously I didn't have high hopes as this ain't my forum, but figured I could maybe persuade one of you to consider it...

Conventions are important...especially when dealing with more than one person other than yourself...like CVS or subversion, commenting, etc...

There is no less or more important in my books...the best companies I worked for, the ones which have continuosly produced stellar quality products, have conventions thouroughly hammered out, so there is no arguing or he said/she said...

I wish I could point you to some of the projects I've worked on, so you could see, but as a freelance developer I've often been required to agree to a NDA that includes my *not* telling anyone about a product I've worked on...

I'm sure they wouldn't find out if I linked to them from here, but given the context of the message, it would be a stupid idea...

The point is...I've seen the difference solid conventions make...and I'm amazed I'm the only one who feels this way...but if so...so be it I guess...

You've clearly worked on projects without standard conventions and had acceptable results...

Personally I like everything planned out intensely...that includes following rock solid conventions which serve a purpose other than just personal taste...

It's all good though man...I still appreciate your input...as I'm trying to remain as open minded as possible in coming to a conclusion about conventions...

Take er' easy :)

Posted: Fri Aug 18, 2006 4:08 pm
by feyd
Hockey wrote:You've clearly worked on projects without standard conventions and had acceptable results...
Every project I've worked on has had conventions. They were, overall, specific and custom to that project. I have no general problem with conventions, after all, I have my own code conventions. But I don't find them important enough to make them outside of a specific project. There are far more important things pressing for me to care too much about how many spaces my tabs are and where I place a brace.
Hockey wrote:I still appreciate your input...
Excellent.
Hockey wrote:as I'm trying to remain as open minded as possible in coming to a conclusion about conventions.
Maybe there's a threshold that I've gone through that allows me to accept pretty much whatever's thrown at me where I just don't really care about it as much.

Something to think about.. Image

Posted: Fri Aug 18, 2006 4:13 pm
by Oren
<off-topic>Damn... Are you ever going to release these smiles to simple members? Or perhaps make me an admin :P </off-topic>

Posted: Fri Aug 18, 2006 4:39 pm
by alex.barylski
Well my problem is this...

I still consistently program in C/C++ MFC/ATL/WTL/COM/Perl/PHP/JavaScript/Windows and just recently started reading up on Linux Kernel...

I am currently designing documents and testing ideas for a CMS I will begin to develop hopefully somewhere by mid-fall...

I too have a million things on the go...and conventions are completely ignored when I'm a hired gun...I just kind of copycat everything before and after my code the best I can...

I've done that for years...and can say without a dought, it's those situations in which bad code is produced...

The things is, bad code doesn't sell a product it's marketing and sales people who sell the product and as long as it works - c'est la vie!!!

I absolutely "hate hate hate" that feeling of poor quality code, conventions is a small part of that feeling...but it's a part none the less...

Proper design, etc are equally important, so is easy to use interfaces, etc...but they are more obvious and better documented...design patterns??? Also they tend to be more adhoc depending on the project...

MVC is solid but the specific implementation will vary from project to project based on requirements...

Conventions are something you could absolutely almost hammer out 100% with enough time and effort...albeit more effort than I'm willing to put out as a lone sldier, so I figured I would turn to a community... :)

Sure you could beautifiers, but why, it's an extra step when everyone could just stop being so personal and do what has been proven to work in the past...

Making your entire team use a solid convention, would be like Henry Ford implementing the assembly line...sorta :P

I've had many roles as a freelance developer, some as project lead hand on small projects and others just as a hired gun to crack out some objects...

I'm obsessed with perfection...I think day in and day out about how to make code better, both in design, aesthetics, etc...I dream about it...not just as a programmer but as a future business mogul :P

Seriously...I have big hopes and even bigger dreams...and realize two heads are waaaay better than one...

By following a strict standard, coding conventions, etc...we unify programmers to write somewhat similar code...spacing may not bother you, but is does bother me (and I bet you or me are not unique in that stance) so much so, I've ran beautifiers on source before...for what, wasted time???

I know I'll never convince the entire world to follow suit or even this entire community...but I'll at least try and nail home the importance of coding conventions...as to me...everything about development is important...

Now I am not saying we should adapt to these stated conventions for everything, thats silly...we as developers need to remain flexible and capable of working with any project, but as a community, wouldn't it be worth a shot to try and unify our coding techniques, conventions, etc...?

I like most of the people on here and find everyone quite intriguing in one way or another...iamsure with his constant barking of standards, etc...really opened my eyes as to the importance of standardized XHTML...hard to pill to swallow at first, but after some thought...it made sense, both morally and technically...

arborint with his constant advocating of design patterns, etc...despite having used most of them or very similar techniques (TDD, MVC) over the years after some consideration...I seen the usefulness to actually documenting the...

By doing so there have created somewhat of a standard blueprint to follow when developing software...so what harm would an additional blueprint cause by forcing coding conventions???

Programming is about the only engineering profession I can htink of that doesn't have absolute guidlines to follow...I may be wrong as I'm not an engineer, but I've been in contact with many professors, engineers, etc over the years via email, person, etc...and this is definetely the impression I'm left with :)

No wonder software is so buggy compared to other engineering practices...

This industry needs more hardened standards...blueprints if you will...and coding conventions is one of them...IMHO anyways...

Cheers :)