You are on page 1of 28

A Whirlwind Tour of

Software Development Fundamentals


Steve Smith
http://SteveSmithBlog.com | @ardalis | The Code Project
Software Fundamentals
• Principles

• Patterns

• Practices
Core Principles
• Don’t Repeat Yourself
• Single Responsibility Principle
• Open / Closed Principle
• Liskov Substitution Principle
• Interface Segregation Principle
• Dependency Inversion Principle
Don’t Don’t Repeat Repeat
• Duplication in logic calls for abstraction.

• Duplication in process calls for automation.


Single Responsibility Principle
The Single Responsibility Principle states that every
object should have a single responsibility, and that
responsibility should be entirely encapsulated by the
class.
Wikipedia

There should never be more than one reason for a


class to change.
Robert C. “Uncle Bob” Martin
Example Responsibilities
• Persistence
• Validation
• Notification
• Error Handling
• Logging
• Class Selection / Construction
• Formatting
• Parsing
• Mapping
Open / Closed Principle
The Open / Closed Principle states that software
entities (classes, modules, functions, etc.)
should be open for extension, but closed for
modification.
Wikipedia
Open / Closed Principle
Open to Extension
New behavior can be added in the future

Closed to Modification
Changes to source or binary code are not required

Dr. Bertrand Meyer originated the OCP term in his 1988 book,
Object Oriented Software Construction
Liskov Substitution Principle
The Liskov Substitution Principle states that
Subtypes must be substitutable for their base
types.
Agile Principles, Patterns, and Practices in C#

Named for Barbara Liskov, who first described


the principle in 1988.
Interface Segregation Principle
The Interface Segregation Principle states that Clients
should not be forced to depend on methods they do
not use.
Agile Principles, Patterns, and Practices in C#

Corollary:
Prefer small, cohesive interfaces to “fat” interfaces
Dependency Inversion Principle
• Depend on Abstractions
– Interfaces, not concrete types

• Inject Dependencies into Classes

• Structure Solution so Dependencies Flow


Toward Core
– Onion Architecture
Patterns
• Strategy
• Adapter
• Command
• Template Method
• Repository
• MVC | MVP | MVVM
Strategy Pattern
• Inject Dependencies
• Abstract out rules or decisions
• Make your classes honest about their
dependencies
• Composition solution to OCP problem

public class CustomerRepository(IPersistenceLayer persistenceLayer)


{

}
Adapter Pattern
• Breaks Dependencies
• Your class depends on an adapter interface
– In turn, each concrete adapter depends on a
particular implementation
• Future proofs your application
– New implementations simply require new
adapters to be written
Command Pattern
• Great for Workflow and Finite State Machines

State State

State

Stateis a separate Command


• Each arrow State
implementation
Template Method
• Inheritance solution to OCP problem

• For classes that perform several steps, but not


always in the same way

• May provide greater reuse than Strategy,


which requires full implementation to be
written
Repository Pattern
• A common data access pattern
• Allow persistence to be hidden behind an
interface
• Promotes Persistence Ignorant classes
• Much better than static DAL helpers
UI Patterns
• MVC
– ASP.NET MVC
• MVP
– ASP.NET Web Forms
– Winforms
• MVVM
– Silverlight
– WPF
Practices
• Source Control
• One-Click Build and Test
• Unit Testing
• Integration Testing
• Continuous Integration
Applying SOLID Principles

DEMO
Summary
• Download Slides http://SteveSmithBlog.com

• In Depth Training:
– PluralSight On Demand, Principles of Object Oriented Design
http://www.pluralsight-training.net/microsoft/olt/subscriptions.aspx
– NimblePros
Software Development, Mentoring, Application Development
http://NimblePros.com/

• Recommended Reading
– Clean Code by Robert C. Martin http://amzn.to/Clean-Code
– Agile Principles, Patterns, and Practices by Robert C. Martin and Micah Martin
http://amzn.to/agilepppcsharp/
• Image Credits
http://www.lostechies.com/blogs/derickbailey/archive/2009/02/11/solid-development-pr
inciples-in-motivational-pictures.aspx
Register for DevReach 2010
• 18-19 Oct, Sofia, Bulgaria
– 5 tracks
– about 60 unique sessions
– more than 30 rockstar speakers
• 20% Early Bird until 15 Sept (XBOX 360 raffle)
• Special discounts for User Group members
• Twitter: #devreach
• Facebook: www.facebook.com/DevReach

You might also like