Computer Science 313 – Advanced Programming Topics.

Slides:



Advertisements
Similar presentations
CHAPTER OBJECTIVE: NORMALIZATION THE SNOWFLAKE SCHEMA.
Advertisements

Computer Science 313 – Advanced Programming Topics.
Coding and Debugging. Requirements and Specification Recall the four steps of problem solving: Orient, Plan, Execute, Test Before you start the implementation.
Copyright ©: Lawrence Angrave, Vikram Adve, Caccamo 1 Virtual Memory III.
Chair of Software Engineering Constants, once routines, and helper functions these slides contain advanced material and are optional.
Plab – Tirgul 12 Design Patterns
Nov R McFadyen1 Design Patterns (GoF) contains the creational patterns: Abstract factory Builder Factory method (section 23.3 has a Simple.
Iterators T.J. Niglio Computer & Systems Engineering Fall 2003 Software Design & Documentation Object Behavioral.
Chapter 3.4 Programming Fundamentals. 2 Data Structures Arrays – Elements are adjacent in memory (great cache consistency) – They never grow or get reallocated.
Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering.
Week 1 Game Design & Development for Mobile Devices.
Computer Math AP Computer Science Computer Programming.
Singleton Christopher Chiaverini Software Design & Documentation September 18, 2003.
Design Patterns.
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.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 6: Using Design Patterns 1.
Prof. Hertz (as told by xkcd.com)‏. Computer Science 313 – Advanced Programming Topics.
Albert Einstein Two things are infinite: the universe & human stupidity; and I'm not sure about the universe.
CSC 213 – Large Scale Programming. Today’s Goal  Improve design skills to make usable designs  Noun extraction & UML class diagram reviewed  Connections.
Beware of bugs in the above code; I have only proved it correct, not tried it.
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,
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,
GAME 1024: Advanced Game Programming Lesson 1: The Beginning By Kain Shin.
Computer Science 313 – Advanced Programming Topics.
Problem of the Day  Why are manhole covers round?
Computer Science 313 – Advanced Programming Topics.
Computer Science 313 – Advanced Programming Topics.
Computer Science 313 – Advanced Programming Topics.
Design Patterns Gang Qian Department of Computer Science University of Central Oklahoma.
Computer Science 313 – Advanced Programming Topics.
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
CSC 313 – Advanced Programming Topics. What Is the Factory Method?  Creation details hidden by AbstractCreator  Does effective job of limiting concrete.
Design Patterns Yonglei Tao. Design Patterns  A design pattern describes a recurring design problem, a solution, and the context in which that solution.
The Singleton Pattern SE-2811 Dr. Mark L. Hornick 1.
Object Oriented Analysis & Design Game Patterns. Contents  What patterns are  Delegation  Game Loop  Scene Graph  Double Buffering  Component 
IOS Best Practices: Avoid the Bloat
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
CS212: Object Oriented Analysis and Design Lecture 38: Design Pattern-II.
Interfaces Chapter 9. 9 Creating Interfaces An interface is a contract. Every class that implements the interface must provide the interface’s defined.
Religious Studies 313 – Advanced Programming Topics.
Advanced Object-oriented Design Patterns Creational Design Patterns.
March 1, 2004CS WPI1 CS 509 Design of Software Systems Lecture #6 Monday, March 1, 2004.
Singleton Pattern Presented By:- Navaneet Kumar ise
The Singleton Pattern (Creational)
Week 12 - Monday.  What did we talk about last time?  Defining classes  Class practice  Lab 11.
Singleton Pattern. Problem Want to ensure a single instance of a class, shared by all uses throughout a program Context Need to address initialization.
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.
Overview of Creational Patterns ©SoftMoore ConsultingSlide 1.
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
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.
GC Assertions: Using the Garbage Collector To Check Heap Properties Samuel Z. Guyer Tufts University Edward Aftandilian Tufts University.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
By: Lacey Williams. Introduction Troubles in CS education Lack of comprehension of the basics Seen in first-year CS students Are there long-term effects?
XuanTung Hoang 1 Something to discuss Feedbacks on Midterm Exam Final exam and term project  Final exam requires solid knowledge/skills in Java  Be more.
Generator Design Patterns: Singleton and Prototype
Lecture 6 of Computer Science II
Unit II-Chapter No. : 5- design Patterns
Game Architecture Rabin is a good overview of everything to do with Games A lot of these slides come from the 1st edition CS 4455.
MPCS – Advanced java Programming
Design Patterns C++ Java C#.
The Singleton Pattern SE-2811 Dr. Mark L. Hornick.
Design Patterns C++ Java C#.
PH page GoF Singleton p Emanuel Ekstrom.
Object Oriented Design Patterns - Creational Patterns
Improving the structure of existing code
What is Singleton Category: Creational pattern
Singleton Pattern Pattern Name: Singleton Pattern Context
Topics discussed in this section:
CS 350 – Software Design Singleton – Chapter 21
Presentation transcript:

Computer Science 313 – Advanced Programming Topics

How Can We Code…

Why One Is Better  Can create improvement from uniqueness  Easy universal access to important resources  Error checks and complex locks eliminated  Avoid allocating large number of small objects  Simplifies calculating space-time tradeoffs

One Is The Loneliest Number  Correctness easy with only one object  Trigger for an error is pretty easy to find  Enforcing order of actions much quicker  Problem over which instance dominates is solved

Where To Find Singletons?  Graphic & game engines  System.out  Bars  System.err  Grocery stores  Device drivers  Laundromats  Design patterns

Where To Find Singletons?  Graphic & game engines  System.out  Bars  System.err  Grocery stores  Device drivers  Laundromats  Design patterns

Where To Find Singletons?

Singleton Pattern  Ensures class has exactly 1 instance  Cannot create second instance of this class  Instance constant, but fields can change  Provides single access point to instance  To ease debugging, do not let reference leak  All uses of class must go through that instance

Singleton Usage  Singleton is harmful when a global variable  public static field used for instance  Eliminates ability to track updates & changes  Common anti-pattern is using global variable  Anti-patterns are habits that harm development Big Ball Of Mud Throwaway Code Kill Two Birds With One Stone Design By Committee

Singleton Pattern  System uses exactly 1 instance of the class  Instantiates only 1 instance during entire program  Guarantees that program uses only single instance  Does not restrict methods in any way  Can define and use fields like normal  Creational pattern like the factory patterns  How we (do not) create instances is focus  Usage unimportant and should not be considered

Singleton Pattern Guides D O NOT use for  1 instance wanted  Global value  Instead use static field  Poor design suggested  Instantiation check  Use factory method D O use for  1 instance possible  Global access point  For a global resource  Gatekeeper for actions  Optimize performance  Can be easily removed

For Next Class  Lab #4 on Angel  Implement Singleton 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?