ALTERNATE UNIVERSE DEV

CodingBlocks

Episode 56 – Clean Code – How to Build Maintainable Systems

We’re back with another deep dive into the infamous book Clean Code by Uncle Bob as Joe alters columns, Michael misreads things, and Allen has a positive customer service experience.

Care to join in on the conversation? Become a member of our Slack community by signing up at http://www.codingblocks.net/slack.

Viewing these show notes through your podcast player? For the full show notes, visit: http://www.codingblocks.net/episode56.

Survey

The week’s survey: Why did you start programming?

#yop-poll-container-33_yp58cf5c30163af { width: 1000; background:#fff; padding:10px; color:#555; overflow:hidden; font-size:12px; } #yop-poll-container-33_yp58cf5c30163af input[type='text'] { margin:0px 0px 5px 0px; padding:2%; width:96%; text-indent:2%; font-size:12px; } .yop-poll-name-33_yp58cf5c30163af { font-weight:bold; background:#327BD6; color:#fff; padding:5px; text-align:center; font-size:12px; } #yop-poll-questions-container-33_yp58cf5c30163af { font-size:14px; margin:5px 0px; } .yop-poll-question-container-33_yp58cf5c30163af { padding: 2px; } .yop-poll-question-33_yp58cf5c30163af { background:#327BD6; color:#fff; margin-bottom: 21px; margin-top: -10px; font-style: italic; text-align: center; width: 100%; padding:5px; } .yop-poll-answers-33_yp58cf5c30163af { } .yop-poll-answers-33_yp58cf5c30163af ul { list-style: none outside none; margin: 0; padding: 0; } .yop-poll-li-answer-33_yp58cf5c30163af { font-style:normal; margin:0px 0px 10px 0px; padding:0px; font-size:12px; margin-bottom:20px; } .yop-poll-li-answer-33_yp58cf5c30163af input { margin:0px; float:none; } .yop-poll-li-answer-33_yp58cf5c30163af label { margin:0px; font-style:normal; font-weight:normal; font-size:12px; float:none; } .yop-poll-results-33_yp58cf5c30163af { font-size: 12px; font-style: italic; font-weight: normal; margin-left: 15px; } .yop-poll-customs-33_yp58cf5c30163af { } .yop-poll-customs-33_yp58cf5c30163af ul { list-style: none outside none; margin: 0; padding: 0; } .yop-poll-li-custom-33_yp58cf5c30163af { padding:0px; margin:0px; font-size:14px; } /* Start CAPTCHA div style*/ #yop-poll-captcha-input-div-33_yp58cf5c30163af { margin-top:5px; } #yop-poll-captcha-helpers-div-33_yp58cf5c30163af { width:30px; float:left; margin-left:5px; height:0px; } #yop-poll-captcha-helpers-div-33_yp58cf5c30163af img { margin-bottom:2px; } #yop-poll-captcha-image-div-33_yp58cf5c30163af { margin-bottom:5px; } #yop_poll_captcha_image_33_yp58cf5c30163af { float:left; } /* End CAPTCHA div style*/ .yop-poll-clear-33_yp58cf5c30163af { clear:both; } #yop-poll-vote-33_yp58cf5c30163af { } /* Start Result bar*/ .yop-poll-results-bar-33_yp58cf5c30163af { background:#f5f5f5; height:10px; } .yop-poll-results-bar-33_yp58cf5c30163af div { background:#555; height:10px; } /* End Result bar*/ /* Start Vote Button*/ #yop-poll-vote-33_yp58cf5c30163af div#yop-poll-vote-33_yp58cf5c30163af button { float:left; } #yop-poll-vote-33_yp58cf5c30163af div#yop-poll-results-33_yp58cf5c30163af { float: right; margin-bottom: 20px; margin-top: -20px; width: auto; } #yop-poll-vote-33_yp58cf5c30163af div#yop-poll-results-33_yp58cf5c30163af a { color:#fff; text-decoration:underline; font-size:12px; } #yop-poll-vote-33_yp58cf5c30163af div#yop-poll-back-33_yp58cf5c30163af a { color:#555; text-decoration:underline; font-size:12px; } #yop-poll-vote-33_yp58cf5c30163af div#yop-poll-archive-33_yp58cf5c30163af a { color:#555; text-decoration:underline; font-size:12px; } #yop-poll-vote-33_yp58cf5c30163af div { float:left; width:100%; } /* End Vote Button*/ /* Start Messages*/ #yop-poll-container-error-33_yp58cf5c30163af { font-size:12px; font-style:italic; color:red; text-transform:lowercase; margin-bottom:20px; text-align:center; } #yop-poll-container-success-33_yp58cf5c30163af { font-size:12px; font-style:italic; color:green; margin-bottom:20px; text-align:center; } /* End Messages*/#yop-poll-container-33_yp58cf5c30163af img { max-width: 1000; } .yop-poll-forms-display{}
Why did you start programming?
  • Needed to fulfill a business need
  • Wanted to personalize my MySpace theme
  • Took a class in school and thought it was awesome
  • 2 make gamez!
  • I like getting paid to sit

