Eagleson’s Law: Any code of your own that you haven't looked at for 6+ months might as well have been written by someone else.

Slides:



Advertisements
Similar presentations
Computer Science 313 – Advanced Programming Topics.
Advertisements

CSE 331 SOFTWARE DESIGN & IMPLEMENTATION DEBUGGING Autumn 2011 Bug-Date: Sept 9, 1947.
Recursion CS 367 – Introduction to Data Structures.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Dynamic Typing COS 441 Princeton University Fall 2004.
Java.  Java is an object-oriented programming language.  Java is important to us because Android programming uses Java.  However, Java is much more.
Recursion.
CS 106 Introduction to Computer Science I 03 / 30 / 2007 Instructor: Michael Eckmann.
CS503: Tenth Lecture, Fall 2008 Review Michael Barnathan.
CSC 395 – Software Engineering Lecture 21: Overview of the Term & What Goes in a Data Dictionary.
Donald Knuth [F]orget about small efficiencies, say about 97% of the time.
7/16/2015Singleton creational design pattern1 Eivind J. Nordby Karlstad University Dept. of Computer Science.
Generics, Proxy, and The Compile Time Type Checking Debate You are either with us or against us. Please snarf the code for today’s class.
CSC 313 – Advanced Programming Topics. Why Recurse?  Recursion is useful, powerful technique  Often yields compact, easy-to-read code  Highlights all.
Computer Math AP Computer Science Computer Programming.
1 Testing Concurrent Programs Why Test?  Eliminate bugs?  Software Engineering vs Computer Science perspectives What properties are we testing for? 
Singleton Christopher Chiaverini Software Design & Documentation September 18, 2003.
School of Computing and Mathematics, University of Huddersfield Computing Science: WEEK 17 Announcement: next few weeks… 9 nd Feb: Comparative Programming.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage  Weekly assignments.
CSC 213 – Large Scale Programming. Why Do We Test?
CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
CSCA48 Course Summary.
Introduction to Psychology What IS Psychology? Why should I care about it?
Methods of Science Section 1.1. Methods of Science 3 areas of science: Life, Earth, Physical –What is involved in each? Scientific Explanations- not always.
Prof. Hertz (as told by xkcd.com)‏. Computer Science 313 – Advanced Programming Topics.
Computer Science 313 – Advanced Programming Topics.
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Albert Einstein Two things are infinite: the universe & human stupidity; and I'm not sure about the universe.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Beware of bugs in the above code; I have only proved it correct, not tried it.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Computer Science 313 – Advanced Programming Topics.
Problem of the Day  Why are manhole covers round?
Security - Why Bother? Your projects in this class are not likely to be used for some critical infrastructure or real-world sensitive data. Why should.
CSC 313 – Advanced Programming Topics. Open-Closed Principle Classes should be open for extension, but closed to modification  So, what does this mean?
Refactoring1 Improving the structure of existing code.
Computer Science 313 – Advanced Programming Topics.
Computer Science 313 – Advanced Programming Topics.
Question of the Day You overhear a boy & his mother talking: Mom:What is ? Boy: That's easy, 33. Mom: Good. What's ? Boy:Simple. It's 40. Mom:Excellent!
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Tom Cargill The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the.
Exceptions, cont’d. Factory Design Pattern COMP 401 Fall 2014 Lecture 12 9/30/2014.
CSC 313 – Advanced Programming Topics. What Is the Factory Method?  Creation details hidden by AbstractCreator  Does effective job of limiting concrete.
1 CS 177 Week 12 Recitation Slides Running Time and Performance.
Science Fair Projects Requirements, Tips, etc.. When is the project due? The Sweetwater Science Fair will be on Friday, January 29, Time to be announced.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Religious Studies 313 – Advanced Programming Topics.
Using Lists Games Programming in Scratch. Games Programming in Scratch Extension – Using Lists Learning Objectives Create a temporary data store (list)
CMSC 202 Advanced Section Classes and Objects: Object Creation and Constructors.
Refactoring1 Improving the structure of existing code.
Question of the Day You overhear a boy & his mother talking: Mom:What is ? Boy: That's easy, 33. Mom: Good. What's ? Boy:Simple. It's 40. Mom:Excellent!
Fred Brooks Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the.
Singleton Pattern. Problem Want to ensure a single instance of a class, shared by all uses throughout a program Context Need to address initialization.
INF3110 Group 2 EXAM 2013 SOLUTIONS AND HINTS. But first, an example of compile-time and run-time type checking Imagine we have the following code. What.
Bjarne Stroustrup I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
CSE 374 Programming Concepts & Tools
Factory Patterns 1.
Week 4 Object-Oriented Programming (1): Inheritance
Advanced Compilers CMPSCI 710 Spring 2003 Lecture 1
Improving the structure of existing code
Singleton Pattern Pattern Name: Singleton Pattern Context
Unit 3 Test: Friday.
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
LCC 6310 Computation as an Expressive Medium
January 15, 2004 Adrienne Noble
Introduction to Computer Science
Presentation transcript:

Eagleson’s Law: Any code of your own that you haven't looked at for 6+ months might as well have been written by someone else.

Computer Science 313 – Advanced Programming Topics

How About that Recursion Flat profile of 0.67 secs (32 total ticks): main Interpreted + native Method 3.1% Recursive02.binomialExpansion Compiled + native Method 96.9% Recursive02.binomialExpansion Flat profile of 2.61 secs (145 total ticks): main Interpreted + native Method 0.7% java.util.Vector.elementAt Compiled + native Method 85.5% Recursive02.binomialExpansion 13.8% java.util.Vector.addElement

What Happened? Why?

Simple Explanation  Java’s implementation of Stack sucks

Real Explanation  Java’s Stack slower than system stack  Well, duh, but more important is why  Stack class must work in lots of situations  Includes checks to grow on each call to push  Must balance size and speed demands  Decent performance often; Great performance never  System stack is highly specialized  Explodes size to gain speed  Benefits from knowing it has only one use

One is Special

There Can Be Only One!  Uniqueness leads to improvements  Provide universal access  Eliminate unneeded checks for errors  Avoid creating large number of small objects  Make space-time tradeoffs with confidence  Can also make correctness easy  Pretty easy to find object triggering error  Ensure order of actions  Prevents problems over which instance in charge

Common Situation  Graphic & game engines  System.out  System.err  AbstractFactory instances  FactoryMethod instances  Device drivers

Singleton Pattern  Ensures class has exactly 1 instance  Always use same instance of class  Fields can change, but instance should not  Provides single access point to instance  All uses of class should go through this  Methods should not let this reference leak

Singleton Anti-Pattern  Process or model harmful to overall process  Alcohol Fueled Development  Big Ball Of Mud  Blowhard Jamboree  Design By Committee  Kill Two Birds With One Stone  Singleton is harmful when a global variable  Also known as public static field  Can be updated & changed in many places

For Next Class  Lab #5 on web/Angel & due week from Tues.  Implements Decorator pattern & a factory  You can choose the factory to implement  Read pages 179 – 186 in the book  How do we implement these Singletons?  What are the myriad ways to screw them up?  Which system bugs are exposed by this pattern?