Object Oriented Practices

Slides:



Advertisements
Similar presentations
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Advertisements

CS 201 Functions Debzani Deb.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
CSE 332: C++ templates and generic programming I Motivation for Generic Programming in C++ We’ve looked at procedural programming –Reuse of code by packaging.
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse.
Introduction to Object-oriented programming and software development Lecture 1.
Object Oriented Programming Lecture 4: Refactoring, An Applet Example, Idiom - Animation applets, Introduction to the Laboratorial exercise www2.hh.se/staff/jebe/oop2005/
1 Life Cycle of Software Specification Design –Risk Analysis –Verification Coding Testing –Refining –Production Maintenance.
Introduction to Design. What is Design? 2 minutes Pairs.
1 CS161 Introduction to Computer Science Topic #9.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
Functional Programming IN NON-FUNCTIONAL LANGUAGES.
The Last Lecture CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
Object Oriented Programming Some Interesting Genes.
Motivation for Generic Programming in C++
Structures and Classes
Topic: Functions – Part 1
Phil Tayco Slide version 1.0 Created Sep 18, 2017
Software Development Expansion of topics page 28 in Zelle
ASP.NET MVC Introduction
CS 350 – Software Design The Strategy Pattern – Chapter 9
The Object-Oriented Thought Process Chapter 1
Programming the Web Using Visual Studio .NET
Data Abstraction: The Walls
CMPT 120 Topic: Functions – Part 4
OOP What is problem? Solution? OOP
CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1
Topic: Functions – Part 2
Figure 1.1 The life cycle of software as a water wheel that can rotate from one phase to any of phase.
Types of Programming Languages
Chapter 16 – Software Reuse
SVTRAININGS. SVTRAININGS Python Overview  Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed.
Figure 1.1 The life cycle of software as a water wheel that can rotate from one phase to any of phase.
Object Oriented Practices
Functions Inputs Output
.NET and .NET Core 9. Towards Higher Order Pan Wuming 2017.
CSE 332 Overview and Structure
12 Asynchronous Programming
Learning to Program in Python
Chapter 5 Designing the Architecture Shari L. Pfleeger Joanne M. Atlee
CIS16 Application Development – Programming with Visual Basic
Prof. Jason Eisner MWF 3-4pm (sometimes 3-4:15)
Object Oriented Practices
Object Oriented Practices
Need for the subject.
Object Oriented Practices
Object Oriented Practices
Software Design and Architecture
Object Oriented Practices
An Introduction to Software Architecture
SE2811 Software Component Design Dr. Rob Hasker
Distributed Systems through Web Services
Week 4 Lecture-2 Chapter 6 (Methods).
SE2811 Software Component Design Dr. Rob Hasker
Review B.Ramamurthy 4/6/2019 BR.
CMSC202 Computer Science II for Majors Lecture 07 – Classes and Objects (Continued) Dr. Katherine Gibson Based on slides by Chris Marron at UMBC.
Chapter 16 – Software Reuse
Use Case Analysis – continued
Slide design: Dr. Mark L. Hornick
Final Review B.Ramamurthy 5/8/2019 BR.
Dependency Inversion principle
Copyright  1997 Oxford University Press All Rights Reserved
Chapter 8 - Design Strategies
Message Passing Systems Version 2
HFOOAD Chapter 5 Interlude
Architectural Mismatch: Why reuse is so hard?
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
Presentation transcript:

Object Oriented Practices This is the Delegates, Events, and Lambdas module. I’ve tested this to be 45 minutes in length for the slide deck. The code review portion should be 45 minutes. The speaker notes on the slides will detail the key concepts we want to cover in each of these slid Bill Wagner | Software Consultant James Sturtevant | Senior Technical Evangelist, Microsoft

Course Topics Object Oriented Practices 01 | Encapsulation 05 | Generics 02 | Inheritance 06 | Delegates Events and Lambdas 03 | Interfaces 07 | Functional Programming 04 | Abstract Classes 08 | Review Exercises Hey, up to functional programming The final new concept

Functional Concepts Bill Wagner | Software Consultant Objects and object oriented programming are great tools and concepts for many common problems. But, it’s not the Best tool for everything. Bill Wagner | Software Consultant James Sturtevant | Senior Technical Evangelist

Module Topics Functional Concepts 01 | Definition 02 | Guidelines 03 | Functional Programming Practices 04 | Functional Concepts Good Outcomes Hey, up to functional programming The final new concept

Definition Bill Wagner | Software Consultant Objects and object oriented programming are great tools and concepts for many common problems. But, it’s not the Best tool for everything. Bill Wagner | Software Consultant James Sturtevant | Senior Technical Evangelist

Definitions Functional Programming is a style of programming where functions are treated as first-class citizens: functions can be used as arguments to other functions. Higher order functions are functions that take a function as one or more arguments. Read through the definition. Functions are first class functions. There are areas in C# and .NET where you’ve already seen this. LINQ is the most common examples.

The Benefit of Pure Functions A pure function is a function with no side effects Result relies only on its arguments (not global state) Only result is method return value (no changes in global state) Can be called repeatedly and safely Easier to test Doesn’t rely on program state Inheritently thread-safe Shared Data won’t be modified Pure functions are functions with no side effects. Can be called once, twice, or more with no global state side-effects. .

Code can be treated as data Supply function as an argument Return functions from other functions Functions are a ‘recipe’ for part of an algorithm LINQ, and other examples show how we would use functions as data. LINQ, Task.Run() and other styles of code.

Guidelines Bill Wagner | Software Consultant Section header Let’s look at guidelines for leveraging Functional Programming Techniques. Bill Wagner | Software Consultant James Sturtevant | Senior Technical Evangelist

Guideline: Compose algorithms as Functions Sounds obvious, but think it through How many algorithms do you write that combine: General solution Specific functionality Compose those parts as functions General and generic Specific function as argument General problem: Run a task on another thread, using the Task Asynchronous Protocol. Specific Function: What work to do on another thread. Consider that if you might copy / paste / modify. What if the code you were going to modify could be implemented as a separate function?

Guideline: Stateless Methods Methods and functions should strive for statelessness. Don’t rely on program state Don’t modify program state Results: Thread Safe Idempotent Discussion Consider a sort algorithm. General part: rearrange element based on ordering function Delegate: define the ordering function

Functional Programming Practices Section header How can we accomplish smart use of functional programming concepts Bill Wagner | Software Consultant James Sturtevant | Senior Technical Evangelist

Separate General from Specific Again, Sort is a great example LINQ provides great examples.. Discussion points here: . Notice that in C#, most of the time, Functional Programming idioms are implemented in terms of delegates. That’s why LINQ is a great example.

Examples: LINQ LINQ is a functional library A LINQ query represents a set of functions that query a data source The set of functions are a combination of: Core libraries (System.Linq.Enumerable) Specific code for specific scenarios That specific code is represented as a function Those functions are encoded as delegates Delegates are arguments to LINQ query methods This is a good point for the discussion of functional concepts. Build a linq query is a set of functional concepts.

Examples: Task<T> A Task represents work that will be done Work that will be done can be expressed as a function Functions can run somewhere Task<T> separates general task algorithms from specific This is a good point for the discussion of functional concepts. Build a

Bill Wagner | Software Consultant James Sturtevant | Senior Technical Functional Concepts: Good Outcomes Section header Why are these practices going to help? How might they cause concern? Bill Wagner | Software Consultant James Sturtevant | Senior Technical

Good Outcome: Clients focus on What Good functional libraries encapsulate How. Client developers focus on What. Reuse via metaprogramming means that the compiler creates the specific versions of eah generic when it is instantiated.

Good Outcome: Composability of Functions Pipeline of operations LINQ queries are a great example Each function has inputs, outputs. Relies on nothing else. Functions can be defined for any stage of the pipeline. Re-configure the pipeline in any order. (subject to input and output types ASP.NET OWIN pipeline