Multithreading in C# - pitfalls, mistakes and solutions.Marcin Dembowski
Short presentation prepared for Olivia Tech Talks about multithreading in C#. Link to examples: https://github.com/D3M80L/SharpProject/tree/master/Threading
Beyond Supply Chain Scorecards: New Approaches to Elevating Supplier Responsi...Sustainable Brands
Amy Longsworth, Managing Director, Sustainable Business Solutions, PwC
Amy Hargroves, Director of Corporate Responsibility, Sprint
Is there hope for overcoming supplier survey and scorecard fatigue? Have individual leading companies' custom scorecards worked well to drive supplier sustainability, and is there a clear need to design overarching industry-level standards? What brands and other organizations are best positioned to lead such efforts, and why?
Talk presented at National Institute For Space Research (INPE) in Brazil.
Explain how Chain of Responsibility pattern can help you to build a better and decoupled code.
As the name suggests, the chain of responsibility pattern creates a chain of receiver objects for a request. This pattern decouples sender and receiver of a request based on type of request. This pattern comes under behavioral patterns.
Patterns and Anti-patterns
How to learn design patterns?
Categories of GoF patterns
The Fundamental theorem of software engineering
Real-world problems and how design patterns solve them with GoF structural patterns
Multithreading in C# - pitfalls, mistakes and solutions.Marcin Dembowski
Short presentation prepared for Olivia Tech Talks about multithreading in C#. Link to examples: https://github.com/D3M80L/SharpProject/tree/master/Threading
Beyond Supply Chain Scorecards: New Approaches to Elevating Supplier Responsi...Sustainable Brands
Amy Longsworth, Managing Director, Sustainable Business Solutions, PwC
Amy Hargroves, Director of Corporate Responsibility, Sprint
Is there hope for overcoming supplier survey and scorecard fatigue? Have individual leading companies' custom scorecards worked well to drive supplier sustainability, and is there a clear need to design overarching industry-level standards? What brands and other organizations are best positioned to lead such efforts, and why?
Talk presented at National Institute For Space Research (INPE) in Brazil.
Explain how Chain of Responsibility pattern can help you to build a better and decoupled code.
As the name suggests, the chain of responsibility pattern creates a chain of receiver objects for a request. This pattern decouples sender and receiver of a request based on type of request. This pattern comes under behavioral patterns.
Patterns and Anti-patterns
How to learn design patterns?
Categories of GoF patterns
The Fundamental theorem of software engineering
Real-world problems and how design patterns solve them with GoF structural patterns
Top tips from what we've learned from our 10 years experienceJoomlaDay Australia
Butterfly, a digital agency in Melbourne have been building Joomla websites for 10 years, and are one of the largest agencies in Australia who use Joomla. Development Team Leader Dylan McTaggart will be sharing some details about how Butterfly use Joomla to provide solutions to their clients.
He will be sharing interesting learnings and knowledge from the team's collective experience such as how they use a "skeleton" Joomla install full of extensions and libraries to get up and running quicker, how team collaboration on projects is increased using a front-end SASS framework in Joomla, and much more.
Design patterns are known and tested solutions to common problem. In software engineering we constantly come across similar problems. The same problems or tasks need to be programmed again and again, hence patterns. Design patterns catalog and document these solutions.They are built on industry knowledge of what works and why. We will look at what design patterns are, their history and the structure of documenting patterns.
As an example we look at the Observer pattern.
We will also look at Liskov Substitution Principle and the Open Close Principle, both which are very useful in building enterprise systems. Finally we look at creating objects.
Learn the power of object-oriented programming in PHP5 and the many benefits it offers over the more traditional PHP procedural programming style. This session will include a light introduction to object-oriented concepts and will provide real-world concrete examples of the benefits it can offer you and the PHP projects you work on.
Patterns (contd)Software Development ProcessDesign patte.docxdanhaley45372
Patterns (contd)
Software Development Process
Design patterns used to handle change
More time extending and changing code than developing it.
The Strategy design pattern handle change by selecting from a family of external algorithms rather than rewrite.
Design point: Make code closed for modification of code, but open for extension
Problem
Computer object created
Description Method returns
Getting a Computer
Problem
Program has to change every time
Customer changes options
Decorator Pattern
Wrapper code used to extend your core code
Extend a class dynamically at runtime
Decorator uses wrapper code to extend core functionality - decorating the code
Decorator Pattern
description() returns “You are getting a computer”
Wrapper description() returns
“You are getting a computer and a disk”
Wrapper description() returns
“You are getting a computer and a disk and a monitor”
Decorator Pattern
Core component: Computer
Variables holding computer objects should also be able to hold objects that wrap computer objects.
Extend the wrapper classes from the Computer class.
Abstract class cannot be instantiated
Ensures all wrappers are consistent
Developers have to provide their own description
Decorator Pattern
Method calls the core computer object’s
description method and adds “and a disk”
Decorator Pattern
Method calls the core computer object’s
description method and adds “and a disk”
Extend the core object by wrapping it in decorator wrappers. Avoids modification of the core code.
Each successive wrapper called the description method of the object it wrapped and added something to it.
Factory Pattern
Based on type, call the
Connection method
Factory Pattern
Create a method that returns the
correct connection type
Factory Pattern
New operator used to create OracleConnection objects.
New operator used to create SqlServerConnection objects, and MySqlConnection objects.
New operator to instantiate many different concrete classes
Code becomes larger and needs to be replicated in many places
Factor that code out into a method.
Code keeps changing
Encapsulate code into a factory object
Goal: Separate out the changeable code and leave the core code closed for modification
Building the Factory
Creating the Factory
FirstFactory class encapsulates the connection object creation
Pass to it the type of connection (“Oracle”, “SQL Server”,)
Use the factory object to create connection objects with a factory method named createConnection
Building the Factory
Create the FirstFactory class.
Save the type of the database, passed to the FirstFactory class’s constructor.
Object-creation code changes
Check which type of object to be created
(OracleConnection, SqlServerConnection,
and then create it.
Factory Class
Create the Abstract Connection Class
Core code should not be modified or has to be modified
as little as possible.
Using the connection object returned by the
new factory object
Use t.
Adapter Pattern is an example of some Demo implementations for OOP PHP Design Patterns in the Drupal 7 and Drupal 8 environments. Presentation at the Toronto Drupal Group
In this presentation, you will be introduced to Clean Code, Code Smells concepts and anti-patterns in programming, what are the common bad patterns of Selenium code and architectural considerations. We will also go though guidelines on how to write maintainable and reusable automation code, automation of complicated websites, PageObject vs ScreenPlay patterns, and common practices in avoiding and debugging of flaky tests.
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Steven Smith
Design patterns help developers and teams solve problems using proven approaches. In this talk, you'll learn how to solve a series of real world problems by applying patterns. Not only do patterns help individual developers solve particular problems, but they also enable teams to discuss design decisions using a richer, more descriptive language. By the end, you'll have some concrete tools you can apply, and hopefully the desire to master more patterns as you continue to improve!
Architecting Applications the Microsoft WayClint Edmonson
This presentation distills the best guidance from the Microsoft Patterns & Practices group to provide a hands-on approach to designing application architectures. Along the way, we’ll examine the key decisions that must be made when choosing our architectural styles and designing our layers and show how those decisions turn into a real shippable code on a project.
Top tips from what we've learned from our 10 years experienceJoomlaDay Australia
Butterfly, a digital agency in Melbourne have been building Joomla websites for 10 years, and are one of the largest agencies in Australia who use Joomla. Development Team Leader Dylan McTaggart will be sharing some details about how Butterfly use Joomla to provide solutions to their clients.
He will be sharing interesting learnings and knowledge from the team's collective experience such as how they use a "skeleton" Joomla install full of extensions and libraries to get up and running quicker, how team collaboration on projects is increased using a front-end SASS framework in Joomla, and much more.
Design patterns are known and tested solutions to common problem. In software engineering we constantly come across similar problems. The same problems or tasks need to be programmed again and again, hence patterns. Design patterns catalog and document these solutions.They are built on industry knowledge of what works and why. We will look at what design patterns are, their history and the structure of documenting patterns.
As an example we look at the Observer pattern.
We will also look at Liskov Substitution Principle and the Open Close Principle, both which are very useful in building enterprise systems. Finally we look at creating objects.
Learn the power of object-oriented programming in PHP5 and the many benefits it offers over the more traditional PHP procedural programming style. This session will include a light introduction to object-oriented concepts and will provide real-world concrete examples of the benefits it can offer you and the PHP projects you work on.
Patterns (contd)Software Development ProcessDesign patte.docxdanhaley45372
Patterns (contd)
Software Development Process
Design patterns used to handle change
More time extending and changing code than developing it.
The Strategy design pattern handle change by selecting from a family of external algorithms rather than rewrite.
Design point: Make code closed for modification of code, but open for extension
Problem
Computer object created
Description Method returns
Getting a Computer
Problem
Program has to change every time
Customer changes options
Decorator Pattern
Wrapper code used to extend your core code
Extend a class dynamically at runtime
Decorator uses wrapper code to extend core functionality - decorating the code
Decorator Pattern
description() returns “You are getting a computer”
Wrapper description() returns
“You are getting a computer and a disk”
Wrapper description() returns
“You are getting a computer and a disk and a monitor”
Decorator Pattern
Core component: Computer
Variables holding computer objects should also be able to hold objects that wrap computer objects.
Extend the wrapper classes from the Computer class.
Abstract class cannot be instantiated
Ensures all wrappers are consistent
Developers have to provide their own description
Decorator Pattern
Method calls the core computer object’s
description method and adds “and a disk”
Decorator Pattern
Method calls the core computer object’s
description method and adds “and a disk”
Extend the core object by wrapping it in decorator wrappers. Avoids modification of the core code.
Each successive wrapper called the description method of the object it wrapped and added something to it.
Factory Pattern
Based on type, call the
Connection method
Factory Pattern
Create a method that returns the
correct connection type
Factory Pattern
New operator used to create OracleConnection objects.
New operator used to create SqlServerConnection objects, and MySqlConnection objects.
New operator to instantiate many different concrete classes
Code becomes larger and needs to be replicated in many places
Factor that code out into a method.
Code keeps changing
Encapsulate code into a factory object
Goal: Separate out the changeable code and leave the core code closed for modification
Building the Factory
Creating the Factory
FirstFactory class encapsulates the connection object creation
Pass to it the type of connection (“Oracle”, “SQL Server”,)
Use the factory object to create connection objects with a factory method named createConnection
Building the Factory
Create the FirstFactory class.
Save the type of the database, passed to the FirstFactory class’s constructor.
Object-creation code changes
Check which type of object to be created
(OracleConnection, SqlServerConnection,
and then create it.
Factory Class
Create the Abstract Connection Class
Core code should not be modified or has to be modified
as little as possible.
Using the connection object returned by the
new factory object
Use t.
Adapter Pattern is an example of some Demo implementations for OOP PHP Design Patterns in the Drupal 7 and Drupal 8 environments. Presentation at the Toronto Drupal Group
In this presentation, you will be introduced to Clean Code, Code Smells concepts and anti-patterns in programming, what are the common bad patterns of Selenium code and architectural considerations. We will also go though guidelines on how to write maintainable and reusable automation code, automation of complicated websites, PageObject vs ScreenPlay patterns, and common practices in avoiding and debugging of flaky tests.
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Steven Smith
Design patterns help developers and teams solve problems using proven approaches. In this talk, you'll learn how to solve a series of real world problems by applying patterns. Not only do patterns help individual developers solve particular problems, but they also enable teams to discuss design decisions using a richer, more descriptive language. By the end, you'll have some concrete tools you can apply, and hopefully the desire to master more patterns as you continue to improve!
Architecting Applications the Microsoft WayClint Edmonson
This presentation distills the best guidance from the Microsoft Patterns & Practices group to provide a hands-on approach to designing application architectures. Along the way, we’ll examine the key decisions that must be made when choosing our architectural styles and designing our layers and show how those decisions turn into a real shippable code on a project.
2. What Are Design Patterns?
Well-understood code patterns
Solve common problems
Create common pattern vocabulary
Speed up design and development
Encourage creating design standards
3. Useful Design Principles
Prefer Composition over Inheritance
Program to abstractions instead of
concrete implementations
Design loosely coupled components
Encapsulate what varies
Hide the likely-to-change code behind an
interface
4. Time-Tested Design Principles
S – Single Responsibility Principle
One reason to change per class
O – Open-Closed Principle
Classes open for extension, closed for modification
L – Liskov Substitution Principle
Classes can be substituted if designed to be
referenced via their public contracts
I – Interface Segregation Principle
Interfaces should not be bloated
D – Dependency Inversion Principle
Classes should not be responsible for creating their
dependencies
6. Example Anti Patterns
The Arrowhead
Constructor Over-Injection
Gold Plating
Interface Bloat
God Object
Magic Literals
Reinventing The Wheel
7. The Gang Of Four
Authors of the canonical book Design
Patterns: Elements of Reusable Object-
Oriented Software
Erich Gamma, Richard Helm, Ralph
Johnson, John Vlissides
Main theme 1: Program to an interface
instead of an implementation
Main theme 2: Favor composition over
inheritance
9. Enterprise Design Patterns
Patterns found in enterprise applications
Major proponent: Martin Fowler of
Thoughtworks
Enterprise patterns go beyond GoF
patterns
Often specific to technology stacks
11. What Makes It Useful?
Repeatable pattern to execute tasks as
objects
Allows parameterizing command
invokers with different commands
Allows undo operations
Meta-Command Pattern allows creating
composite commands
Decouples worker objects from client
objects
12. Practical Uses
Background processing agents
Allow third-party vendors to create and
distribute custom commands
Supports queuing requests
Facilitates logging requests
By serializing/deserializing objects to/from log
files
Log contains history of all command objects
Allows implementing transaction semantics
15. What Makes It Useful?
Facilitates implementing the open-
closed principle
Allows adding new functionality without
modifying existing classes
Promotes composition over inheritance
Promotes iterative development
16. Practical Uses
Dynamically creating specialized objects
Provide flexible API with object
decorators
Example uses in the .Net framework
BufferedStream decorates MemoryStream
20. Pattern: Lazy Load
Avoid performing time-consuming
operations unless unavoidable
Load data from database or an external
service as late as possible
Cache fetched data for as long as
feasible
Reduce database and/or network load
21. Code Sample
Private Shared ReadOnly Property
DTSearchIndexLocation() As String
Get
If String.IsNullOrEmpty(_dtSearchIndexLocation)
Then
' fetch from database and assign to
_dtSearchIndexLocation
End If
Return _dtSearchIndexLocation
End Get
End Property
23. Further Study
Writings of The Godfather of Enterprise
Design Patterns a.k.a. Martin Fowler
Martinfowler.com
Head-First Design Patterns by O’Reilly
Writings of Uncle Bob a.k.a. Robert C.
Martin
ButUncleBob.com, blog.objectmentor.com
Presentations by Jeremy Miller
codebetter.com/blogs/jeremy.miller
Editor's Notes
Say more with less, shared vocabulary speeds up development and reduces chances of confusion and misunderstanding.
Constructor Over Injection: If the class can function without a particular dependent object, it shouldn’t demand it in the constructor.