Coding Blocks Podcast
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

Talking about the short book "How to be a Programmer", which covers a huge spectrum of important topics for developers of all levels.

Direct download: coding-blocks-episode-038.mp3
Category:programming -- posted at: 12:36am EDT

Our Favorite Developer Tools for 2015

We wrapped up 2015 with another favorites of 2015.  This go around it's the tools that we feel are invaluable as developers.  This can be anything from hardware, to software or a service that we feel is integral in our daily needs as programmers.  

If you're on mobile, you can visit the show notes page for this episode by going here:
Episode 37 Show Notes

[yop_poll id="12"]

News and Random Discussions

Are static methods a cod / code smell?

Maybe we should go full on OO and use Microtypes?
http://www.michael-snell.com/2015/03/microtyping-in-java-revisited.html

Win the other pre-worn, gently broken in, gray T-Shirt!  Just leave a comment on this episode!

Nicholas wrote back in Ep. 21 - how is the renaming with ReSharper different than the refactoring option in Visual Studio?
http://www.codingblocks.net/podcast/episode-21-our-favorite-tools/#comment-1987021142

Our Favorite Tools

Individual Picks

Number 5 - Last but not least:
Allen: Simple Mind
Description: Mind mapping tool for getting your ideas out in a somewhat organized state.

Main Site: http://www.simpleapps.eu/simplemind/
Android (free): https://play.google.com/store/apps/details?id=com.modelmakertools.simplemindfree
Android (paid): https://play.google.com/store/apps/details?id=com.modelmakertools.simplemindpro
Apple iOS (free): https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=305727658&mt=8
Apple iOS (paid): https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=378174507&mt=8

Michael:  UBlock Origin
Description: An ad-blocking plugin for various browsers that allows your web experience to be much faster and less intrusive by ad-agencies.

Main Site: https://www.ublock.org/
Chrome Plugin: https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm?hl=en
Mozilla Plugin: https://addons.mozilla.org/en-us/firefox/addon/ublock-origin/
Apple iOS: https://itunes.apple.com/us/app/purify-blocker-fast-clutter/id1030156203?ls=1&mt=8

Joe: Gliphy
Description: Workflow diagrams, wireframes, mockups, etc., all online.  Integrates with Atlassian products extremely nicely for wikis, Jira tickets, etc.
Main Site: https://www.gliffy.com/

#4
Allen: Codecademy
Description: Learn how to code for FREE - Interactively!  HTML, CSS, Javascript, Ruby, Python, PHP and more.  Go there...now...

Main Site: https://www.codecademy.com/

Michael: .NET Fiddle
Description: Site that allows you to write your .NET code online in a web browser, similar to JSFiddle, execute and share your code

Main Site: https://dotnetfiddle.net/

Joe: Office 365
Description: There are several subscription options so you'd definitely want to make sure you're picking the one that's right for you.  For personal (one person) use, the cost is (currently either $69.99/year or $6.99/month and you get access to Microsoft Word, Excel, PowerPoint, OneNote, Outlook, Publisher and Access on PC / Mac plus one phone and a tablet.  For family use, you'd probably want to go with the "Home" plan as you get all the same perks as the "Personal" plan times 5 for just $9.99/month or $99.99/year.  So that means you get to install Office on up to 5 PCs or Macs, five tablets, and five phones.  And you also get 1TB of storage per user, for a total of 5TB of cloud storage.

Office 365 Personal (individual user): https://products.office.com/en-us/office-365-personal
Office 365 Home (for 5 users): https://products.office.com/en-us/office-365-home

#3
Allen: Netgear R7000 AC1900
Description: Rock solid, great performing wireless router.

Product Link: http://www.amazon.com/gp/product/B00F0DD0I6/?tag=codingblocks-20

Michael: Hours Tracker
Description: Especially useful for freelancers or consultants, this application allows you to track your hours worked with a ton of features: geofencing, tagging, switching projects, multiple rates, multiple clients.

Main Site: http://www.hourstrackerapp.com/
Apple iOS: https://itunes.apple.com/us/app/hourstracker-time-tracking/id336456412?mt=8&ign-mpt=uo%3D4
Android: https://play.google.com/store/apps/details?id=com.cribasoft.HoursTrackerFree.Android&hl=en

Joe: JQuery Injector
Description: Chrome plugin that allows you to interact programmatically with a web page - basically friendly hacking to achieve things that maybe weren't meant to be achieved.

Main Site: https://chrome.google.com/webstore/detail/jquery-injector/indebdooekgjhkncmgbkeopjebofdoid

#2
Allen: Snagit
Description: For both Mac and PC, this is an excellent utility for taking and marking up your screenshots with some easy to use tools and you can even record your screen which can be saved off in standard video formats that are easily shared.  NOTE: You cannot edit the videos as with a ScreenFlow or a Camtasia, but it's great for quick little recordings for how-to's or to demonstrate problems.

Main Site: https://www.techsmith.com/snagit.html

Michael: Briggs & Riley Verb Backpack
Description: Excellent laptop bag especially for those who travel a lot for their work.  It holds up remarkably well, comes with a Lifetime warranty and is attractive to boot.  This bag has a ton of features that are made to help expedite your trip through airports.

