Refactoring to
|
|
- Basil Clyde Crawford
- 5 years ago
- Views:
Transcription
1 Refactoring to
2
3
4
5
6 Functional programming combines the flexibility and power of abstract mathematics with the intuitive clarity of abstract mathematics.
7 Functional programming typically avoids using mutable state.
8 Asking a question should not change the answer. Bertrand Meyer
9 Asking a question should not change the answer, and nor should asking it twice!
10
11 Referential transparency is a very desirable property: it implies that functions consistently yield the same results given the same input, irrespective of where and when they are invoked. That is, function evaluation depends less ideally, not at all on the side effects of mutable state. Edward Garson "Apply Functional Programming Principles"
12 your code should be reasonable
13 you should be able to reason about code
14 A large fraction of the flaws in software development are due to programmers not fully understanding all the possible states their code may execute in. John Carmack
15
16
17 A large fraction of the flaws in software development are due to programmers not fully understanding all the possible states their code may execute in. In a multithreaded environment, the lack of understanding and the resulting problems are greatly amplified, almost to the point of panic if you are paying attention. John Carmack
18 Threads
19 Locks
20 Unshared mutable data needs no synchronisation Unshared Mutable Shared mutable data needs synchronisation Shared Unshared immutable data needs no synchronisation Immutable Shared immutable data needs no synchronisation
21 Mutable The Synchronisation Quadrant Unshared mutable data needs no synchronisation Unshared Shared mutable data needs synchronisation Shared Unshared immutable data needs no synchronisation Immutable Shared immutable data needs no synchronisation
22
23 Architecture represents the significant design decisions that shape a system, where significant is measured by cost of change. Grady Booch
24 As an evolving program is continually changed, its complexity, reflecting deteriorating structure, increases unless work is done to maintain or reduce it. Meir M Lehman
25
26 µονόλιθος
27
28 Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior. Refactor (verb): to restructure software by applying a series of refactorings without changing the observable behavior of the software.
29
30 Functional Operational Developmental
31 Functional Operational Developmental
32 Many programming languages support programming in both functional and imperative style but the syntax and facilities of a language are typically optimised for only one of these styles, and social factors like coding conventions and libraries often force the programmer towards one of the styles.
33
34 public class Clock public static Clock Instance =>... public TimeOfDay Now =>......
35 public void Example() var now = Clock.Instance.Now;...
36 public void Example(Clock clock) var now = clock.now;...
37 public interface Clock TimeOfDay Now =>... public class ClockImpl : Clock public static Clock Instance =>......
38 public interface IClock TimeOfDay Now =>... public class Clock : IClock public static IClock Instance =>......
39 public interface IClock TimeOfDay Now =>... public class LocalClock : IClock public static IClock Instance =>......
40 public interface Clock TimeOfDay Now =>... public class LocalClock : Clock public static Clock Instance =>......
41 public void Example(Func<TimeOfDay> timeofday) var now = timeofday();...
42 public void Example(TimeOfDay now)...
43 If you have a procedure with ten parameters, you probably missed some. Alan Perlis
44 Reduce Scope of Variable Declare variables at the point of their initialisation. Variables used in a single block should be declared in it. Fields used in a single method invocation should be variables local to that method. Replace Second Assignment to a Variable with New Variable Instead of accumulating changes in a variable, use different variables to represent changes. Pass Globals as Parameters Make dependencies explicit by passing them as arguments rather than relying on global access. Replace Long Parameter List with Parameter Object Group cohesive parameters together as objects. These are often value types, and may also reveal new domain types. Replace Resource Passing with Direct Value Instead of passing suppliers, factories, etc. to methods, pass the result of their use directly.
45
46
47 Immutable Value Define a value object type whose instances are immutable. The internal state of a value object is set at construction and no subsequent modifications are allowed.
48 public class TimeOfDay... public int Hour get... set... public int Minute get... set... public void NextHour()... public void NextMinute()...
49 public class TimeOfDay private int minutes; public const int minutesinhour = 60; public const int hoursinday = 24; public const int minutesinday = hoursinday * minutesinhour; private static int Wrap(int minutes) return minutes % minutesinday; public int Hour get return minutes / minutesinhour; set if (value < 0 value >= hoursinday) throw new ArgumentException(); minutes = Wrap(value * minutesinhour + Minute); public int Minute get return minutes % minutesinhour; set if (value < 0 value >= minutesinhour) throw new ArgumentException(); minutes = Wrap(Hour * minutesinhour + value); public void NextHour() minutes = Wrap(minutes + minutesinhour); public void NextMinute() minutes = Wrap(minutes + 1);
50 public class TimeOfDay... public int Hour get... set... public int Minute get... set... public void NextHour()... public void NextMinute()...
51 public class TimeOfDay... public int Hour get... public int Minute get... public void NextHour()... public void NextMinute()...
52 public class TimeOfDay... public int Hour =>... public int Minute =>... public void NextHour()... public void NextMinute()...
53 public class TimeOfDay... public int Hour =>... public int Minute =>... public TimeOfDay WithHour(int newhour)... public TimeOfDay WithMinute(int newminute)... public void NextHour()... public void NextMinute()...
54 public class TimeOfDay... public int Hour =>... public int Minute =>... public TimeOfDay WithHour(int newhour)... public TimeOfDay WithMinute(int newminute)... public TimeOfDay NextHour()... public TimeOfDay NextMinute()...
55 public class TimeOfDay... public TimeOfDay(int hour, int minute)... public int Hour =>... public int Minute =>... public TimeOfDay WithHour(int newhour)... public TimeOfDay WithMinute(int newminute)... public TimeOfDay NextHour()... public TimeOfDay NextMinute()...
56 public class TimeOfDay... public TimeOfDay(int hour, int minute)... public int Hour =>... public int Minute =>... public TimeOfDay WithHour(int newhour)... public TimeOfDay WithMinute(int newminute)... public TimeOfDay NextHour()... public TimeOfDay NextMinute()... public class Builder...
57 public class TimeOfDay private readonly int minutes; public const int minutesinhour = 60; public const int hoursinday = 24; public const int minutesinday = hoursinday * minutesinhour; private TimeOfDay(int minutes) this.minutes = minutes % minutesinday; public TimeOfDay(int hour, int minute) if (hour < 0 hour >= hoursinday minute < 0 minute >= minutesinhour) throw new ArgumentException(); minutes = hour * minutesinhour + minute; public int Hour => minutes / minutesinhour; public int Minute => minutes % minutesinhour; public TimeOfDay WithHour(int newhour) => new TimeOfDay(newHour, Minute); public TimeOfDay WithMinute(int newminute) => new TimeOfDay(Hour, newminute); public TimeOfDay NextHour() => new TimeOfDay(minutes + minutesinhour); public TimeOfDay NextMinute() => new TimeOfDay(minutes + 1);...
58 Remove Modifiers Remove unused modifiers (e.g., setters) and consider Replace Modifiers with Constructors, Extract Modifiers to Builder and Make Void Methods Fluent. Replace Modifications with Constructors Many sequences of modification can often be replaced with a broader set of meaningful constructors. Move Modifiers to Builder Define a mutable companion class to handle sequences of modification (cf. String and StringBuilder). Replace Side Effect with New Object Return a new object instead of changing an existing one. Often Make Void Methods Fluent is a useful stepping stone. Make Void Methods Fluent Have a method return an existing or new object the caller can chain from.
59
60 A book is simply the container of an idea like a bottle; what is inside the book is what matters. Angela Carter
61 public class Stack<T> private List<T> items = new ArrayList<>(); public int depth() return items.size(); public T top() if (depth() == 0) throw new IllegalStateException(); return items.get(depth() - 1); public void pop() if (depth() == 0) throw new IllegalStateException(); items.remove(depth() - 1); public void push(t newtop) items.add(newtop);
62 In computing, a persistent data structure is a data structure that always preserves the previous version of itself when it is modified. Such data structures are effectively immutable, as their operations do not (visibly) update the structure in-place, but instead always yield a new updated structure. (A persistent data structure is not a data structure committed to persistent storage, such as a disk; this is a different and unrelated sense of the word "persistent.")
63
64
65
66
67
68
69
70 public interface Stack<T> int depth(); T top(); Stack<T> pop(); Stack<T> push(t newtop);...
71 public interface Stack<T>... class Empty<T> implements Stack<T> public int depth() return 0; public T top() throw new IllegalStateException(); public Stack<T> pop() throw new IllegalStateException(); public Stack<T> push(t newtop) return new NonEmpty(newTop, this);...
72 public interface Stack<T>... default Stack<T> push(t newtop) return new NonEmpty<>(newTop, this); class Empty<T> implements Stack<T> public int depth() return 0; public T top() throw new IllegalStateException(); public Stack<T> pop() throw new IllegalStateException();...
73 public interface Stack<T>... class NonEmpty<T> implements Stack<T> private T top; private Stack<T> tail; public NonEmpty(T newtop, Stack<T> previous) top = newtop; tail = previous; public int depth() return 1 + tail.depth(); public T top() return top; public Stack<T> pop() return tail;
74 The goal of the Anti-IF Campaign is to raise awareness of the effective use of software design principles and practices, by first of all removing bad, dangerous IFs.
75 Stack<String> stack = new Stack<>(); stack.push("sdd"); stack.push("2018");
76 Stack<String> stack = new Stack.Empty<>(); stack = stack.push("sdd").push("2018");
77 public interface Stack<T> int depth(); T top(); Stack<T> pop(); Stack<T> push(t newtop);... Either T must be a type whose instances are immutable, or only instances that will remain immutable may be pushed.
78 Replace Mutable Collection with Persistent Collection Use, create or repurpose a mutable collection with or as a persistent collection, i.e., one that is effectively immutable to referential observers, allowing sharing without cost of copying. Replace Mutable Collection Values with Immutable Values A collection that is itself unchanging or persistent cannot preserve its immutability guarantee if its collected references are mutable, so use immutable values for collection elements. Replace State-based Object Behaviour with Polymorphism Replace flags that are unchanging for a given collection, but cause branching to different behaviours, with polymorphism, i.e., use instances of types to represent the behavioural differences.
79
80
81 try Integer.parseInt(time.substring(0, 2)); catch (Exception x) return false; if (Integer.parseInt(time.substring(0, 2)) > 12) return false;... if (!time.substring(9, 11).equals("AM") &!time.substring(9, 11).equals("PM")) return false; Burk Hufnagel "Put the Mouse Down and Step Away from the Keyboard"
82 public static boolean validatetime(string time) return time.matches("(0[1-9] 1[0-2]):[0-5][0-9]:[0-5][0-9] ([AP]M)"); Burk Hufnagel "Put the Mouse Down and Step Away from the Keyboard"
83
84
85
86 intension, n. (Logic) The set of characteristics or properties by which the referent or referents of a given expression is determined. The sense of an expression that determines its reference in every possible world, as opposed to its actual reference. For example, the intension of prime number may be having non-trivial integral factors, whereas its extension would be the set 2, 3, 5, 7,... E J Borowski and J M Borwein Dictionary of Mathematics
87 x 2 x, x 1 x 100 select from where
88 A list comprehension is a syntactic construct available in some programming languages for creating a list based on existing lists. It follows the form of the mathematical setbuilder notation (set comprehension) as distinct from the use of map and filter functions.
89
90
91 // Get the unique surnames in uppercase of the // first 15 book authors that are 50 years old // or older? library.stream().map(book -> book.getauthor()).filter(author -> author.getage() >= 50).limit(15).map(Author::getSurname).map(String::toUpperCase).distinct().collect(toList())
92 // Get the first 15 unique surnames in // uppercase of the book authors that are 50 // years old or older. library.stream().map(book -> book.getauthor()).filter(author -> author.getage() >= 50).map(Author::getSurname).map(String::toUpperCase).distinct().limit(15).collect(toList())
93 // Get the unique surnames in uppercase of the // first 15 book authors that are 50 years old // or older. library.stream().map(book -> book.getauthor()).filter(author -> author.getage() >= 50).distinct().limit(15).map(Author::getSurname).map(String::toUpperCase).distinct().collect(toList())
94 // Get the unique surnames in uppercase of the // first 15 book authors that are 50 years old // or older. library.stream().map(book -> book.getauthor()).distinct().filter(author -> author.getage() >= 50).limit(15).map(Author::getSurname).map(String::toUpperCase).distinct().collect(toList())
95 Simple filters that can be arbitrarily chained are more easily re-used, and more robust, than almost any other kind of code. Brandon Rhodes
96 // Get the unique surnames in uppercase of the // first 15 book authors that are 50 years old // or older? List<Author> authors = new ArrayList<Author>(); for (Book book : library) Author author = book.getauthor(); if (author.getage() >= 50) authors.add(author); if (authors.size() == 15) break;
97 // Get the unique surnames in uppercase of the // first 15 book authors that are 50 years old // or older? List<Author> authors = new ArrayList<Author>(); for (Book book : library) Author author = book.getauthor(); if (author.getage() >= 50) authors.add(author); if (authors.size() == 15) break; List<String> result = new ArrayList<String>(); for(author author : authors) String name = author.getsurname().touppercase(); if (!result.contains(name)) result.add(name);
98 // Get the first 15 unique surnames in // uppercase of the book authors that are 50 // years old or older. List<String> result = new ArrayList<String>(); for (Book book : library) Author author = book.getauthor(); if (author.getage() >= 50) String name = author.getsurname().touppercase(); if (!result.contains(name)) result.add(name); if (result.size() == 15) break;
99 // Get the unique surnames in uppercase of the // first 15 book authors that are 50 years old // or older. List<Author> authors = new ArrayList<Author>(); for (Book book : library) Author author = book.getauthor(); if (author.getage() >= 50 &&!authors.contains(author)) authors.add(author); if (authors.size() == 15) break; List<String> result = new ArrayList<String>(); for(author author : authors) String name = author.getsurname().touppercase(); if (!result.contains(name)) result.add(name);
100 Try to leave out the part that readers tend to skip. Elmore Leonard
101 // Get the unique surnames in uppercase of the // first 15 book authors that are 50 years old // or older, in Java. library.stream().map(book -> book.getauthor()).distinct().filter(author -> author.getage() >= 50).limit(15).map(Author::getSurname).map(String::toUpperCase).distinct().collect(toList())
102 // Get the unique surnames in uppercase of the // first 15 book authors that are 50 years old // or older, in C#. library.select(book => book.author).distinct().where(author => author.age >= 50).Take(15).Select(author => author.surname).select(name => name.toupper()).distinct().tolist()
103 // Get the unique surnames in uppercase of the // first 15 book authors that are 50 years old // or older, in C#. library.select(book => book.author).distinct().where(author => author.age >= 50).Take(15).Select(author => author.surname.toupper()).distinct().tolist()
104 Extract Iteration Repetition is repetitive, so factor out common loops into appropriately named and parameterised methods. Extract Control Flow as Higher-Order Functions Much control flow has stable structure but variable conditions or actions, so use pluggable behaviour. Replace Control Flow with Data Structure Many data structures embody control intelligence, e.g., sorted collections and regular expressions, so replace long-hand logic and control with more intelligent data structures. Replace Control Flow with Data Flow Use pipelines, polymorphism and higher-order methods to replace control flow with data flow. Replace Loop with Stream Filtering Use collection pipelines to replace explicit looping and control flow with data flow.
105 When it is not necessary to change, it is necessary not to change. Lucius Cary
Immutability @KevlinHenney Change is the only constant. Heraclitus When it is not necessary to change, it is necessary not to change. Lucius Cary Mutable Unshared mutable data needs no synchronisation
More informationProcedural Programming. It's Back? It Never Went
Procedural Programming It's Back? It Never Went Away @KevlinHenney procedural? µονόλιθος µservices µservices This is the Unix philosophy: Write programs that do one thing and do it well. Write programs
More informationStreams in Java 8. Start programming in a more functional style
Streams in Java 8 Start programming in a more functional style Background Who am I? Tobias Coetzee I m a Technical Lead at BBD I present the Java Expert Level Certifications at BBD (EJB, JPA, etc.) I m
More informationJava Fundamentals (II)
Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Java Fundamentals (II) Marco Piccioni static imports Introduced in 5.0 Imported static members of a class
More informationUpcoming Features in C# Mads Torgersen, MSFT
Upcoming Features in C# Mads Torgersen, MSFT This document describes language features currently planned for C# 6, the next version of C#. All of these are implemented and available in VS 2015 Preview.
More informationContents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix
PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring
More informationData Structure. Recitation IV
Data Structure Recitation IV Topic Java Generics Java error handling Stack Lab 2 Java Generics The following code snippet without generics requires casting: List list = new ArrayList(); list.add("hello");
More informationCollections, Maps and Generics
Collections API Collections, Maps and Generics You've already used ArrayList for exercises from the previous semester, but ArrayList is just one part of much larger Collections API that Java provides.
More informationIndex. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107
A abbreviations 17 abstract class 105 abstract data types 105 abstract method 105 abstract types 105 abstraction 92, 105 access level 37 package 114 private 115 protected 115 public 115 accessors 24, 105
More informationFunctional programming in C#
Functional programming in C# A quick approach to another paradigm Nacho Iborra IES San Vicente This work is licensed under the Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License.
More informationCS4215 Programming Language Implementation. Martin Henz
CS4215 Programming Language Implementation Martin Henz Thursday 15 March, 2012 2 Chapter 11 impl: A Simple Imperative Language 11.1 Introduction So far, we considered only languages, in which an identifier
More informationPreface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS
Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...
More informationHandout 10: Imperative programs and the Lambda Calculus
06-02552 Princ of Progr Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 10: Imperative programs and the Lambda Calculus
More informationJVM ByteCode Interpreter
JVM ByteCode Interpreter written in Haskell (In under 1000 Lines of Code) By Louis Jenkins Presentation Schedule ( 15 Minutes) Discuss and Run the Virtual Machine first
More informationCS113: Lecture 4. Topics: Functions. Function Activation Records
CS113: Lecture 4 Topics: Functions Function Activation Records 1 Why functions? Functions add no expressive power to the C language in a formal sense. Why have them? Breaking tasks into smaller ones make
More informationCS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?
CS6501 - Internet programming Unit- I Part - A 1 Define Java. Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed to have the "look
More informationSummer Final Exam Review Session August 5, 2009
15-111 Summer 2 2009 Final Exam Review Session August 5, 2009 Exam Notes The exam is from 10:30 to 1:30 PM in Wean Hall 5419A. The exam will be primarily conceptual. The major emphasis is on understanding
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationDesign Stories Exploring and Creating Code from a Narrative Perspective Kevlin
Design Stories Exploring and Creating Code from a Narrative Perspective Kevlin Henney kevlin@curbralan.com @KevlinHenney See http://programmer.97things.oreilly.com (also http://tinyurl.com/97tepsk) and
More informationhttps://asd-pa.perfplusk12.com/admin/admin_curric_maps_display.aspx?m=5507&c=618&mo=18917&t=191&sy=2012&bl...
Page 1 of 13 Units: - All - Teacher: ProgIIIJavaI, CORE Course: ProgIIIJavaI Year: 2012-13 Intro to Java How is data stored by a computer system? What does a compiler do? What are the advantages of using
More information15CS45 : OBJECT ORIENTED CONCEPTS
15CS45 : OBJECT ORIENTED CONCEPTS QUESTION BANK: What do you know about Java? What are the supported platforms by Java Programming Language? List any five features of Java? Why is Java Architectural Neutral?
More informationPrinciples of Software Construction: Objects, Design and Concurrency. Mutability and Java Potpourri. toad Fall 2013
Principles of Software Construction: Objects, Design and Concurrency Mutability and Java Potpourri 15-214 toad Fall 2013 Jonathan Aldrich Charlie Garrod School of Computer Science 2012-13 C Garrod, J Aldrich,
More informationJava SE 8 Programming
Oracle University Contact Us: +52 1 55 8525 3225 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features and Application Programming
More informationJava Programming Training for Experienced Programmers (5 Days)
www.peaklearningllc.com Java Programming Training for Experienced Programmers (5 Days) This Java training course is intended for students with experience in a procedural or objectoriented language. It
More informationUNIT 3
UNIT 3 Presentation Outline Sequence control with expressions Conditional Statements, Loops Exception Handling Subprogram definition and activation Simple and Recursive Subprogram Subprogram Environment
More informationAbsolute C++ Walter Savitch
Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents
More informationCourse Hours
Programming the.net Framework 4.0/4.5 with C# 5.0 Course 70240 40 Hours Microsoft's.NET Framework presents developers with unprecedented opportunities. From 'geoscalable' web applications to desktop and
More informationReferences: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1
References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1 Assertions Statements about input to a routine or state of a class Have two primary roles As documentation,
More informationProblem Solving with C++
GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter
More informationOPENMP TIPS, TRICKS AND GOTCHAS
OPENMP TIPS, TRICKS AND GOTCHAS OpenMPCon 2015 2 Directives Mistyping the sentinel (e.g.!omp or #pragma opm ) typically raises no error message. Be careful! Extra nasty if it is e.g. #pragma opm atomic
More informationJava SE 8 Programming
Java SE 8 Programming Training Calendar Date Training Time Location 16 September 2019 5 Days Bilginç IT Academy 28 October 2019 5 Days Bilginç IT Academy Training Details Training Time : 5 Days Capacity
More informationCMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.
CMSC131 Inheritance Object When we talked about Object, I mentioned that all Java classes are "built" on top of that. This came up when talking about the Java standard equals operator: boolean equals(object
More informationCourse Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline ::
Module Title Duration : Intro to JAVA SE7 and Programming using JAVA SE7 : 9 days Course Description The Java SE 7 Fundamentals course was designed to enable students with little or no programming experience
More informationCosc 241 Programming and Problem Solving Lecture 9 (26/3/18) Collections and ADTs
1 Cosc 241 Programming and Problem Solving Lecture 9 (26/3/18) Collections and ADTs Michael Albert michael.albert@cs.otago.ac.nz Keywords: abstract data type, collection, generic class type, stack 2 Collections
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter
More informationCA Compiler Construction
CA4003 - Compiler Construction Semantic Analysis David Sinclair Semantic Actions A compiler has to do more than just recognise if a sequence of characters forms a valid sentence in the language. It must
More informationLTBP INDUSTRIAL TRAINING INSTITUTE
Java SE Introduction to Java JDK JRE Discussion of Java features and OOPS Concepts Installation of Netbeans IDE Datatypes primitive data types non-primitive data types Variable declaration Operators Control
More informationDiscover how to get up and running with the Java Development Environment and with the Eclipse IDE to create Java programs.
Java SE11 Development Java is the most widely-used development language in the world today. It allows programmers to create objects that can interact with other objects to solve a problem. Explore Java
More information03 Features of C#, Part 2. Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211
03 Features of C#, Part 2 Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211 Module Overview Controlling Programmatic Flow Manipulating Types and Strings Controlling
More informationSoftware. Is
Software Is Details @KevlinHenney Any program is a model of a model within a theory of a model of an abstraction of some portion of the world or of some universe of discourse. Meir M Lehman "Programs,
More informationJava SE 8 Programming
Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 67863102 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features
More informationIT Web and Software Developer Software Development Standards
IT Web and Software Developer Software Development Standards Definition of terms Identifier An identifier is the name you give variables, methods, classes, packages, interfaces and named constants. Pascal
More informationClasses and Methods גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון
Classes and Methods גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון 2 Roadmap Lectures 4 and 5 present two sides of OOP: Lecture 4 discusses the static, compile time representation of object-oriented
More informationCOEN244: Class & function templates
COEN244: Class & function templates Aishy Amer Electrical & Computer Engineering Templates Function Templates Class Templates Outline Templates and inheritance Introduction to C++ Standard Template Library
More informationTokens, Expressions and Control Structures
3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type
More informationCSCI387 Data Structure Fall. Aug. 21, 2012 Sung Hee Park Computer Science Virginia State University
CSCI387 Data Structure- 2012 Fall Aug. 21, 2012 Sung Hee Park Computer Science Virginia State University Abstract Data Type (ADT) A mathematical model a certain class of data structures Certain data types
More informationEnums. In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed.
Enums Introduction In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed. The Final Tag To display why this is useful, I m going to
More informationSoftware Development & Education Center. Java Platform, Standard Edition 7 (JSE 7)
Software Development & Education Center Java Platform, Standard Edition 7 (JSE 7) Detailed Curriculum Getting Started What Is the Java Technology? Primary Goals of the Java Technology The Java Virtual
More informationClasses and Methods עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון מבוסס על השקפים של אותו קורס שניתן בשנים הקודמות
Classes and Methods עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון מבוסס על השקפים של אותו קורס שניתן בשנים הקודמות 2 Roadmap Lectures 4 and 5 present two sides of OOP: Lecture 4 discusses the static,
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationSoftware. Is
Software Is Details @KevlinHenney Any program is a model of a model within a theory of a model of an abstraction of some portion of the world or of some universe of discourse. Meir M Lehman "Programs,
More informationOPENMP TIPS, TRICKS AND GOTCHAS
OPENMP TIPS, TRICKS AND GOTCHAS Mark Bull EPCC, University of Edinburgh (and OpenMP ARB) markb@epcc.ed.ac.uk OpenMPCon 2015 OpenMPCon 2015 2 A bit of background I ve been teaching OpenMP for over 15 years
More informationReviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013
Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Things to Review Review the Class Slides: Key Things to Take Away Do you understand
More informationGenerics in Java. EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG
Generics in Java EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG Motivating Example: A Book of Objects 1 class Book { 2 String[] names; 3 Object[] records; 4 /* add a name-record
More informationType Hierarchy. Comp-303 : Programming Techniques Lecture 9. Alexandre Denault Computer Science McGill University Winter 2004
Type Hierarchy Comp-303 : Programming Techniques Lecture 9 Alexandre Denault Computer Science McGill University Winter 2004 February 16, 2004 Lecture 9 Comp 303 : Programming Techniques Page 1 Last lecture...
More informationMotivating Example: Observations (1) Generics in Java. Motivating Example: A Book of Objects. Motivating Example: Observations (2)
Motivating Example: Observations (1) Generics in Java EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG In the Book class: By declaring the attribute Object[] records We meant that
More informationA Third Look At Java. Chapter Seventeen Modern Programming Languages, 2nd ed. 1
A Third Look At Java Chapter Seventeen Modern Programming Languages, 2nd ed. 1 A Little Demo public class Test { public static void main(string[] args) { int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]);
More informationFunctional Programming for Imperative Programmers
Functional Programming for Imperative Programmers R. Sekar This document introduces functional programming for those that are used to imperative languages, but are trying to come to terms with recursion
More informationGoal. Generic Programming and Inner classes. Minor rewrite of linear search. Obvious linear search code. Intuitive idea of generic linear search
Goal Generic Programming and Inner classes First version of linear search Input was array of int More generic version of linear search Input was array of Comparable Can we write a still more generic version
More informationIntroducing Wybe a language for everyone
Introducing Wybe a language for everyone Peter Schachte joint work with Matthew Giuca The University of Melbourne Department of Computing and Information Systems 4 December 2013 Peter Schachte (Melbourne)
More informationCS180 Review. Recitation Week 15
CS180 Review Recitation Week 15 Announcement Final exam will be held on Thursday(12/17) 8:00~10:00 AM The coverage is comprehensive Project 5 is graded. Check your score in Blackboard. Classes and Methods
More informationProgramming Languages Third Edition. Chapter 9 Control I Expressions and Statements
Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE
More informationClasses and Methods לאוניד ברנבוים המחלקה למדעי המחשב אוניברסיטת בן-גוריון
Classes and Methods לאוניד ברנבוים המחלקה למדעי המחשב אוניברסיטת בן-גוריון 22 Roadmap Lectures 4 and 5 present two sides of OOP: Lecture 4 discusses the static, compile time representation of object-oriented
More informationConcurrent and Real-Time Programming in Java
064202 Degree Examinations 2003 DEPARTMENT OF COMPUTER SCIENCE Concurrent and Real-Time Programming in Java Time allowed: One and one half (1.5) hours Candidates should answer not more than two questions.
More informationReview sheet for Final Exam (List of objectives for this course)
Review sheet for Final Exam (List of objectives for this course) Please be sure to see other review sheets for this semester Please be sure to review tests from this semester Week 1 Introduction Chapter
More informationCOMP 401 Spring 2014 Midterm 1
COMP 401 Spring 2014 Midterm 1 I have not received nor given any unauthorized assistance in completing this exam. Signature: Name: PID: Please be sure to put your PID at the top of each page. This page
More informationRecursion. Comp Sci 1575 Data Structures. Introduction. Simple examples. The call stack. Types of recursion. Recursive programming
Recursion Comp Sci 1575 Data Structures Outline 1 2 3 4 Definitions To understand, you must understand. Familiar of recursive definitions Natural numbers are either: n+1, where n is a natural number 1
More informationGE PROBLEM SOVING AND PYTHON PROGRAMMING. Question Bank UNIT 1 - ALGORITHMIC PROBLEM SOLVING
GE8151 - PROBLEM SOVING AND PYTHON PROGRAMMING Question Bank UNIT 1 - ALGORITHMIC PROBLEM SOLVING 1) Define Computer 2) Define algorithm 3) What are the two phases in algorithmic problem solving? 4) Why
More informationA Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 5 Programming with Locks and Critical Sections
A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 5 Programming with Locks and Critical Sections Dan Grossman Last Updated: May 2012 For more information, see http://www.cs.washington.edu/homes/djg/teachingmaterials/
More informationCPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia
CPL 2016, week 10 Clojure functional core Oleg Batrashev Institute of Computer Science, Tartu, Estonia April 11, 2016 Overview Today Clojure language core Next weeks Immutable data structures Clojure simple
More informationDOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS
Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully
More informationCS111: PROGRAMMING LANGUAGE II
CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A
More informationConfiguration Provider: A Pattern for Configuring Threaded Applications
Configuration Provider: A Pattern for Configuring Threaded Applications Klaus Meffert 1 and Ilka Philippow 2 Technical University Ilmenau plop@klaus-meffert.de 1, ilka.philippow@tu-ilmena.de 2 Abstract
More informationCSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections. Tyler Robison Summer 2010
CSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections Tyler Robison Summer 2010 1 Concurrency: where are we Done: The semantics of locks Locks in Java Using locks for mutual
More informationArray. Prepared By - Rifat Shahriyar
Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types
More informationCONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17
List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code
More information1 Shyam sir JAVA Notes
1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write
More informationChapter 15 - C++ As A "Better C"
Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference
More informationThe following topics will be covered in this course (not necessarily in this order).
The following topics will be covered in this course (not necessarily in this order). Introduction The course focuses on systematic design of larger object-oriented programs. We will introduce the appropriate
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More information(a) Write the signature (visibility, name, parameters, types) of the method(s) required
1. (6 pts) Is the final comprehensive? 1 2. (6 pts) Java has interfaces Comparable and Comparator. As discussed in class, what is the main advantage of Comparator? 3. (6 pts) We can use a comparator in
More informationProgramming Languages. Streams Wrapup, Memoization, Type Systems, and Some Monty Python
Programming Languages Streams Wrapup, Memoization, Type Systems, and Some Monty Python Quick Review of Constructing Streams Usually two ways to construct a stream. Method 1: Use a function that takes a(n)
More informationCE204 Data Structures and Algorithms Part 2
CE204 Data Structures and Algorithms Part 2 14/01/2018 CE204 Part 2 1 Abstract Data Types 1 An abstract data type is a type that may be specified completely without the use of any programming language.
More information9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement
Outline Expression Evaluation and Control Flow In Text: Chapter 6 Notation Operator evaluation order Operand evaluation order Overloaded operators Type conversions Short-circuit evaluation of conditions
More informationThe New Java Technology Memory Model
The New Java Technology Memory Model java.sun.com/javaone/sf Jeremy Manson and William Pugh http://www.cs.umd.edu/~pugh 1 Audience Assume you are familiar with basics of Java technology-based threads (
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing
More informationCOL728 Minor2 Exam Compiler Design Sem II, Answer all 5 questions Max. Marks: 20
COL728 Minor2 Exam Compiler Design Sem II, 2017-18 Answer all 5 questions Max. Marks: 20 1. Short questions a. Give an example of a program that is not a legal program if we assume static scoping, but
More informationComputing Fundamentals Advanced functions & Recursion
Computing Fundamentals Advanced functions & Recursion Salvatore Filippone salvatore.filippone@uniroma2.it 2014 2015 (salvatore.filippone@uniroma2.it) Recursion 2014 2015 1 / 14 Anonymous functions Useful
More informationCSE 341, Autumn 2015, Ruby Introduction Summary
CSE 341, Autumn 2015, Ruby Introduction Summary Disclaimer: This lecture summary is not necessarily a complete substitute for atting class, reading the associated code, etc. It is designed to be a useful
More informationSome Advanced ML Features
Some Advanced ML Features Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming University of Washington: Dan Grossman ML is small Small number of powerful constructs
More informationLinked List Implementation of Queues
Outline queue implementation: linked queue application of queues and stacks: data structure traversal double-ended queues application of queues: simulation of an airline counter random numbers recursion
More informationCPSC 427: Object-Oriented Programming
CPSC 427: Object-Oriented Programming Michael J. Fischer Lecture 5 February 2, 2016 CPSC 427, Lecture 5 1/31 C++ I/O (continued) End of File and I/O Errors Functions and Methods Parameters Choosing Parameter
More informationI BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++
No. of Printed Pages : 3 I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination 05723. June, 2015 BCS-031 : PROGRAMMING IN C ++ Time : 3 hours Maximum Marks : 100 (Weightage 75%)
More informationThread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections
Thread Safety Today o Confinement o Threadsafe datatypes Required reading Concurrency Wrapper Collections Optional reading The material in this lecture and the next lecture is inspired by an excellent
More informationChapter 11. Abstract Data Types and Encapsulation Concepts ISBN
Chapter 11 Abstract Data Types and Encapsulation Concepts ISBN 0-321-49362-1 Chapter 11 Topics The Concept of Abstraction Introduction to Data Abstraction Design Issues for Abstract Data Types Language
More informationSubprograms, Subroutines, and Functions
Subprograms, Subroutines, and Functions Subprograms are also called subroutines, functions, procedures and methods. A function is just a subprogram that returns a value; say Y = SIN(X). In general, the
More informationPrinciples of Software Construction: Objects, Design and Concurrency. Exceptions, scope, static data and methods, and Generics.
Principles of Software Construction: Objects, Design and Concurrency 15-214 toad Exceptions, scope, static data and methods, and Generics Spring 2013 Christian Kästner Charlie Garrod School of Computer
More informationImplicit Evaluation of auto Variables and Arguments
Implicit Evaluation of auto Variables and Arguments Document number: N3748 Authors: Joël Falcou University Paris XI, LRI Peter Gottschling SimuNova Herb Sutter Microsoft Date: 2013-08-30 Project: Programming
More informationDesign Of JCSP Language Classes
Design Of JCSP Language Classes Paul Austin pda1@ukc.ac.uk University Of Kent Canterbury BSc Computer Science with an Industrial Year 3 rd Year Project Paul David Austin 1-May-1998 Contents 1 Introduction...1
More informationJava SE 8: Lambda Expressions And The Stream API
Java SE 8: Lambda Expressions And The Stream API Simon Ritter Head of Java Technology Evangelism Java Product Management Java Day Tokyo 2015 April 8, 2015 Safe Harbor Statement The following is intended
More information