Code review – be specific

self.UpdateMemberDetails = function( memberDetails) {

};

Code reviewer: “are you not following best practices?”

  • There is a sneer behind this comment.
  • Aims to put the reviewee into a defensive mode.
  • It does not describe what is wrong with this line of code; nor does it suggest a best practice to follow.
  • Reviewer obviously has a practice in mind.  But instead of talking about that practice, she moves on to the programmer’s habits, attitudes towards code.

What have I learnt about code reviews from this anti-pattern?

  • Avoid anything that insults or puts the reviewee into a defensive mode.
  • Describe what is wrong and suggest a specific solution, or two.
  • Do not make any assumptions or conjectures about the programmer’s attitude or skills.
  • Ask yourself: What value is my comment adding here?

Good examples,

 if (service.MemberLocation > 3 && service.IsActive && service.Amount > 0 && service.MemberServiceHistoryDetail.DueDate < dueDate)

Code Reviewer: Please format lengthy if-conditions by placing each term of the condition on a separate line.  The code that spills beyond the edge of the screen here is critical to the understanding of the business logic.  For example,

 if (service.MemberLocation > 3 &&
service.IsActive &&
service.Amount > 0 &&
service.MemberServiceHistoryDetail.DueDate < dueDate)

Advertisements

A bootcamp for architects

Curriculum

  • Computer science
    • Algorithms
    • Data structures
    • OS concepts and principles
    • Distributed processing
    • Network protocols
  • Design
    • Principles
    • Patterns
    • Framework design
    • ER modeling
  • Architecture
    • Structuring
    • Styles and patterns
      • SPA
      • Message oriented architecture
    • Performance engineering
    • Scalability engineering
    • Security engineering
    • Documenting architectures
    • Product line architecture
    • Model driven architecture
    • Component based architecture
    • ATAM – Arch. tradeoff analysis method
  • Infrastructure
    • Computer hardware
    • Clustering
    • Network
      • Load balancing
      • DNS
  • Software engineering
    • Estimation
    • SDLC – phase transition
    • Methods
    • Reuse
    • Building reference architectures
    • Conducting and reporting POCs
    • Code generation
  • Communications
    • Graphical notations
    • Documenting architecture
    • Identifying stakeholders
  • Management
    • Scheduling
    • Project planning
    • Monitoring
    • Designing org structures
    • Risk management
  • Technology
    • Mainstream programming languages
    • Scripting languages
    • Template engines
    • Databases – RDBMS & NoSQL
  • Platforms
    • Unix
    • Linux
    • Mobile
    • Web
    • .NET
    • Windows
  • New developments
    • Data science

Course design

  • Principles
  • Case studies
  • Examples

 

  • Assignments
  • Problems
  • Exercises
  • Assessment
    • Quizzes
    • Exams

 

 

Configuration – Outline

Introduction

  • The problem that it solves – or its importance or value of configuration
  • Important but is neglected
  • Configuration hell

Features

  • Simple scenarios: key=value pairs (untyped)
  • Store and retrieve typed values
    • Primitives (int, date, etc)
    • Complex types (POJOs or POCOs)
    • Arrays
    • Maps
  • Inheritance and hierarchy
  • Expressiveness (DSLs)
  • Management
    • Dynamically specify configuration to use at runtime
    • Include other config
    • Centralization of configuration
    • Organization
    • Documentation – single and multi-line comments
    • Versioning
    • Abstract configuration sources or media
    • Persistence of modified configuration
    • Detection of changes and dynamic reloading

Examples of configuration

  • Unix/Linux .rc files (or scripts?)
  • Apache
  • Sendmail
  • ini
  • XML
  • Windows Registry
  • Apache or squid config

Storage

  • Settings or property files
  • XML files
  • database
  • App.config and Web.config
  • JNDI

Trends

  • Convention over configuration
  • Fluent vs XML configuration
  • Service Locators and registries
  • Configuration worksheet

Holy wars

  • File vs database
  • Configuring end user applications vs systems applications
  • Configuration files vs DSLs

Misc topics

  • Deployment and configuration
  • Re-loading config files
  • Abstracting configuration sources
  • IOC containers and configuration
  • Configuring the shell environment

Configuration Frameworks

  • Nini
  • .NET – System.Configuration
  • java
    • java.utils.properties
    • Commons.Configuration
  • IOC containers
    • Spring – org.springframework.beans and org.springframework.context
    • Unity
  • XML serialization
    • Java: org.simpleframework.xml

 

Configuration – bibliography

 

[Off topic]

http://stackoverflow.com/questions/70689/what-is-an-efficient-way-to-implement-a-singleton-pattern-in-java?rq=1

http://stackoverflow.com/questions/137975/what-is-so-bad-about-singletons?rq=1

 

hand-roll a configuration

From the Jargon File – hand-roll:

To perform a normally automated software installation or configuration process by hand; implies that the normal process failed due to bugs in the configurator or was defeated by something exceptional in the local environment. “The worst thing about being a gateway between four different nets is having to hand-roll a new sendmail configuration every time any of them upgrades.”