How to be a Good Developer

Slides:



Advertisements
Similar presentations
18-1 Verifying Object Behavior and Collaboration Role playing – the act of simulating object behavior and collaboration by acting out an object’s behaviors.
Advertisements

Design Patterns CS is not simply about programming
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Katie C. O’Shea Dennis T. Tillman 11 February 2K2 Flyweight.
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
CERN – European Organization for Nuclear Research GS Department – Administrative Information Services Design Patterns in Groovy Nicolas Décrevel Advanced.
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Idioms and Patterns polymorphism -- inheritance and delegation idioms -- realizing.
Design Patterns Standardized Recurring model Fits in many location Opposite of customization Fundamental types of pattern Choose and use as desired and.
Software Waterfall Life Cycle Requirements Construction Design Testing Delivery and Installation Operations and Maintenance Concept Exploration Prototype.
Design Dan Fleck CS 421 George Mason University. What is the design phase? Analysis phase describes what the system should do Analysis has provided a.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
CSSE 374: More Object Design with Gang of Four Design Patterns Steve Chenoweth Office: Moench Room F220 Phone: (812)
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
1 The Proxy Design Pattern Problem: Defer the cost of object creation and init. until actually used Applicability (possible contexts): – Virtual Proxy:
Team 5: The Infinite Loops Gloria Berumen Patricia Martinez Jose Roberto Salcido Michelle Soto Jose Luis Yanez Omar Zorrilla Design Pattern.
CSSE 374: Introduction to Gang of Four Design Patterns
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Computing IV Singleton Pattern Xinwen Fu.
Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03.
Structural Design Patterns
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Introduction to Design Patterns. Questions What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared.
Creational Patterns
What to know for the exam. Smalltalk will be used for questions, but there will not be questions about the grammar. Questions might ask – how particular.
Proxy, Observer, Symbolic Links Rebecca Chernoff.
08 - StructuralCSC4071 Structural Patterns concerned with how classes and objects are composed to form larger structures –Adapter interface converter Bridge.
Structural Patterns1 Nour El Kadri SEG 3202 Software Design and Architecture Notes based on U of T Design Patterns class.
Proxy.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
CS616: Software Engineering Spring 2009 Design Patterns Sami Taha.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
Design Patterns Introduction
Design Patterns SE464 Derek Rayside images from NetObjectives.com & Wikipedia.
Proxy Pattern defined The Proxy Pattern provides a surrogate or placeholder for another object to control access to it by creating a representative object.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
PROTOTYPE. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract factory.
7 April 2004CSci 210 Spring Design Patterns 2 CSci 210.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
1/23/2018 Design Patterns David Talby.
How to be a Good Developer
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
How to be a Good Developer
MPCS – Advanced java Programming
Design Patterns Lecture part 2.
Introduction to Design Patterns
How to be a Good Developer
Structure We saw early on the importance of algorithms, but what about structuring our code? What's the best way to structure a larger project made of.
How to be a Good Developer
object oriented Principles of software design
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
How to be a Good Developer
Design Patterns Satya Puvvada Satya Puvvada.
Software Engineering Lecture 7 - Design Patterns
Design Patterns in Game Design
Informatics 122 Software Design II
Behavioral Design Pattern
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
DESIGN PATTERNS : Introduction
Informatics 122 Software Design II
Chapter 8, Design Patterns Introduction
Chapter 8, Design Patterns Singleton
Software Design Lecture : 38.
CIS 644 Tues. Nov. 30, 1999 W15A … patterns.
Presentation transcript:

How to be a Good Developer SESSION 6

Values Simplicity Communication Feedback Courage Respect

Principles Boy Scout Rule Persistence Ignorance You Aren’t Gonna Need It Keep It Simple Stable Dependencies Hollywood Single Responsibility Open-Closed Liskov Substitution Interface Segregation Don’t Repeat Yourself Inversion of Control Dependency Inversion Explicit Dependencies Once and Only Once Separation of Concerns Tell, Don’t Ask Encapsulation Principle of Least Surprise

Patterns | Creational, Structural, Behavioural Factory method Facade Memento Abstract factory Flyweight Observer Builder Proxy State Prototype Chain of responsiblity Stategy Singleton Template Command Adaptor Visitor Interpreter Bridge Iterator Composite Mediator Decorator

Principles | Don’t Repeat Yourself This principle states to remove both repetition of process and repetition of logic.

Principles | Inversion of Control A principle in which custom-written portions of a computer program receive the flow of control from a generic framework.

Principles | Inversion of Control Traditional control main Method 1 Method 2 Method 3 Method 4

Principles | Inversion of Control Inverted control Module 1 Module 2 IoC Container Module 3 Module 4

Pattern | Proxy Structural This pattern is centred around creating a placeholder for another object to control access to it. There are 4 common situations where it’s applicable

