Coding Blocks Podcast

We continue talking our way through Clean Code, taking a deep look at the building blocks of programming in the quest to write the best functions. Oh, and everybody sings.

The original version of the show notes can be found at:
http://www.codingblocks.net/episode48

Direct download: coding-blocks-episode-048.mp3
Category:programming -- posted at: 8:40pm EDT

Clean Code - Writing Meaningful Names

In this episode, we take our first dive into the book Clean Code by Robert Martin and specifically we talk about writing meaningful names for all things code related.  You'll be amazed at how following some decent rules that you can start naming things that will help you and fellow coders understand your code at a glance.

Clean Code - Writing Meaningful Names

You can see the original show notes and put your own stamp on our survey here:
http://www.codingblocks.net/episode47

News

Samsung 960 Pro
http://www.anandtech.com/show/10698/samsung-announces-960-pro-and-960-evo-m2-pcie-ssds

SQL Server 2016 Columnstore for real time operational analytics
https://msdn.microsoft.com/en-us/library/dn817827.aspx

Krebs site taken off Akamai
http://www.zdnet.com/article/krebs-on-security-booted-off-akamai-network-after-ddos-attack-proves-pricey/

The best Android distribution is iOS?
Outlaw’s thoughts on various phone OS’s

Survey

[yop_poll id="23"]

Meaningful Names - Clean Code Chapter 2

“If a name requires a comment, then the name does not reveal its intent”

  • Write explicit code - naming variables and methods can reveal the entire intent of the code
  • Avoid using words that would be confusing like “List” as they refer to programming types and could be misleading : accountList should be accounts
  • Avoid using characters that look like numbers i and L or capital o
  • disinformative vs noninformative
    • noise words “data” “info” - noninformative
  • Types should almost never be in a name “table” “string” “object”
  • Names should be distinguished so a user can look at them and understand the differences
  • Use pronounceable names
  • Use searcheable names - longer names trump shorter names
  • Author’s pref - single letter names should only be used as local variables inside small methods - length of the name should correspond to the size of its scope
  • Avoid encoding names
  • Avoid Hungarian Notation with typing as part of the variable name - simply not needed nowadays
  • Stop prefixing member (instance) variables with m_ or _
  • Decorating Interfaces vs Classes with a prefix / suffix - opinion - he prefers
    • ClassImp or vs IType
  • Don’t force someone to map variable names in their mind - n = username…smart programmer vs professional programmer - clarity is king
  • Class names should be nouns - English 101 - NOT VERBS
  • Method names should be verbs
  • Use get, set, is - javabean standard
  • When constructors are overloaded, use static factory methods with explicit names - liked this one, possibly make the constructors private
  • Don’t get cute with naming by means of jokes (inside or well known)
  • Use consistent naming - Get, Set, Controller - makes it easier to understand and code various parts of an application
  • Avoid puns - add for a collection vs add for setting a value - two different meanings with the same name
  • Use technical names such as pattern names or CS terms in your names - other programmers will understand them better than the problem domain in some cases
  • Fall back to the problem domain for a name if there is no suitable technical name
  • Adding context to naming can clarify their use - prefixes can work but putting variables into classes may work out better

“Hardest thing about choosing good names is that it requires good descriptive skills and a shared cultural background”

Renaming things that don’t make sense as you work in code is a good thing.

Resources we Like

Clean Code

Clean Code by Robert C. Martin

Even though we’re giving our thoughts on the various ideas throughout the book, Clean Code has tons of excellent sample code that really helps drive the points home. We can’t recommend it enough - it’s probably one of the few books EVERY developer should read and revisit from time to time.
http://amzn.to/2cryvJR

Tip of the Week

Allen: Implementing OAuth in ASP.NET for a number of providers
http://www.oauthforaspnet.com/

Michael: Get out there! Go to conferences, meetups, do it all!
http://www.connect.tech/
https://www.atlantacodecamp.com/2016

Direct download: coding-blocks-episode-047-mono.mp3
Category:general -- posted at: 10:05pm EDT

Storing smaller subsets of data in a faster, closer memory can make astronomical differences in performance. This episode we're talking about the caching tools and techniques that application frameworks provide.

The original version of the shownotes can be found at:
http://www.codingblocks.net/episode46

Direct download: coding-blocks-episode-046.mp3
Category:Software Development -- posted at: 10:42pm EDT

Caching Overview and Hardware

In this episode we give a general overview of caching, where it's used, why it's used, and what the differences in hardware implementations mean in terms we can understand.  This will be foundational to understanding caching at a software level in an upcoming episode.  There's also something about the number 37 that may be the most important number to remember...ever...

Podcast News

You can see all the show notes in their original form by visiting:
http://www.codingblocks.net/episode45

