Your SlideShare is downloading. ×
Object Calisthenics
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

Object Calisthenics

829
views

Published on

Published in: Technology, Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
829
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
7
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. Object Calisthenics @krolow
  • 2. WTF?● code is hard to understand, test and maintain● OO will save us!● its hard the transaction of paradigms Procedural --- to --- OOP● Qualities matters: ○ cohesion ○ loose coupling ○ no redundancy ○ encapsulation ○ testability ○ readability
  • 3. so what is it about?Its an exercise, a practice to help you to writegood oriented-object code!
  • 4. The RULES#1 One level of indentation per method#2 Dont use ELSE keyword#3 Wrap all primitives and String#4 First class collections#5 One dot per file#6 Dont abbreviate#7 Keep all entities small#8 No classes with more than two instancesvariable#9 No getters/setters/properties
  • 5. #RULE1You shall not ident more than once!
  • 6. #RULE2You shall not have "else"
  • 7. #RULE3 You shall encapsulate the primitives typesnot totally applicable in PHP because of performance issuesbut... we can do this with other types...
  • 8. #RULE4Your collection shall not have other membersvariable
  • 9. #RULE 5 You shall use one dot per file, so you know each object has the responsiblenot totally applicable in PHP...... but nested calls ● show some problems of encapsulation make harder to debug ... ● we can use... in chain of get and setters in chain of objects with a fluent interface
  • 10. #RULE 6 You must not abbreviatewhy I should abbreviate? ● because I use the name several times... ● .... maybe your method is to heavily and you should remove duplication ● or because the names are too long... ● ... maybe you are misplacing responsibilities or there is a missing class...Avoid also duplicate of words...
  • 11. #RULE 7 Keep your entity classes smaller!50 rows by class10 classes by package...maybe 100 rows by class and 15 by package its also OK!
  • 12. #RULE 8 Class shall have less than 2 instance variablesYep quite hard this... but lets try...with this we can decomposition, we can separate the concerns...maybe 5 variables its also okay dont you think?
  • 13. #RULE 9 You shall not have getter and settersWTF?Yeah, PHP its not possible apply that :|BUT...If we apply the #RULE 8 we may get this!