Your SlideShare is downloading. ×
0
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Pep 8
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Pep 8

1,345

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,345
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. PEP 8 OU,POR QUE UTILIZAR PADRÕES DE CÓDIGO?
  • 2. AGENDAQuem sou eu?MotivaçãoPEP8
  • 3. QUEM SOU EU?Renato OliveiraCIn-UFPEPUG-PELinux User - #532503Js e Rails developer na E.Life
  • 4. MOTIVAÇÃO“40% ~ 80% of the lifetime cost of a piece of software goes to maintenance”“Hardly any software is mainteined for its hole life by the original author” Sun
  • 5. PROBLEMADesenvolvi um produto há 2 anos e o cliente voltou agora e pediu para adicionar mais alguns módulos PERGUNTA Você tem orgulho do seu código? Está fácil fazer esta manutenção?
  • 6. CODE SMELLNão é um bugEstá mais para um sintoma do código que indica umproblema maiorIndica que o código é fraco de design e que podeatrasar o desenvolvimento ou aumentar o risco debugs ou falhas no futuroUm código que não segue padrões é mais suscetível asmells
  • 7. MANUTENÇÃO QUALIDADE REFATORAR
  • 8. ENTÃO VAMOS FALAR DE COISA BOA NÉ? Você já conhece a nova top therm?
  • 9. E POR QUE COMPYTHON SERIA DIFERENTE?
  • 10. PEP 8Escrita por Guido Van Rossum e Barry Warsaw
  • 11. THE ZEN OF PYTHON import this
  • 12. THE ZEN OF PYTHON, BY TIM PETERS Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts.Special cases arent special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced.
  • 13. THE ZEN OF PYTHON, BY TIM PETERSIn the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless youre Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, its a bad idea.If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- lets do more of those!
  • 14. FORMATAÇÃO DE CÓDIGO Identação Tabs ou espaços Comprimento da linha Linhas em branco imports
  • 15. ERRADOipr o,ss mot s y CERTOipr o mot sipr ss mot y CERTO[2]fo o ipr pt,mdr rm s mot ah ki
  • 16. ERRADOpitsm(fb 5) fb 1 )) rn oa i( , i( 0 CERTOpitsm(i() fb1) rn oafb5, i(0)
  • 17. OPERADORES ERRADOx1 =0ay1 =<0 CERTOx=10a=y<10
  • 18. OPERADORES ERRADOsm( =1,y=2) oax 0 0 CERTOsm(=0 y2) oax1, =0
  • 19. ATRIBUTOSAGM_OSAT =2 LUACNTNE 0agm_aivl="luasrn" luavrae agm tig_tiuod_s_nen ="ur srn" arbt_euoitro ota tigcasNmeelse ls odDCas: _arbt_rvd_ecas =Tu _tiuopiaod_lse re dfagm_uco) e luafna(: #cdg d ba óio e o dfOtauco) e urFna(: #cdg tnoau óio es qi
  • 20. RECOMENDAÇÕESi xi Nn: f s oe .. .i z f : .. .i tp(b)i tp() f yeoj s ye1: #erd raoi iisac(b,it: f sntneoj n) #cro et
  • 21. RECOMENDAÇÕESi fo:]= a f o[3 = br: #erd raoi frsatwt(br) f o.trsiha: #cro et
  • 22. MAIS EMhttp://www.python.org/dev/peps/pep-0008/
  • 23. DÚVIDAS?
  • 24. OBRIGADO @_renatoOliveira renato@labcodes.com.brgithub.com/renatooliveira

×