Thanks for your patience, we had a couple of rough audio situations - and we appreciate you sticking with us!

iTunes Reviews
Hedgehog, Thiagoramos.ai, Btn1992, Jonajonlee, UndeadCodemonkey, zmckinnon, hillsidecruzr, Dibjibjub, ddurose

Stitcher Reviews
pchtsp, rafaelh, CK142, TheMiddleMan124, LocalJoost

Clean Code episodes coming soon + book giveaway - Stay Tuned!

Caching: Turtles all the way down

Turtles all the way down???
https://en.wikipedia.org/wiki/Turtles_all_the_way_down

  • Storing a subset of information for faster retrieval
  • The hit ratio dramatically increases as the cache size increases
  • Think about a simple web request…
  • Browser cache
  • DNS cache
  • ISP caching
  • CDN
  • Whatever your application is doing (redis, framework, database, etc)
  • PLUS whatever the various computers are doing

Why don’t we cache everything?

  • Fast is expensive!
  • Cache Invalidation is hard!

Caching at the hardware level

Interactive Cache Visualization
Interactive Cache Visualization

Latency Numbers Every Programmer Should Know
https://gist.github.com/jboner/2841832

Relative Memory Access Interactive Demo
http://www.overbyte.com.au/misc/Lesson3/CacheFun.html

Caching is a strategy that computers use going all the way down to the processor

L1

  • .5ns
  • As quick as a it gets, how long it takes light to travel 6"
  • Managed by the CPU itself, no assembly available!

L2

  • 7ns
  • 14 x slower than L1
  • L3 / L4 / Scratch etc

Main Memory

  • Have numbers for a “reference” and a 1mb sequential read
  • 100ns - 250,000ns
  • 14 - 35,714 x slower than L2
  • 200 - 500,000 x slower than L1

Network

  • Sending is quick, there are numbers for that
  • In general, a lot of variability here
    Same datacenter
  • 500,000 ns
  • 2 x slower than Main Memory
  • 1 million times slower than L1

SSD

  • Wait, network faster than the hd??? Yes, but no
  • 1mb sequential
  • 1 million ns
  • 2 x slower than Network
  • 2 million x slower than L1

Spinning Disk

  • Get your employer to get you an ssd!
  • 1mb sequential read
  • 20 million ns
  • 20 x slower than SSD
  • 40 million x slower than L1

Internet

  • Rough gauge of internet speeds
  • Highly variable (CDN + ISP caching, for example), but gives you a sense of scale
  • 150 million ns
  • 7.5 x slower than spinning disk
  • 300 million times slower than L1

In more relatable terms.

  • 1 second for L1 Cache
  • 5 days for memory
  • 11 days for data center
  • 23 days for SSD
  • 15 months for HD
  • Almost 10 years for internet!

Think about how those numbers cache

  • RAM / Application cache
  • Local Hard drive
  • Network storage
  • Cache Server
  • DB

Summary

Hope we gave you a good idea of the importance and scale of caching in computing at the hardware level

Things we didn’t talk about coming in a future episode:

  • Application / Software caching and caching algorithms

Resources we Like

Latency Numbers Every Programmer Should Know
https://gist.github.com/jboner/2841832

How L1 and L2 caching work
http://www.extremetech.com/extreme/188776-how-l1-and-l2-cpu-caches-work-and-why-theyre-an-essential-part-of-modern-chips

Relative Memory Access Interactive Demo
http://www.overbyte.com.au/misc/Lesson3/CacheFun.html

Miscellaneous

Michael’s Favorite Meetup Ever
The Atlanta JavaScript Meetup
http://www.meetup.com/AtlantaJavaScript/events/222696324/?a=cr1_grp&rv=cr1

Hacking Interviews with:
Nick Larsen - http://cultureofdevelopment.com/
Sam Lawrence - http://www.samelawrence.com/

Tip of the Week

Algorithms to Live By
Algorithms to Live By

Joe: Algorithms to Live By
There's something about the number 37%...
http://amzn.to/2aX1iJk

Michael: Use Sublime to replace \n with an actual new line by turning on RegEx search and replace. Or in Michael’s case, replace
with actual \n\t characters.
http://stackoverflow.com/questions/20515670/replace-n-with-actual-new-line-in-sublime-text

Allen: Collaborative Markdown Editor - What?!
http://www.hackmd.io

 

Direct download: coding-blocks-episode-045.mp3
Category:general -- posted at: 12:39am EDT

This week on Coding Blocks, Allen says www as best he can, Joe eats the microphone, and Michael does something crazy as we discuss Stack Overflow's Salary Calculator and our experiences in landing the job - what to do and what not to do.

Direct download: coding-blocks-episode-44.mp3
Category:general -- posted at: 1:09am EDT

