SlideShare une entreprise Scribd logo
1  sur  20
Renée De Voursney July 14, 2011 ConferenciaRails How I learned to smell code Photo credit: http://www.vlib.us/medical/gaswar/Exp.%20Dog%20Mask,%20WWI.jpg
How many of you went to university for Computer Science? How many have a background in business consulting or working in the Microsoft stack (C#)? I will assume we all currently work with Rails. How many have a main app that is Rails <= 2.0.5? Rails 2.3.x? Rails >= 3.0.x? Who is out there? Photo credit: http://www.flickr.com/photos/drachmann/327122302/sizes/l/in/photostream/
Who am I? ,[object Object]
Lives in Seattle, Washington
A mountain and rock climber
Loves Building Systems for People
Loves Working in a Programming Language made for People
Likes Useful Frameworks and Gems
Strives to live up to the principles learned onRenee’s Road to Scentless Code
A hound surrounded by wonderful smelling flowers, is to a developer working with: Well documented code A working application Well designed and maintainable code What I want Photo credit: http://timesnow.info/Download/images/pet_animals/cute_puppies/spring_scents_basset_hound.jpg
Writing and then Maintaining Lots and Lots of stinky code! How did I get there? Renee’s Road to  Scentless Code  Photo credit: http://static.howstuffworks.com/gif/pug.jpg
Photo credit: http://www.vlib.us/medical/gaswar/Exp.%20Dog%20Mask,%20WWI.jpg
[object Object]
Teaching someone else is the best way to learn and re-enforce your understanding of a concept
Objects, javadoc, and the JVM are really cool! What Did I learn Photo credit: http://www.mentalfloss.com/wp-content/uploads/2007/10/tongue_stuck_on_pole.jpg
Photo credit: http://i2.squidoocdn.com/resize/squidoo_images/250/draft_lens10490801module95270741photo_1271186415dog_sneeze.jpg
[object Object]
Single Responsibility
Abstractions
Positive Conditions, Always have an else…. What Did I learn Photo credit: http://www.flickr.com/photos/sephiroty/320928712/sizes/z/in/photostream/

Contenu connexe

Similaire à How I Learned to Smell Code

Recipe of a rockstar developer
Recipe of a rockstar developerRecipe of a rockstar developer
Recipe of a rockstar developer
Topu Newaj
 

Similaire à How I Learned to Smell Code (20)

hey I founded a tech startup...OH SHIT I CAN'T CODE. #barcampsg7
hey I founded a tech startup...OH SHIT I CAN'T CODE. #barcampsg7hey I founded a tech startup...OH SHIT I CAN'T CODE. #barcampsg7
hey I founded a tech startup...OH SHIT I CAN'T CODE. #barcampsg7
 
Software Craftsmanship - It's an Imperative
Software Craftsmanship - It's an ImperativeSoftware Craftsmanship - It's an Imperative
Software Craftsmanship - It's an Imperative
 
TxJS 2011
TxJS 2011TxJS 2011
TxJS 2011
 
My experience of Ruby Education in Taiwan
My experience of Ruby Education in TaiwanMy experience of Ruby Education in Taiwan
My experience of Ruby Education in Taiwan
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
 
OWASP Bricks presentation from OWASP-Null combined meet at Delhi, August 2014
OWASP Bricks presentation from OWASP-Null combined meet at Delhi, August 2014OWASP Bricks presentation from OWASP-Null combined meet at Delhi, August 2014
OWASP Bricks presentation from OWASP-Null combined meet at Delhi, August 2014
 
Recipe of a rockstar developer
Recipe of a rockstar developerRecipe of a rockstar developer
Recipe of a rockstar developer
 
Documentation for developers
Documentation for developersDocumentation for developers
Documentation for developers
 
Why you should use a web framework, eventually
Why you should use a web framework, eventuallyWhy you should use a web framework, eventually
Why you should use a web framework, eventually
 
Ruby On Rails Presentation
Ruby On Rails PresentationRuby On Rails Presentation
Ruby On Rails Presentation
 
Software craftsmanship - Imperative or Hype
Software craftsmanship - Imperative or HypeSoftware craftsmanship - Imperative or Hype
Software craftsmanship - Imperative or Hype
 
Learning Web Development with Ruby on Rails Launch
Learning Web Development with Ruby on Rails LaunchLearning Web Development with Ruby on Rails Launch
Learning Web Development with Ruby on Rails Launch
 
Developers are People Too! Building a DX-Based API Strategy Ronnie Mitra, Pri...
Developers are People Too! Building a DX-Based API Strategy Ronnie Mitra, Pri...Developers are People Too! Building a DX-Based API Strategy Ronnie Mitra, Pri...
Developers are People Too! Building a DX-Based API Strategy Ronnie Mitra, Pri...
 
Most common mistakes in ruby on rails development (and how to avoid making them)
Most common mistakes in ruby on rails development (and how to avoid making them)Most common mistakes in ruby on rails development (and how to avoid making them)
Most common mistakes in ruby on rails development (and how to avoid making them)
 
Software Craftsmanship - It's an Imperative
Software Craftsmanship - It's an ImperativeSoftware Craftsmanship - It's an Imperative
Software Craftsmanship - It's an Imperative
 
SxSW 2015
SxSW 2015SxSW 2015
SxSW 2015
 
Shrey jairath li
Shrey jairath liShrey jairath li
Shrey jairath li
 
Shrey jairath
Shrey jairathShrey jairath
Shrey jairath
 
AWResume
AWResumeAWResume
AWResume
 
Extracurricular Swift
Extracurricular SwiftExtracurricular Swift
Extracurricular Swift
 

Plus de reneedv

Plus de reneedv (14)

Nginx caching
Nginx cachingNginx caching
Nginx caching
 
Week10
Week10Week10
Week10
 
Week9
Week9Week9
Week9
 
Week7
Week7Week7
Week7
 
Week6
Week6Week6
Week6
 
Week5
Week5Week5
Week5
 
Week4
Week4Week4
Week4
 
Week3
Week3Week3
Week3
 
Week2
Week2Week2
Week2
 
Week1
Week1Week1
Week1
 
Fill Up your Bookshelves!
Fill Up your Bookshelves! Fill Up your Bookshelves!
Fill Up your Bookshelves!
 
Dealing with Legacy &lt;del>Code&lt;/del> People
Dealing with Legacy &lt;del>Code&lt;/del> PeopleDealing with Legacy &lt;del>Code&lt;/del> People
Dealing with Legacy &lt;del>Code&lt;/del> People
 
Whose Wife Are You?
Whose Wife Are You?Whose Wife Are You?
Whose Wife Are You?
 
RailsBrdige Seattle Workshop Intro
RailsBrdige Seattle Workshop IntroRailsBrdige Seattle Workshop Intro
RailsBrdige Seattle Workshop Intro
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

How I Learned to Smell Code

Notes de l'éditeur

  1. Hola, thank you for having me here today! I’m going to be telling you a story, my story. I hope you get something out of it, and if not I hope it amuses you.Before I tell you about myself, I’m going to ask you some questions. I know! Audience participation at a software conference, how awful of me! And just before lunch too! Don’t worry they are not questions about food!Also, everyone has heard the term “code smell before right?”
  2. Just for fun, how many of you are rock climbers?
  3. Like Rails! Especially ones that follow or teach us maintainable patterns and practices of ways to structure code.
  4. What is at the end of the Road? What’s the light at the end of the tunnel?I love descriptive analogies, especially ones that come with a picture of a dog!So which is it? I think I made this pretty obvious, but just in case.
  5. What is this? This is my story.I’m going to be telling you about my experiences with code, the Good, the Bad ,and the Goofy!This explains my questions. I was wondering who out there has a similar background to mine. I went to university for computer science, I worked as a business consultant doing custom development in the Microsoft stack, and now I work as the lead Ruby developer for Blue Box Group.I’ve worked with lots and lots of code of different varieties, and each of the three different places where I have written and had to maintained code I’ve learned something different about what makes for good code and what makes for bad code.Using my hound sniffing analogy, you can say my code sniffing ability grew with each step of my journey.
  6. At university I did a lot of java and C programmingThough we were using java to learn about objects, most of the code I wrote and learned from was procedural in nature and had lots of conditionals:A situation I like to refer to as if-else-death.Working with teams was vile,Tests were unheard ofAnd I rarely every looked at code that was quote ”finished” – ie: code for a completed assignment (in fact I had trouble finding code from that time to make this awful picture of java code for this talk)So with my dog analogy: a dog with a refined sniffer at this point would look at my code and need a gas mask….
  7. So what did I learn about code from University?Of course I learned the basics: how to solve a programming problem (don’t underestimate this!)&lt;Read 1st bullet&gt;unless I interview with Google (linked list, Back-Tracking Search, Bubble Sort,etc…)I did ACM competitions, Top Coder competitions, etc…I certainly got skills from doing that, but they were not skills about how to create maintainable, and/or scalable, applications.I was a CS TA for 3 years, and found teaching to be the best way for me to learn myself.(Not really anymore…)I really loved javadoc when I got out of school, I thought that was the best and only way to document code! How awesome is that, something creates docs right from your comments!HAHA ok enough with the java already! This is a RoRconf!
  8. So what am I going to talk about next? C#... As a consultant, one of my favorite projects was building a financial forecasting system for a very large organization from scratch in C# .Net. It was a service oriented web application that was going to save all of their financial analysts tons and tons of time. We used the Windows Workflow Foundation framework for structuring the app. Anyone familiar with the WWF? Hehe I like to refer to that acronym because it’s reference to the world wrestling federation is appropriate – It’s a big show, and very few people get hurt.We had lots and lots and lots of code.But it wasn’t horrible code, it was very, very structured code. Everything with a similar purpose was grouped together, you knew where to look for a particular action, naming conventions and code patterns for methods were strictly enforced…. Even when they didn’t really make sense…..Our hound in this picture is just sneezing, he’s not terribly sick, but this somewhat nicely patterned behemoth of code never actually went into production… Also, our “test suite” was actually a team of testers with scripts they would run through any time the app changed. That is pretty typical big corporation waste from what I have seen.
  9. So What did I learn about code here?Consistently adhering to patterns makes code written by different team members separately adhere together nicely.I certainly learned about single responsibility and abstractions, but there were patterns beaten into me that never really clicked:Always make your if statements positive, and you must always have an else when there is an if. What? Why?Well now I can say I understand that if you have an if, you are branching your code, and putting the else there makes that other branch explicit, therefore giving someone who comes after more information about what your code does.I can see the argument, but I would say now get rid of the branch and use polymorphism – objects are your friends!!!But again, this wasn’t Ruby, the framework wasn’t Rails, and this was enterprise level business practices – a much more restrictive environment than most of us in the RoR community work in.
  10. So what was next?Ruby! Rails! Legacy Code?Best way to understand OO design principles is to work with code that doesn’t follow any. But it’s a rails app, it has MVC structure and separation of concerns at those layers, right?The model I’ve excerpted here has 2,533 linesThe dog in this picture says it all….So what do you do? This is production code, that the business and the customers depend on. There are bugs. (Did I really need to say that?) but really there are bugs that need fixing and feature requests that need implementation. You gotta deal with it, you gotta do it – That’s how I learned to smell code.
  11. make sure there are tests! – Get the business requirements (AGAIN) from the end user – if it works in production that does not mean “don’t change it”, that means “Good the end users know the business process, and we can easily re-capture what this cluster is trying to do, and re-do it better”.
  12. All of my first code looks like C#, because that’s the last language I knew, and there weren’t any good patterns to follow.I fought with Rails about how it structures data – I’m a db girl, who all of a sudden isn’t supposed to worry about the database anymore….When I found myself writing just as nasty (in terms of maintainability) code I looked for help.
  13. Rails patterns are getting better and better:Coffee Script – makes our js less smelly – and there will be emerging new patterns here for maintaining all the gobs of client side code we are all writing
  14. I talked about patterns to follow – here I’m talking about not following a pattern – when you follow an anti-pattern you will learn something – work with someone else who has a different pattern and learn together with them.The least smelly programmers are pair-programmers
  15. If you have never seen the anit-patterns or code-smells talked about here, they may not click, but then re-read it. This is a reference manual, not a one-time-read.
  16. Same idea here – this book is mentioned in Clean Code – read all the books in clean code’s bibliography – I have not gotten through all of them yet.
  17. Lastly – pick up a hobby – you learn really cool things about what you do everyday when you do something else.From Rock climbing I’ve learned this about OO design patterns:It’s like learning to belay – you learn, you become a good belayer, It becomes muscle memory, but you don’t really get it, until one day it clicks – you’ve caught lots of falls, you’ve both lead climbed and caught a leader fall – you get how the system works and why the pattern / the rules you follow are there. That is when you can evolve and modify the system. You know when to follow the pattern and when to improvise. Do this with your code and help others do it – follow a couple good design patterns, make them muscle memory, and one day it will click, and then you can evolve your own patterns that will push the field forward. – If you’ve followed lots of good patterns, you will know how to make a good new one.
  18. Not everyone has the same experiences you do, sometimes you need to write a bit of C# in ruby to figure out that ruby shouldn’t be written that way.I’ve found that these three things that are about learning and flexibility are more important to creating scentless code than anything else.For # 4 : It’s my pet peeve – I’m allowed one soap-box per talk, and this is it.every point in Chapter 17 (smells and heuristics) that is made about comments is 100% true. I’ve seen all of them, I’ve done a number of those things with comments myself. JUST STOP! Make your code document itself, no one who comes after you, who changes what your code does, will update your comments, but they will update your names and method signatures. And trust your source control – use Git for your comments – it’s a much better place for them. All of us think about the appropriate place for our code to go, think about the appropriate place for your comments.