News

  • Huge thanks to those that left us a review!
    • iTunes Reviews: Chuck O’Halloran, Haddoc67, mhender24, jeremyunderwood, runartrollet, ksklmiller, tuplesteve, JoeR8975, Compninja, Thomas Cooper CA, SWFMac, yvesmh, Diana
    • Stitcher Reviews: rionmonster, mhender24, Cpt_Coathanger, oopmichael, JKBob11, BrandonHartman, TerranZima, Matthew Lazarow, yetAnotherCleverNickname, SkyKrynn, NguTron
  • What’s the difference between a Code Technician and an Engineer
  • Programming is the New Blue Collar Job
  • Allen buys an Ecobee 3.
  • New version of GlyphFriend is available.
    • Joe and Allen are famous (GitHub)
  • Allen digs into the details of public variables vs public properties. Watch at YouTube.
  • Joe uses the Interface Segregation Principle to reduce his technical debt. Watch at YouTube.
  • Joe was on Productivity in Tech.
  • Requirements for dev laptops.

Stickers

Like stickers? Want some Coding Blocks stickers? Of course you do, who can blame you? Head to http://www.codingblocks.net/swag to learn about sending us a SASE to get some of the best stickers ever made.

Systems

“Complexity kills.” – Ray Ozzie

Separate your concerns with Dependency Injection

  • Separate constructing a system from using it
  • Just because it’s startup code, doesn’t mean you should abandon abstraction
  • Dependencies should be passed down from main…
  • Factories should create instances, not other classes
  • Gather your data, process your data, format your output
  • Consistency is good!

Dependency injection

  • Dependency injection – a class takes no steps to resolve its dependencies – it’s completely passive
  • “Dependency Injection, the application of Inversion of Control to dependency management”
  • IoC vs DI: http://stackoverflow.com/questions/6550700/inversion-of-control-vs-dependency-injection
  • Setter or constructor methods take care of the instance creation
  • Spring Framework for Java – objects are wired together in XML configurations
  • .NET DI Frameworks: Unity vs Ninject vs StructureMap
  • https://www.nuget.org/packages?q=dependency+injection
  • Most DI frameworks won’t construct an object until you need it – THIS IS HUGE – i.e. lazy initialization
  • Additionally, most frameworks allow for plugging in factories to help with the idea of lazy evaluation
  • The myth about getting it “right the first time”
  • Focus on today’s needs today. Refactor and expand for tomorrow’s needs tomorrow.
  • We should iterate on stories today, and do more in the future as they come along – TDD and clean code enable this

Manage Cross Cutting Concerns with AOP

  • Analogies of cities growing and the pains involved – parallel to software
  • You wouldn’t build a 6 lane highway through a tiny town
  • Cross cutting concerns (Wikipedia)
  • Aspect Oriented programming – and how it helps with cross-cutting concerns
  • “The real value of an AOP system is the ability to specify systemic behaviors in a concise and modular way”
  • Proxies aka wrappers – fairly complicated code (and hard to code cleanly) – and don’t provide system-wide execution points
  • Typically proxies are created by tooling
  • In Spring, you write business logic as POJO’s – plain old java objects
  • POJO’s focus ONLY on their domain – no dependencies on external domains
  • Interesting point made in the book – XML is typically hard to read and the conventions might be difficult to follow, but it’s still easier than reading proxy code and is usually preferred for that reason
  • “The power of separating concerns through aspect-like approaches can’t be overstated. If you can write your application’s domain logic using POJO’s, decoupled from any architecture concerns at the code level, then it is possible to truly test drive your architecture.”
  • Start with small, simple pieces and fulfill user stories – this does not mean to go into a project rudderless – but don’t do Big Design Up Front (BDUF) – too inflexible
    • Avoid BDUF.
  • “A good API should largely disappear from view most of the time” – allows you to focus on your core
    • What about REST?
  • If not, the constraints will inhibit the efficient delivery of value to the customer

Be quick or be dead, keep things ready and plan for change

  • In large systems, no one person can make all of the decisions.
  • Postpone decisions until the last possible moment
  • Don’t fall in love with standards or frameworks just because they exist – EJB2 as an example – focus on the core and use what makes sense
  • Domain Specific Languages – popular for the reason that business users can write / understand the language
  • Systems must be clean too – failing to do so can impact agility and tie you to the architecture
  • “Never forget to use the simplest thing that can possibly work”

Resources We Like

We’d be remiss if we didn’t include Clean Code as a Resource We Like.

Clean Code

Seriously, read this book!

Tip of the Week

Developer Confessions

So, there’s a recent Twitter trend that has been gaining notoriety where seasoned developers are confessing their sins. And we thought we’d throw out some of ours.

  • Michael habitually refers back to this Stack Overflow answer before undo a Git commit.
  • Long ago, Joe has previously stored credit card numbers in clear text. Gasp! And then he changed the column type from textual to numerical. Hilarity ensued.
  • Allen may have forgotten to add a WHERE clause to his UPDATE/DELETE SQL statements. Recently.

Developer confessions has been a popular topic within our Slack community as well.

Imagine having to pass a technical interview just to get into the country?!

Share with a Friend!

Want to do your friends a solid? Tell them about the show! You’ll be their hero for like a year or so, I think. They’ll probably owe you something big. It’s that big of a deal. So what are you waiting for? Get out there and tell them.

And, if you haven’t yet left us a review, we’d super, duper appreciate it if you would. We’ll even be your best friend if you do. Head over to http://www.codingblocks.net/review to make it happen!

Episode source