This time we're talking about problems with nulls, stored procedures, and impostor syndrome.

Link to Episode 43’s Full Show Notes:
http://www.codingblocks.net/episode43

Direct download: coding-blocks-episode-043.mp3
Category:general -- posted at: 8:03pm EDT

Command, Repository and Mediator Design Patterns

In this episode we go back to the design pattern well that we've been away from for so long.  We cover the Command, Repository and Mediator design patterns.  It was hard for us to believe, but it's been almost a year since our last design patterns episode!!!  Come on in for fun, learning, and of course, our tips of the week.

See the original show notes at:
http://www.codingblocks.net/epsiode42

Leave us a review here:
http://www.codingblocks.net/review

News

Stitcher Reviews:

Spectre013, Christoffer, Genius, HAM3rtag, joe_recursion_joe, Gearhead2k, Manriquey2k, Mike North, AndrewM, MildManneredCalvin, Freeleeks

iTunes Reviews:

Sid Savara, J. Mair, tonicorb, Nmkel999, Eschwartz20, mochadwi, Banjammin, wisco_cmo, NewZeroRiot, Nate_the_DBA, Pauloispaulo

Joe’s chess game!

Joe on Hello Tech Pros

Software Engineering Radio #256 on Unit Testing

!important is a CSS code smell.

Do you name your IIFEs? You should.

This is our 5th, Design Patterns Episode. Last one was in July 2015.

30: Adapter, Facade, and Memento
19: Iterators, Observers, and Chains
16: Strategy, Template, Null Object
11: Factories, Factory Methods, Builder, Prototype

What type of development do you prefer?

Front-End
Back-End
Full Stack

Design Patterns - Command, Repository, and Mediator

Command Pattern

  • Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undo.
  • It's not "method()" it's "new Object(), and later...object.invoke()
  • Why? Nice, clean way of organizing your code. Especially if….
  • OO replacement for callbacks - meh
    • Specify, queue, execute
    • Undo
    • Transactions/Logging
    • Not mentioned:
      • Macros
      • Async
  • Real World Applications
    • GUI/Menus - copy/paste/undo/photoshop
    • Video Games
      • Age of Empires sent commands rather than the game state!
      • It’s not if("B") { jump(); }, if(input[k]) { input[k].invoke() }
        • Great for different contexts, like menus
    • Parallel / Tasks
      • Async/Await
    • Queues / Multi-Step Wizards
      • Queue up the commands, execute all at once
    • Restaurants????
  • How it’s done:
    • Client: Customer
    • Receiver: Waiter
    • I/Command: Order
    • Invoker: Cook
  • Great example on sourcemaking.com
  • What about callbacks?
  • Why not the observer pattern?
  • Challenge for the listeners, program the command pattern - do it “by the book”

Repository Pattern

Why?

  • Testable with isolated data layer
  • Centrally managed access rules and logic
  • Centralized caching strategy
  • Allows you to separate business logic from data access logic
  • Strongly typed entities
  • Business entity associations
  • Can apply a domain model to simplify business logic
  • Decouple business entity from data storage technology - the repository doesn’t expose where it gets its data

What?

  • Sits between the data source and the business layer
    • Maps data from the data source to an entity
    • Persists changes from the entity back to the data source
      • Can use the Unit of Work pattern for complex, multi-step operations
    • Typically utilizes a Data Mapper Pattern, or an ORM such as Entity Framework in .NET

Mediator Pattern

What is it?

  • The mediator pattern defines an object that encapsulates how a set of objects interact
  • Promotes loose coupling by keeping objects from referring to each other explicitly
  • Promotes the Single Responsibility Principle by allowing communication to be offloaded to a class that handles just that.
  • Similar to the Observer pattern
    • Mediator pattern can be implemented during the observer pattern,
    • The Observer pattern distributes communication by introducing “observer” and “subject” objects.
  • Also similar to the Facade pattern in that it abstracts functionality of the classes.

Examples

  • Chat room
  • Air Traffic Control
  • Button events?

Resources We Like

http://gameprogrammingpatterns.com/
https://msdn.microsoft.com/en-us/library/ff649690.aspx?f=255&MSPPError=-2147217396
https://genericunitofworkandrepositories.codeplex.com/
http://blog.falafel.com/implement-step-step-generic-repository-pattern-c/
http://www.gamasutra.com/view/feature/131503/1500_archers_on_a_288_network_.php
https://sourcemaking.com/design_patterns/command
https://sourcemaking.com/design-patterns-book
http://www.codeproject.com/Articles/526874/Repository-pattern-done-right
https://en.wikipedia.org/wiki/Mediator_pattern
https://sourcemaking.com/design_patterns/mediator
http://programmers.stackexchange.com/questions/134432/mediator-vs-observer

Tips of this Episode