Product Link: http://www.amazon.com/Briggs-Riley-Advance-Backpack-Black/dp/B016JQUYMM/ref=sr_1_3?ie=UTF8&qid=1451846799&sr=8-3&keywords=briggs+and+riley+verb&tag=codingblocks-20
More Information: http://www.briggs-riley.com/shop/collections/verb/advance-backpack-1

Joe: FitBit
Description: Turn your fitness into a bit of a game to help you stay active.  If you've not heard of this company, you're probably living in a box, but Joe definitely stands behind this product as something that motivates him to get his daily activity in.

Product Link: http://www.amazon.com/Fitbit-Wireless-Activity-Sleep-Tracker/dp/B0095PZHPE/ref=sr_1_8?ie=UTF8&qid=1451847290&sr=8-8&keywords=fitbit&tag=codingblocks-20

#1 - Our top individual picks
Allen: MeteorJS
Description: An isomorphic approach to applications.  It's a full stack javascript application framework - write your Server, Client and Middleware in Javascript.  It's so quick and easy to get up and running that it's really not fair to compare it to any other "frameworks" out there.  It's done incredibly well.

Main Site: https://www.meteor.com/

Michael: WebStorm by JetBrains
Description: Web development IDE that has evolved incredibly well with the latest JavaScript frameworks.  It supports many of the latest frameworks, it's cross platform (PC, Mac and Linux), has a ton of useful development features and is relatively speedy.  Also, they've updated their buying options so it starts at $60/year for individuals and is well worth the price of entry.

Product Link: https://www.jetbrains.com/webstorm/

Joe: Spotify
Description: One of the many streaming music services around, but arguably one of the best.  They have a HUGE selection of music.  If you're a subscriber you get access to their higher bit-rate streams for the audiophiles at heart.  As a developer, is there anything more necessary than some tunes to help you tune out everything around you and make some killer progress on your task at hand?

Main Site: https://www.spotify.com/

Group Picks

Number 5: Gulp
Description: A Javascript tool made to enhance and automate your workflow.  Works by piping output to other tasks and is configured by writing simple code pipelines.  Not only that, but there is a rather large library of tasks written for Gulp that can allow you to do most of what you could possibly want.

Main Site: http://gulpjs.com/
Plugin Site: http://gulpjs.com/plugins/

Number 4: NUnit
Description: A unit testing framework for all .NET languages.  Originally a port from JUnit, but has since been rewritten specifically for the .NET framework.  Why we picked this over MSTest - simply put: parameterized tests.

Main Site: http://www.nunit.org/

Number 3: JSFiddle
Description: Similar to Michael's pick for dotnetfiddle, JSFiddle provides you a place online where you can write some Javascript in the browser and share that code with a URL that's created for you.  This is an excellent way to share examples or help others out with working examples of Javascript code.  One of the downsides of JSFiddle is the lack of ability to create multiple files which means it's difficult to show structure along with code samples.

Main Site: https://jsfiddle.net/

Number 2: The Book - Design Patterns: Elements of Reusable Object-Oriented Software 
Description: Still in its first printing, the book includes 23 of the classic design patterns with context as to what the uses are as well as clear code examples.

Product Link: http://www.codingblocks.net/get/gang-of-four-book

Our Consensus Top Pick: Slack
Description: Productivity enhancing as well as time wasting service, Slack is a means of communicating with teams of folks quickly and easily.  Not only is it a great chat platform, it has a ton of useful (and fun) plugins for enhancing your work environment.  An example would be the Visual Studio Online plugin where you can see when a particular branch of code has been updated.  

Main Site: https://slack.com

OUR Slack Channel!  https://codingblocks.slack.com/

Come Join in on the conversation!

Resources We Like

Beyond Legacy Code: Nine Practices to Extend the Life (and Value) of Your Software
Product Link: http://amzn.to/1JtdMzR

Tips for this Episode

Allen: ProgrammableWeb.com - Well known public API's for developers
http://www.programmableweb.com/apis/directory

Michael: Find your mouse - for those with too much monitor real estate!
Mac El Capitan - Just shake your mouse around and it shows up nice and big!
PC Windows - Go into your mouse properties in the control panel, and select "Show location of pointer when pressing the control key" - doing this will allow you to locate your mouse by clicking the control key and a ring will radiate from the mouse pointer.

ApexSQL Refactor - format your SQL within Management Studio for SQL Server
http://www.apexsql.com/sql_tools_refactor.aspx

Use the FORCESEEK Luke - Index hint for SQL Server Queries
https://technet.microsoft.com/en-us/library/bb510478(v=sql.105).aspx

Use the Index Luke - SQL Tips and Tricks
http://use-the-index-luke.com/

Joe: Indigo Studio by Infragistics - Rapid prototyping tool - Wireframing on steroids!
http://www.infragistics.com/products/indigo-studio

Has support for different resolutions so you can see how your app behaves.Also has really nice support for behaviors, swiping here navigates, or double clicking changes the page. Much better than getting psd! Also has a timeline so it’s easier to see the relationship between frames automatically
Alternatives:
http://www.justinmind.com/
http://www.axure.com/

Direct download: coding-blocks-episode-037.mp3
Category:tools -- posted at: 5:44pm EDT