ieleja Posted August 10, 2013 Report Share Posted August 10, 2013 https://en.wikipedia.org/wiki/Indent_style bakstoties svešos kodos, atrodu visādas stilus, pašam vislabāk tīk Whitesmiths style, bet nu esmu atvērts sasēņots internetos, bet ticami, ka populāri pēc kārtas ir šie: 3.1 K&R style 3.2 Allman style 3.3 BSD KNF style kā dariet jūs un kāds ir izvēles iemesls - pierasts, darba devējs, cits iemesls? Quote Link to comment Share on other sites More sharing options...
daGrevis Posted August 11, 2013 Report Share Posted August 11, 2013 Kāds stils ir projektā, tāds stils arī būs projektā. :D Quote Link to comment Share on other sites More sharing options...
gurkjis Posted August 11, 2013 Report Share Posted August 11, 2013 daGrevis, tas tiesa, bet kādu izvēlies, kad raksti savu projektu no 0 ? Uz python šis laikam neattiecas, jo tur braces nav. Apskatījos minētos stilus, mans sanāk Allman style. Kā jau wiki rakstīts, tas ir more readable. Aizguvu no kaut kāda projekta, kurā šis stils bija lietots un iepatikās. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted August 11, 2013 Report Share Posted August 11, 2013 PHP un JavaScriptu rakstīju The One True Brace Style'ā. :P Pythonam pilnīgi pieturos PEP8. Quote Link to comment Share on other sites More sharing options...
codez Posted August 11, 2013 Report Share Posted August 11, 2013 neciešu tukšas rindas, kas sākas ar {, tāpēc vienmēr rakstu: if (...){ .. } while(...){ .. } Quote Link to comment Share on other sites More sharing options...
daGrevis Posted August 11, 2013 Report Share Posted August 11, 2013 Neciešu, ka neliek atstarpi starp `){`. Quote Link to comment Share on other sites More sharing options...
jurchiks Posted August 11, 2013 Report Share Posted August 11, 2013 (edited) Allman forever. Visādi citādi gandrīz pilnībā pieturos Oracle guidelines: http://www.oracle.com/technetwork/java/codeconv-138413.html (arī PHP kodā tāpat formatēju, rūļi lielā mērā atbilst un readability man ir ļoti svarīgs). Ir pāris sīkumi, kuros nepieturos, bet tādi bija burtiski pāris un uz sitiena neatceros. Izvēles iemesls: sāku programmēt, darbojoties ar open-source projektu, kurā praktiski visur tika izmantots Allman stils, bet pārējos rūļus pats izvēlējos, kā man vislabāk patika no Eclipse code style dotajām iespējām. Tikai vēlāk uzzināju, ka mani preferences ļoti atbilst Oracle guidelines. Edited August 11, 2013 by jurchiks Quote Link to comment Share on other sites More sharing options...
dot Posted August 11, 2013 Report Share Posted August 11, 2013 PSR? http://net.tutsplus.com/tutorials/php/psr-huh/ Quote Link to comment Share on other sites More sharing options...
F3llony Posted August 11, 2013 Report Share Posted August 11, 2013 PSR? http://net.tutsplus.com/tutorials/php/psr-huh/ Lūdzu, lasies nakuj ar šito pseido "standartu". Zero shit value ir tam sūdam. Tāpat, kā jebkuram dornim, kas jamo reklamē. Stilam nav nozīmes, visu izšķir slāpes! As long as it's readable. Quote Link to comment Share on other sites More sharing options...
jurchiks Posted August 12, 2013 Report Share Posted August 12, 2013 (edited) Palasīju tos PSR, 0. un 1. piekrītu, bet 2. ir pāris aizķeršanās: Code MUST use 4 spaces for indenting, not tabs. Fuck you. Visibility MUST be declared on all properties and methods; abstract and final MUST be declared before the visibility;static MUST be declared after the visibility. visibility [static] [final] or visibility [abstract|final] Opening braces for control structures MUST go on the same line, and closing braces MUST go on the next line after the body. Baigi gudri, klasēm un funkcijām braces on a new line, šeit nē... Fuck this aswell. The extends and implements keywords MUST be declared on the same line as the class name. šis gan liekās pilnīgi nevajadzīgs noteikums, kāpēc gan neļaut sadalīt extends sarakstu un implements sarakstu katru savā līnijā, piemēram, šādi: public final class Bar extends \Foo implements \That, \SomethingElse Edited August 12, 2013 by jurchiks Quote Link to comment Share on other sites More sharing options...
rpr Posted August 12, 2013 Report Share Posted August 12, 2013 extendam var būt arī saraksts? :) Quote Link to comment Share on other sites More sharing options...
jurchiks Posted August 12, 2013 Report Share Posted August 12, 2013 (edited) You got the idea. Turklāt C++ suportē multiple inheritance. Edited August 12, 2013 by jurchiks Quote Link to comment Share on other sites More sharing options...
daGrevis Posted August 12, 2013 Report Share Posted August 12, 2013 > Turklāt C++ suportē multiple inheritance. Python arī, bet ne viens, ne otrs, nav PHP. Quote Link to comment Share on other sites More sharing options...
jurchiks Posted August 12, 2013 Report Share Posted August 12, 2013 Izlasi topic title... Quote Link to comment Share on other sites More sharing options...
daGrevis Posted August 12, 2013 Report Share Posted August 12, 2013 Whoops! My bad. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.