Allen:

Want a JavaScript tip per day?!
http://www.jstips.co/

Bonus!!!  Want tons of cheap stuff?!
App called "Geek" - download it on iOS or Android

Michael:

Use Nunit's TestCaseSource to test objects in your test cases

How to delete/forget about a wireless network in Win8.1

  • netsh wlan show profiles
  • netsh wlan delete profile name="gogoinflight"

SOURCE: http://www.digitalcitizen.life/how-delete-forget-wireless-network-profiles-windows-81

Joe:

Learn a new language! Stretch the brain, learn new concepts and see old concepts in a new light! Scripting, Compiled, Functional - Conway’s Game of Life!

Direct download: coding-blocks-episode-042.mp3
Category:programming -- posted at: 11:49pm EDT

This week on Coding Blocks, Joe changes a different kind of string, Allen drools over the Hellcat, and Michael shares his random thoughts. We span a collection of topics including GraphQL framework envy, bash on Windows, and whether it takes two to Django.

Direct download: coding-blocks-episode-41.mp3
Category:general -- posted at: 10:23pm EDT

Are you an Advanced Programmer? We dig into the final section of Robert Read’s fantastic writing: How to be a programmer. Also, how to cheat at Jira, a lazy butcher and if learning web development is worth it.

Link to Episode 40’s Full Show Notes
http://www.codingblocks.net/episode40

Direct download: coding-blocks-episode-040.mp3
Category:Software Development -- posted at: 9:33pm EDT

How to be an Intermediate Programmer

Link to Episode 39's Full Show Notes
http://www.codingblocks.net/episode39

T-Shirt Giveaway - The winner is...
Manrique Logan - please contact us to send us your ship-to information!

This Episode's Survey
Suggested by: https://twitter.com/CatcheNameHere/status/700507429390274560

Princess rap battle: GALADRIEL vs LEIA
https://www.youtube.com/watch?v=RL52R7m8b7w

How to be an Intermediate Programmer

Personal Skills

Team Skills

Judgement

Resources We Like

How to be a Programmer: A Short, Comprehensive, and Personal Summary by Robert L Read
Make a Pull Request to get your thoughts in here:
https://github.com/RobertLRead/HowToBeAProgrammer
Or buy your copy here from Amazon:
http://amzn.to/1WzbIxs

Succinctness is Power - Paul Graham
http://www.paulgraham.com/power.html

You Don't Know JS
https://github.com/getify/You-Dont-Know-JS/blob/master/README.md

Want to know how fast you type?
http://www.typingtest.com/

Allen's Typing Speed on the Microsoft Sculpt Ergonomic

Microsoft Sculpt Ergonomic Keyboard
Microsoft Sculpt Ergonomic Keyboard

http://www.typingtest.com/result.html?acc=100&nwpm=90&gwpm=90&ncpm=452&gcpm=452&dur=60&time=60&chksum=45213&unit=wpm&kh=998&td=null&err=0&hits=452

specflow - Binding business requirements to .NET code
http://www.specflow.org/

 

Tips for this Episode

Allen Underwood: Execution plan for a running query in Microsoft SQL Server
Preface: You can click a button in Microsoft SQL Server Management Studio (SSMS) to see the execution plan of a query to identify any performance problems.  The biggest issue with this is that if there's a query that NEVER returns, or takes an insanely long time to return, then you're stuck waiting for the query to finish.  This tip shows you how to find the ACTUAL (not estimated) query plan of the query that is actively running:

How To:

EXEC sp_who2 'active' -- Find the SPID of the query you're running

DECLARE @spid INT = 123 -- From above

SELECT EQP.query_plan, *
FROM sys.dm_exec_requests AS ER
   CROSS APPLY sys.dm_exec_query_plan(ER.plan_handle) AS EQP
WHERE ER.session_id = @spid

Once that bottom query runs, you'll be provided a link in the results grid that you can click to open up the graphical execution plan.

Michael Outlaw: Have Git ignore changes you make to a specific file like you didn't make the changes, but still have it be part of the tracked files in Git.
Preface: Let's say you have a connection string configuration file that you change to point to your local database.  That config file needs to be tracked in Git, but you don't want your changes to accidentally get committed and pushed up to the remote repo, then this command is for you.

How To:

git update-index /path/to/file --assume-unchanged

Joe Zack: Life Tip -  Pay attention to the warnings in your IDE.  It's easy to get used to seeing several warnings and ignoring them because they're not errors.  Eventually a new one that actually matters will show up and by ignoring it, you could be creating heartache for yourself.  If you can, resolve the warnings that are currently showing up so that if a new one surfaces, it'll jump out at you like a sore thumb.

Direct download: coding-blocks-episode-039.mp3
Category:programming -- posted at: 5:29pm EDT