Pattern | Proxy Structural A virtual proxy for expensive to create objects. The real object is created first accessed A remote proxy to provide a local instance for an object that is in a different address space A protective proxy controls access to a private object. The proxy checks permissions of a caller before allowing access A smart proxy adds additional actions on access like reference counting, loading or synchronisation.

Pattern | Proxy Structural Accessor Far Away Resource Class A Resource uses

Pattern | Proxy Structural Accessor Far Away Proxy Far Away Resource Class A Proxy Resource uses cached access

public interface Image { void display(); } public class ProxyPatternDemo { public static void main(String[] args) { Image image = new ProxyImage("test_10mb.jpg"); //image will be loaded from disk image.display(); System.out.println(""); //image will not be loaded from disk } public class RealImage implements Image { private String fileName; public RealImage(String fileName){ this.fileName = fileName; loadFromDisk(fileName); } @Override public void display() { System.out.println("Displaying " + fileName); private void loadFromDisk(String fileName){ System.out.println("Loading " + fileName);

Pattern | Proxy Creational Source Making : Proxy Design Pattern https://sourcemaking.com/design_patterns/proxy Wikipedia: Proxy Pattern https://en.wikipedia.org/wiki/proxy_pattern

the behavioural design patterns identify common communication patterns between a client and code, and try to remain loosely coupled whilst enabling this communication

Pattern | Chain of Responsibility Behavioural This pattern is concerned with the scenario of a client having a request which can be dealt with by multiple receivers. As a way of avoiding coupling, it recommends chaining handlers so that the request can be passed from one to the next until a handler accepts and deals with the request. The number of handlers isn’t known beforehand and they can be configured dynamically.

Pattern | Chain of Responsibility Behavioural

[Flags] public enum LogLevel { None = 0, // 0 Info = 1, // 1 Debug = 2, // 10 Warning = 4, // 100 Error = 8, // 1000 FunctionalMessage = 16, // 10000 FunctionalError = 32, // 100000 All = 63 // 111111 }

/// <summary> /// Abstract Handler in chain of responsibility pattern. /// </summary> public abstract class Logger { protected LogLevel logMask; // The next Handler in the chain protected Logger next; public Logger(LogLevel mask) this.logMask = mask; } /// Sets the Next logger to make a list/chain of Handlers. public Logger SetNext(Logger nextlogger) next = nextlogger; return nextlogger; public void Message(string msg, LogLevel severity) { if ((severity & logMask) != 0) //True only if all logMask bits are set in severity WriteMessage(msg); } if (next != null) next.Message(msg, severity); abstract protected void WriteMessage(string msg);

public class ConsoleLogger : Logger { public ConsoleLogger(LogLevel mask) : base(mask) { } protected override void WriteMessage(string msg) Console.WriteLine("Writing to console: " + msg); } public class EmailLogger : Logger public EmailLogger(LogLevel mask) // Placeholder for mail send logic, usually the email configurations are saved in config file. Console.WriteLine("Sending via email: " + msg);

public class ConsoleLogger : Logger { public ConsoleLogger(LogLevel mask) : base(mask) { } protected override void WriteMessage(string msg) Console.WriteLine("Writing to console: " + msg); } public class EmailLogger : Logger public EmailLogger(LogLevel mask) // Placeholder for mail send logic, usually the email configurations are saved in config file. Console.WriteLine("Sending via email: " + msg);

class FileLogger : Logger { public FileLogger(LogLevel mask) : base(mask) { } protected override void WriteMessage(string msg) // Placeholder for File writing logic Console.WriteLine("Writing to Log File: " + msg); }

public class Program { public static void Main(string[] args) // Build the chain of responsibility Logger logger, logger1, logger2; logger = new ConsoleLogger(LogLevel.All); logger1 = logger.SetNext(new EmailLogger(LogLevel.FunctionalMessage | LogLevel.FunctionalError)); logger2 = logger1.SetNext(new FileLogger(LogLevel.Warning | LogLevel.Error)); // Handled by ConsoleLogger since the console has a loglevel of all logger.Message("Entering function ProcessOrder().", LogLevel.Debug); logger.Message("Order record retrieved.", LogLevel.Info); // Handled by ConsoleLogger and FileLogger since filelogger implements Warning & Error logger.Message("Customer Address details missing in Branch DataBase.", LogLevel.Warning); logger.Message("Customer Address details missing in Organization DataBase.", LogLevel.Error); // Handled by ConsoleLogger and EmailLogger as it implements functional error logger.Message("Unable to Process Order ORD1 Dated D1 For Customer C1.", LogLevel.FunctionalError); // Handled by ConsoleLogger and EmailLogger logger.Message("Order Dispatched.", LogLevel.FunctionalMessage); }

Pattern | Chain of Responsibility Structural Source Making : Chain of Responsibility Design Pattern https://sourcemaking.com/design_patterns/chain_of_responsibility Wikipedia: Chain of Responsibility Pattern https://en.wikipedia.org/wiki/chain-of-responsibility_pattern

Next session Principles | Dependency Inversion Principles | Explicit Dependencies Patterns | Command Patterns | Interpreter