Blog Home  Home Feed your aggregator (RSS 2.0)  
kevin Mocha - Thursday, June 04, 2009
Bookmarks collected from web.
 
 Thursday, June 04, 2009
 Wednesday, June 03, 2009
 Tuesday, June 02, 2009
Tuesday, June 02, 2009 6:05:49 PM UTC  #    Comments [0]    |   |  Trackback

(From http://mikehadlow.blogspot.com/2009/05/what-i-look-for-in-code-review.html)

 

I recently put this bullet point list together for the team I’m currently working with.

Naming Conventions

General Principles

  • The core imperative is to organise complexity.
  • Clarity and readability is central. “Intention Revealing”
  • Do not prematurely optimise for performance.
  • Do not repeat yourself. Never copy-and-paste code.
  • Decouple.
  • Always try to leave the code you work on in a better state than before you started (the ‘boy scout’ principle)

Keep the source clean

  • Always delete unused code. Including variables and using statements
  • Don’t comment out code, delete it. We have source control to manage change.

Naming things

  • The name should accurately describe what the thing does.
  • Do not use shortenings, only use well understood abbreviations.
  • If the name looks awkward, the code is probably awkward.

Namespaces

  • Namespaces should match the project name + path inside the project. This is what VS will give you by default.
  • Classes that together provide similar functions should be grouped in a single namespace.
  • Avoid namespace dependency cycles.

Variables

  • Use constants where possible. Avoid magic strings.
  • Use readonly where possible
  • Avoid many temporary variables.
  • Never use a single variable for two different puposes.
  • Keep scope as narrow as possible. (declaration close to use)

Methods

  • The name should accurately describe what the method does.
  • It should only do one thing.
  • It should be small (more than 10 lines of code is questionable).
  • The number of parameters should be small.
  • Public methods should validate all parameters.
  • Assert expectations and throw an appropriate error if invalid.
  • Avoid deep nesting of loops and conditionals. (Cyclomatic complexity).

Classes

  • The name should accurately describe what the class does.
  • Classes typically represent data or services, be clear which your class is.
  • Design your object oriented schema deliberately.
  • A class should be small.
  • A class should have one responsibility only.
  • A class should have a clear contract.
  • A class should be decoupled from its dependencies.
  • Favour composition over inheritance.
  • Avoid static classes and methods.
  • Make the class immutable if possible.

Interfaces

  • Rely on interfaces rather than concrete classes wherever possible.
  • An interface is a contract for interaction.
  • An interface should have a single purpose (ISP)

Tests

  • All code should have unit tests if possible.
  • Test code should have the same quality as production code.
  • Write code test-first wherever possible.

Error Handling

  • Only wrap code with a try..catch statement if you are expecting it to throw a specific exception.
  • Unexpected errors should only be handled at process boundaries.
  • Never ‘bury’ exceptions.
Tuesday, June 02, 2009 1:03:39 PM UTC  #    Comments [0]    |  Trackback
 Friday, May 29, 2009

http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/

2 new features

- Support for Collection of binding to commands
- Support for Light weight Commands or as I call them Action

Friday, May 29, 2009 2:56:55 PM UTC  #    Comments [0]    |  Trackback
 Thursday, May 28, 2009

http://wpfwonderland.wordpress.com/2007/08/11/mixing-external-mergeddictionaries-with-local-resources-in-appxaml/

Adding local application resources

Even though it is easy to add external resources it’s likely that you’ll want to have a style or other resource that you don’t intend to shared across applications.  You could isolated these resources within a single page (Page.Resources) or element (DockPanel.Resources)  But what if you want to add  them to <Application.Resources> tag?  You can do it as long as you know the correct location. They have to go between the </ResourceDictionary.MergedDictionaries> and </ResourceDictionary> tags.

    <Application.Resources>
      <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
          <ResourceDictionary Source="WorkshopHelpers/MainResources.xaml"/>
        </ResourceDictionary.MergedDictionaries>
        <!-- Place here...-->
        <Style TargetType="Rectangle" >
          <Setter Property="Width" Value="100"/>
          <Setter Property="Height" Value="80"/>
        </Style>
      </ResourceDictionary>
    </Application.Resources>
  </Application>

-Walt Ritscher

Thursday, May 28, 2009 5:25:41 PM UTC  #    Comments [0]    |  Trackback
  1: m_DispatcherTimer = new DispatcherTimer()
  2: {
  3: Interval = TimeSpan.FromSeconds(0.25),
  4: IsEnabled = true
  5: };
  6: 
  7: m_DispatcherTimer.Tick += delegate
  8: {
  9: CommandManager.InvalidateRequerySuggested();
 10: };
 11: 

http://robburke.net/2008/04/23/wpf-command-pattern-when-does-it-query-canexecute/

Thursday, May 28, 2009 5:47:02 AM UTC  #    Comments [0]    |  Trackback

http://blog.schuager.com/2009/01/line-count-in-visual-studio.html

Select Edit -> Find & Replace -> Find in files... or just press CTRL+SHIFT+F
Check Use and select Regular expressions.
Type the following as the text to find:

^~(:Wh@//.+)~(:Wh@\{:Wh@)~(:Wh@\}:Wh@)~(:Wh@/#).+
Select where you want to do the search/count: file, project or solution.
Thursday, May 28, 2009 2:14:18 AM UTC  #    Comments [0]    |  Trackback
 Tuesday, May 26, 2009
 Wednesday, May 13, 2009
 Tuesday, May 12, 2009
Copyright © 2010 Kevin Mocha. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: