GoTo IEnumerable considered harmful

Slides:



Advertisements
Similar presentations
Fun with Lists for the Novice and Expert Scott Reed Brain Hz Software (760)
Advertisements

LINQ and Collections An introduction to LINQ and Collections.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 12 th -13 th Lecture Pavel Ježek.
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
Test practice Multiplication. Multiplication 9x2.
New Features in C# 2.0 Sergey Baidachni MCT, MCSD, MCDBA.
Iterator Pattern Dr. Neal CIS 480. Iterator An iterator pattern can be used when one class is a collection of things and would like to provide a standardized.
Sequence Control Chapter 6. 2 l Control structures: the basic framework within which operations and data are combined into programs. Sequence control.
Copyright © 2006 Thomas P. Skinner1 Chapter 5 Indexers, Interfaces, and Enumerators.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Key Principles of Software Architecture and Design (I) adapted from Dave Penny’s.
Interfaces 1. Interfaces are (parts of) contracts Interfaces are contracts between implementers and consumers Consumers: Programmers using a class implementing.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Modern Software Development Using C#.NET Chapter 5: More Advanced Class Construction.
Advanced C# Types Tom Roeder CS fa. From last time out parameters difference is that the callee is required to assign it before returning not the.
Limits.
Danielle Turner Sadie Fritz Peter Ulrich Eric Kuehn.
Inside LINQ to Objects How LINQ to Objects work Inside LINQ1.
Advanced C#, part I Niels Hallenberg IT University of Copenhagen BAAAP – Spring 2009.
Introduction to C# 2.0 An Advanced Look Adam Calderon Principal Engineer - Interknowlogy Microsoft MVP – C#
Generics Generics vs. heterogeneous collections Doing your own generics FEN 2014UCN Teknologi/act2learn1.
Lecture 8: Collections, Comparisons and Conversions. Svetla Boytcheva AUBG, Spring COS 240 Object-Oriented Languages.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming I 2 nd Lecture Pavel Ježek
Elaboration: Iteration 2. Elaboration: Iteration 2 Basics Iteration 1 ends with : All the software has been tested: The idea in the UP is to do early,
Holt McDougal Algebra 2 Geometric Sequences and Series Holt Algebra 2Holt McDougal Algebra 2 How do we find the terms of an geometric sequence, including.
A Set of Principles for Conducting and Evaluating Interpretive Field Studies in Information Systems Heinz K. Klein Michael D. Myers.
Advanced Functional Programming 2010
Advanced .NET Programming I 2nd Lecture
Establishing and Managing a Schedule Baseline
16. Controlling Loops CSC-3004 Introduction to Software Development
Copyright © Cengage Learning. All rights reserved.
Iterators and Comparators
Alternating Series; Absolute and Conditional Convergence
Understanding Personnel Assessment
Requirements and the Software Lifecycle
Decision Matrix Principles Of Engineering
Theory of Computation Lecture 16: A Universal Program VII
Assignments A sample main program for Project 2 phase 2 is contained in: It reads.
Financial Principles and Project Cost Management
Quicksort analysis Bubble sort
Control Flow Chapter 6.
Conditional Statements
إستراتيجيات ونماذج التقويم
Stat 414 – Day 15 Exam 1 Review.
Evaluating Research Is this valid research?.
Lecture 10: Collections.
16. Controlling Loops CSC-3004 Introduction to Software Development
Object-Oriented Programming
Welcome Activity 1. Find the sum of the following sequence: Find the number of terms (n) in the following sequence: 5, 9, 13, 17,
Informed Consent in Research for Non- Registered Staff
Lesson 6. Types Equality and Identity. Collections.
Iteration Implemented through loop constructs (e.g., in C++)
The Decision Making Model
The iterator and memento patterns
5-6 Marks for Criterion A An appropriate question for investigation has been clearly stated. The student has identified and selected appropriate and relevant.
QUIZ QUIZ TRADE On one side on your sheet of paper – write down a question which you will quiz someone in the class (make it hard!) Write down the answer.
Objectives Find the indicated terms of an arithmetic sequence.
Geometric Sequences.
Learning Intention I will learn about the iterative software development process with a focus on the Analysis stage.
Testing versus instance generation
Topics Introduction to Repetition Structures
Introduction to Sequences
Recursively Enumerable Sets
Optimizing Sequences of DB Operations
Overview of Class #11 Comments on project #1
LO: To understand the different type of percentage question.
Generating Sequences © T Madas.
Change and Continuity HOW & WHY THINGS CHANGE
The Aim of Human Performance
Iterator Design Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014
Presentation transcript:

GoTo IEnumerable considered harmful Goran Šiška (Siopti d.o.o.)

Enumerable IEnumerable Collection Items GetEnumerator() IEnumerator Iterator Current item MoveNext()

Enumerable IGeneratable Collection Items GetGenerator() IGenerator Current item MoveNext()

foreach actually

foreach actually

yield actually

foreach vs ForEach() „The first reason is that doing so (ForEach()) violates the functional programming principles that all the other sequence operators are based upon. Clearly the sole purpose of a call to this method is to cause side effects.“ Eric Lippert

Common mistakes Late Evaluation Multiple Evaluation Instance Evaluation Infinite Evaluation Order Of Evaluation Partial Evaluation

Lessons learned Enumerable is „lazy“ Iterating is generating Re-evaluation re-instantiates Infinite sequences are bad Context may vary Side effects best be avoided

SourceCode https://github.com/GoranSiska/IEnumerableConsideredHarmful

Lack of UnitTests considered harmful