Adaptive Code Umamaheswaran Senior Software Engineer

Slides:



Advertisements
Similar presentations
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Advertisements

General OO Concepts and Principles CSE301 University of Sunderland Harry R. Erwin, PhD.
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
SOLID Object Oriented Design Craig Berntson
©2007 · Georges Merx and Ronald J. NormanSlide 1 Chapter 5 Architecture-Driven Component Development.
Project Management – An Overview Project as a metaphor – a way to approach a series of activities Contexts – construction managementt, IT development,
Layered Architectures The objectives of this chapter are: To understand the principles and importance of Layered Architectures To explain the structure.
Agile Software Development Matt Rice November 27, 2006.
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
Software Engineering Module 1 -Components Teaching unit 3 – Advanced development Ernesto Damiani Free University of Bozen - Bolzano Lesson 2 – Components.
Developed by Reneta Barneva, SUNY Fredonia Component Level Design.
Introduction to Agile.
Classical vs. Agile Requirements Development Svetlin Nakov Telerik Software Academy academy.telerik.com Senior Technical Trainer
SEG4911 – Projet génie logiciel en fin d’études / Software Engineering Capstone Project Thoughts about Agile Design and Release Management Timothy C. Lethbridge.
Struts 2.0 an Overview ( )
CVSQL 2 The Design. System Overview System Components CVSQL Server –Three network interfaces –Modular data source provider framework –Decoupled SQL parsing.
The Design Discipline.
Building SOLID Software with Dependency Injection Jeremy Rosenberg.
Designing For Testability. Incorporate design features that facilitate testing Include features to: –Support test automation at all levels (unit, integration,
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 11 : Frameworks SWE 316: Software Design and Architecture  To understand.
Company Confidential – Do Not Duplicate 2 Copyright 2008 McLane Advanced Technologies, LLC S.O.L.I.D. Software Development Achieving Object Oriented Principles,
Design Design and Software Architecture. The design phase The analysis phase describes what the system should be doing The design phase describes how.
© 2004 Capgemini - All rights reserved SOLID - OO DESIGN PRINCIPLES Andreas Enbohm, Capgemini.
CSE 301 Exam Revision Lecture
Introduction to SOLID Principles. Background Dependency Inversion Principle Single Responsibility Principle Open/Closed Principle Liskov Substitution.
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
Plug-In Architecture Pattern. Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment.
Building a real-world, Internet- scale stock trading application Naveen Prabhu Quadwave Consulting Pvt. Ltd.
Incremental Design Why incremental design? Goal of incremental design Tools for incremental design  UML diagrams  Design principles  Design patterns.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter.
High Cohesion Low Coupling Old Standards for Object Oriented Programming.
MVC WITH CODEIGNITER Presented By Bhanu Priya.
Principles of Object Oriented Design
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
PRINCIPLES OF OBJECT ORIENTED DESIGN S.O.L.I.D. S.O.L.I.D Principles What is SOLID?  Acrostic of 5 Principles:  The Single Responsibility Principle.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Plug-In Architecture Pattern. Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment.
Northwest Arkansas.Net User Group Jay Smith Tyson Foods, Inc. Unit Testing nUnit, nUnitAsp, nUnitForms.
Application Integration Framework (AIF) Dean Wierman Lead Program Manager Microsoft Corporation.
BizTalk Damir Dobric Lead Architect. Agenda Microsoft BizTalk RFID Overview Architecture Application models Implementing Event Handlers Sensors.
Project Workflow.
Chapter 5 Agile Development Moonzoo Kim KAIST
Agile Methods SENG 301.
Agile Methodology and Scrum
AGILE SCRUM METHODOLOGY
Fundamentals Sunny Sharma Microsoft
Software Architecture & Difference from Design
Project Workflow.
Adaptive Code Via C#
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
Satisfying Open/Closed Principle
Magento Technical Guidelines Eugene Shakhsuvarov, Software Magento
Impact of Agile Methodology on Software Architecture
iVend Retail Extensibility
ADO.NET Entity Framework Marcus Tillett
Entity Framework Core.
11/29/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Extending Microsoft Teams
Software Design Lecture : 14.
Object Oriented Practices
Visual Studio 2005 Tools For Office: Creating A Multi-tier Application
API DOCUMENTATION Swetha Mohandas Microsoft Connect 2016
TechEd /3/ :48 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Learning with Xamarin Workbooks
A (partial) blueprint for dealing with change
European conference.
Dependency Inversion principle
Office 365 Development July 2014.
Plug-In Architecture Pattern
Presentation transcript:

Adaptive Code 16.02.2017 Umamaheswaran Senior Software Engineer Microsoft Connect 2016 9/20/2018 10:38 PM Adaptive Code 16.02.2017 Umamaheswaran Senior Software Engineer © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Agenda Agile Overview Dependencies and Layering SOLID Principles Microsoft Connect 2016 9/20/2018 10:38 PM Agenda Agile Overview Dependencies and Layering SOLID Principles © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

What is Agile Manifesto? Individuals and interactions over processes and tools Working software over comprehensive documentation Customer collaboration over contract negotiation Responding to change over following a plan

Agile Sprint Overview Product Backlog Sprint Backlog Sprint (1-4) weeks Release Daily Work

Technical Debt Reckless Prudent We don’t have time for design We must ship now and deal with consequences What’s Layering Now we know how we should have done it Deliberate Inadvertent

Definition of Done “It’s done, I Just have to test it…” “It’s done, but I found a defect that I need to fix” “It’s done, but I’m not 100-percent happy with the design, so I’m going to change the interface”

What goes wrong with Agile? Programmers population doubling every five years Not for all projects Bad Code/Maladaptive Code

Symptoms of bad code? Rigidity Fragility Coupling

Dependencies and Layering

What is dependency?

Different types of dependency First party dependency Framework dependency Third party dependency

Manage Dependencies Implementations vs Interfaces The new code smell Alternatives to object construction Coding to a Interface Using Dependency Injection The Entourage anti-pattern The Stairway Pattern Dependency Management with NuGet

new() code smell AccountController forever dependent on SecurityService SecurityService dependencies are now AccountController implicit dependency It is impossible to mock AccountController ChangePassword method requires users to load UserRepository public class AccountController { private readonly SecurityService _securityService; public AccountController() this._securityService = new SecurityService(); } public void ChangePassword(Guid userId, string newPassword) var userRepository = new UserRepository(); var user = userRepository.GetById(userId); this._securityService.ChangeUsersPassword(user, newPassword);

Refined Version public class SecurityService : ISecurityService { private readonly IUserRepository _userRepository; public SecurityService(IUserRepository userRepository) if (userRepository == null) throw new ArgumentNullException(nameof(userRepository)); _userRepository = userRepository; } public void ChangeUsersPassword(Guid userId, string newPassword) var user = _userRepository.GetById(userId); user.ChangePassword(newPassword); public class AccountController { private readonly ISecurityService _securityService; public AccountController(ISecurityService securityService) if (_securityService == null) throw new ArgumentNullException(nameof(securityService)); _securityService = securityService; } public void ChangePassword(Guid userId, string newPassword) _securityService.ChangeUsersPassword(userId, newPassword);

Entourage anti pattern

Stairway Pattern

Stairway Pattern

Layering Architectural pattern that encourages you to think of software components horizontal layers of functionality that build on each other to form a whole application.

Sample Component

Two Layers User Interface Data Access

Three Layers User Interface Business Logic Data Access

Command Query Responsibility Segregation User Interface Data Access Logic COMMAND SERIALIZE/ DESERIALIZE OBJECTS QUERY DATA

SOLID Single Responsibility principle Open/Closed Principle Liskov Substitution Principle Interface segregation Dependency Injection

Single Responsibility Principle SRP Instructs developers to write code that has only one reason to change It is the lynchpin of adaptive code If a class has more than one reason to change then it has more than one responsibility A class that has too many responsibilities to change should delegate one more responsibilities to other classes Code Sample

What the code does It reads line from a Stream parameter, storing each line in a list of strings It parses out individual fields from each line and stores them in a more structured list of Trade-Record Instances The parsing includes some validation and some logging to the console Each Trade-Record is enumerated, and a stored procedure is called to insert the trades into a database

Circumstances that it will change When you decide not to use a Stream for input but instead read the trades from a remote call to a web service. When the format of the input data changes perhaps with the addition of an extra field indicating the broker for the transaction. When the validation rules of the input data change. When the way in which you log warnings, errors and information changes. If you are using a hosted web service, writing to the console would not be a viable option When the database changes in some way. Ex: new param in SP

The Open Closed Principle Open for extension closed for Modification Open for extension: This means that the behaviour of the module can be extended As the requirements of the application change, we are able to extend the module with new behaviours that satisfy those changes. In other words, we are able to change what the module does Closed for modification: Extending the behaviour of a module does not result in changes to the source or binary code of the module. The binary executable version of the module, whether in a linkable library, a DLL or a Java .jar remains untouched

Methods to provide extension Any class that marks one of its members as virtual is open to extension Abstract methods provides more flexible way for implementation Interface Inheritance “Design for inheritance or prohibit it”

To read more The Liskov substitution principle Interface segregation Dependency Injection