Quality of the Source Code Lexicon

Size: px
Start display at page:

Download "Quality of the Source Code Lexicon"

Transcription

1 Quality of the Source Code Lexicon Venera Arnaoudova Mining & Modeling Unstructured Data in Software Challenges for the Future NII Shonan Meeting, March 206

2 Psychological Complexity meaningless or incorrect comments can be harmful." variable names of a reasonable length should make programs more understandable [Weissman, 974]

3 Psychological Complexity meaningless or incorrect comments can be harmful." variable names of a reasonable length should make programs more understandable [Weissman, 974] public static int (final String[] els, final String e) { int h = els.length; int l = -; while (h - l > ) { final int m = (l + h) / 2; if (els[m].compareto(e) > 0) { h = m; else { l = m; if (l == - els[l].compareto(e)!= 0) { return -; else { return l;

4 Psychological Complexity meaningless or incorrect comments can be harmful." variable names of a reasonable length should make programs more understandable public static int (final String[] sortedlist, final String element) { int highindex = sortedlist.length; int lowindex = -; while (highindex - lowindex > ) { final int middleindex = (lowindex + highindex) / 2; if (sortedlist[middleindex].compareto(element) > 0) { highindex = middleindex; else { lowindex = middleindex; if (lowindex == - sortedlist[lowindex].compareto(element)!= 0) { return -; else { return lowindex; [Weissman, 974]

5 Psychological Complexity meaningless or incorrect comments can be harmful." variable names of a reasonable length should make programs more understandable [Weissman, 974] public static int (final String[] els, final String e) { int h = els.length; int l = -; while (h - l > ) { final int m = (l + h) / 2; if (els[m].compareto(e) > 0) { h = m; else { l = m; if (l == - els[l].compareto(e)!= 0) { return -; else { return l; public static int (final String[] sortedlist, final String element) { int highindex = sortedlist.length; int lowindex = -; while (highindex - lowindex > ) { final int middleindex = (lowindex + highindex) / 2; if (sortedlist[middleindex].compareto(element) > 0) { highindex = middleindex; else { lowindex = middleindex; if (lowindex == - sortedlist[lowindex].compareto(element)!= 0) { return -; else { return lowindex;

6 Psychological Complexity meaningless or incorrect comments can be harmful." variable names of a reasonable length should make programs more understandable [Weissman, 974] Equal structural complexity: binary search algorithm public static int (final String[] els, final String e) { int h = els.length; int l = -; while (h - l > ) { final int m = (l + h) / 2; if (els[m].compareto(e) > 0) { h = m; else { l = m; if (l == - els[l].compareto(e)!= 0) { return -; else { return l; public static int (final String[] sortedlist, final String element) { int highindex = sortedlist.length; int lowindex = -; while (highindex - lowindex > ) { final int middleindex = (lowindex + highindex) / 2; if (sortedlist[middleindex].compareto(element) > 0) { highindex = middleindex; else { lowindex = middleindex; if (lowindex == - sortedlist[lowindex].compareto(element)!= 0) { return -; else { return lowindex; Extremely short identifiers More descriptive identifiers

7 Measuring the Quality of the Source Code Lexicon Shallow measures, e.g., length of variable names Individual identifiers, e.g., Lexicon Bad Smells [Abebe et al., 2009] Consistency among identifiers, e.g., Linguistic Antipatterns [Arnaoudova et al., 205] Consistency of identifiers with functionality, e.g., Debugging Method Names [Høst et Østvold, 2009]

8 Lexicon Bad Smells (LBS) [Abebe et al., 2009] Terms Structural Meaning Naming Rules Extreme contraction Odd grammatical structure Meaningless terms Useless type indication Misspelled terms Overloaded identifiers Similar names Wrong context Identifier construction Examples: Whole and parts Conceptual Hierarchy No hyponyms Inconsistent term

9 Lexicon Bad Smells (LBS) [Abebe et al., 2009] Terms Structural Meaning Naming Rules Extreme contraction Odd grammatical structure Meaningless terms Useless type indication Misspelled terms Overloaded identifiers Similar names Wrong context Identifier construction Examples: asz Whole and parts Conceptual Hierarchy No hyponyms Inconsistent term

10 Lexicon Bad Smells (LBS) [Abebe et al., 2009] Terms Structural Meaning Naming Rules Extreme contraction Odd grammatical structure Meaningless terms Useless type indication Misspelled terms Overloaded identifiers Similar names Wrong context Identifier construction Examples: asz addition() Whole and parts Conceptual Hierarchy No hyponyms Inconsistent term

11 Lexicon Bad Smells (LBS) [Abebe et al., 2009] Terms Structural Meaning Naming Rules Extreme contraction Odd grammatical structure Meaningless terms Useless type indication Misspelled terms Overloaded identifiers Similar names Wrong context Identifier construction Examples: asz addition() foo() Whole and parts Conceptual Hierarchy No hyponyms Inconsistent term

12 Lexicon Bad Smells (LBS) [Abebe et al., 2009] Terms Structural Meaning Naming Rules Extreme contraction Odd grammatical structure Meaningless terms Useless type indication Misspelled terms Overloaded identifiers Similar names Wrong context Identifier construction Examples: asz addition() foo() namestring Whole and parts Conceptual Hierarchy No hyponyms Inconsistent term

13 Linguistic Antipatterns (LAs) [Arnaoudova et al., 205] Behavior A. Does more than it says B. Says more than it does C. Does the opposite than it says State D. Contains more than it says E. Says more than it contains F. Contains the opposite than it says A. A.2 A.3 A.4 B. B.2 B.3 B.4 B.5 B.6 C. C.2 D. D.2 E. F. F.2 Get - more than an accessor Is returns more than a Boolean Set method returns Expecting but not getting a single instance Not implemented condition Validation method does not confirm Get method does not return Not answered question Transform method does not return Expecting but not getting a collection Method name and return type are opposite Method signature and comment are opposite Says one but contains many Name suggests Boolean but type does not Says many but contains one Attribute name and type are opposite Attribute signature and comment are opposite

14 Linguistic Antipatterns (LAs) [Arnaoudova et al., 205] Behavior A. Does more than it says B. Says more than it does C. Does the opposite than it says State D. Contains more than it says E. Says more than it contains F. Contains the opposite than it says A. A.2 A.3 A.4 B. B.2 B.3 B.4 B.5 B.6 C. C.2 D. D.2 E. F. F.2 Get - more than an accessor Is returns more than a Boolean Set method returns Expecting but not getting a single instance Not implemented condition Validation method does not confirm Get method does not return Not answered question Transform method does not return Expecting but not getting a collection Method name and return type are opposite Method signature and comment are opposite Says one but contains many Name suggests Boolean but type does not Says many but contains one Attribute name and type are opposite Attribute signature and comment are opposite

15 Linguistic Antipatterns (LAs) [Arnaoudova et al., 205] Behavior A. Does more than it says B. Says more than it does C. Does the opposite than it says State D. Contains more than it says E. Says more than it contains F. Contains the opposite than it says A. A.2 A.3 A.4 B. B.2 B.3 B.4 B.5 B.6 C. C.2 D. D.2 E. F. F.2 Get - more than an accessor Is returns more than a Boolean Dimension setbreadth(..) Expecting but not getting a single instance Not implemented condition Validation method does not confirm Get method does not return Not answered question Transform method does not return Expecting but not getting a collection Method name and return type are opposite Method signature and comment are opposite Says one but contains many Name suggests Boolean but type does not Says many but contains one Attribute name and type are opposite Attribute signature and comment are opposite

16 Linguistic Antipatterns (LAs) [Arnaoudova et al., 205] Behavior A. Does more than it says B. Says more than it does C. Does the opposite than it says State D. Contains more than it says E. Says more than it contains F. Contains the opposite than it says A. A.2 A.3 A.4 B. B.2 B.3 B.4 B.5 B.6 C. C.2 D. D.2 E. F. F.2 Get - more than an accessor Is returns more than a Boolean Dimension setbreadth(..) Expecting but not getting a single instance Not implemented condition Validation method does not confirm Get method does not return Not answered question Transform method does not return Expecting but not getting a collection Method name and return type are opposite Method signature and comment are opposite Says one but contains many Name suggests Boolean but type does not Says many but contains one Attribute name and type are opposite Attribute signature and comment are opposite

17 Linguistic Antipatterns (LAs) [Arnaoudova et al., 205] Behavior A. Does more than it says B. Says more than it does C. Does the opposite than it says State D. Contains more than it says E. Says more than it contains F. Contains the opposite than it says A. A.2 A.3 A.4 B. B.2 B.3 B.4 B.5 B.6 C. C.2 D. D.2 E. F. F.2 Get - more than an accessor Is returns more than a Boolean Dimension setbreadth(..) Expecting but not getting a single instance Not implemented condition Validation method does not confirm Get method does not return Not answered question Transform method does not return Expecting but not getting a collection EnterTransport exittransport(..) Method signature and comment are opposite Says one but contains many Name suggests Boolean but type does not Says many but contains one Attribute name and type are opposite Attribute signature and comment are opposite

18 Linguistic Antipatterns (LAs) [Arnaoudova et al., 205] Behavior A. Does more than it says B. Says more than it does C. Does the opposite than it says State D. Contains more than it says E. Says more than it contains F. Contains the opposite than it says A. A.2 A.3 A.4 B. B.2 B.3 B.4 B.5 B.6 C. C.2 D. D.2 E. F. F.2 Get - more than an accessor Is returns more than a Boolean Dimension setbreadth(..) Expecting but not getting a single instance Not implemented condition Validation method does not confirm Get method does not return Not answered question Transform method does not return Expecting but not getting a collection EnterTransport exittransport(..) Method signature and comment are opposite Says one but contains many Name suggests Boolean but type does not Says many but contains one Attribute name and type are opposite Attribute signature and comment are opposite

19 Linguistic Antipatterns (LAs) [Arnaoudova et al., 205] Behavior A. Does more than it says B. Says more than it does C. Does the opposite than it says State D. Contains more than it says E. Says more than it contains F. Contains the opposite than it says A. A.2 A.3 A.4 B. B.2 B.3 B.4 B.5 B.6 C. C.2 D. D.2 E. F. F.2 Get - more than an accessor Is returns more than a Boolean Dimension setbreadth(..) Expecting but not getting a single instance Not implemented condition Validation method does not confirm Get method does not return Not answered question Transform method does not return Expecting but not getting a collection EnterTransport exittransport(..) Method signature and comment are opposite Says one but contains many Name suggests Boolean but type does not boolean _statistics Attribute name and type are opposite Attribute signature and comment are opposite

20 Linguistic Anti-Patterns Detector (LAPD) C++ Java srcml xml XPath identifiers + structural information 6

21 C++ Linguistic Anti-Patterns Detector (LAPD) Submit Clear srcml xml XPath Java identifiers + structural information / JavadocNotVisibleReference Javadoc Stanford Not CoreNLP Visible Reference Stanford javadoc not CoreNLP visible reference Noun Adverb Adjective Noun Please NNenter your RB text JJhere: NN javadoc not visible reference amod Submit Clear neg NN RB JJ NN Part-of-Speech: javadoc not visible reference hidden JJ Extracting identifiers Splitting identifiers Stanford CoreNLP WordNet Part-of-Speech: / 8/4/204 Stanford CoreNLP javadoc hidden reference Visualisation provided using the brat visualisation/annotation software. Copyright 20, Stanford University, All Rights Reserved. amod Collapsed CC-processed endencies: javadoc hidden reference amod Collapsed endencies: javadoc hidden reference amod Basic endencies: javadoc hidden reference Coreference: javadoc hidden reference Named Entity Recognition: javadoc hidden reference Part-of-Speech: JavadocHiddenReference javadoc hidden reference 8/5/204 8/4/204 Stanford CoreNLP Transform terms to lowercase Output format: Output format: Visualise Please enter your text here: Output format: Visualise javadoc not visible reference javadoc not visible reference Submit Clear NN RB JJ NN Part-of-Speech: javadoc not visible reference Named Entity Recognition: javadoc not visible reference javadoc not visible reference Named Entity Recognition: Coreference: javadoc not visible reference javadoc not visible reference Coreference: Basic endencies: NN RB JJ NN javadoc not visible reference amod neg NN RB JJ NN Basic endencies: javadoc not amod visible reference 8/5/204 Named Javadoc Stanford Entity Hidden CoreNLP Recognition: Reference javadoc hidden reference javadoc Stanford hidden CoreNLP reference Please enter your text here: Coreference: javadoc hidden reference Visualisation provided using the brat visualisation/annotation software. Copyright 20, Stanford University, All Rights Reserved. antonyms Visualise javadoc hidden reference amod javadoc Noun hidden Adjective reference Noun Visualisation provided using the brat visualisation/annotation software. Copyright 20, Stanford University, All Rights Reserved. synonyms Output format: Please enter your text here: Collapsed NN CC-processed JJ NN endencies: javadoc hidden reference Basic endencies: javadoc hidden hidden reference reference amod javadoc hidden reference Submit Clear amod amod Collapsed CC-processed endencies: Part-of-Speech: javadoc hidden reference Collapsed endencies: javadoc hidden reference Collapsed endencies: amod Part-of-Speech: javadoc hidden reference amod Named NN NNEntity JJ JJRecognition: NN NN javadoc hidden reference javadoc hidden reference javadoc hidden reference amod Collapsed endencies: Basic endencies: javadoc hidden reference Collapsed Named Entity Coreference: CC-processed Recognition: endenci amod Submit Clear Visualise javadoc hidden reference javadoc hidden reference javadoc hidden reference amod Coreference: Basic endencies: Coreference: Basic endencies: javadoc hidden reference javadoc hidden reference Visualisation provided using the brat visualis Copyright NN 20, JJStanford amod Basic endencies: NNUniversity, All Ri javadoc hidden reference javadoc javadoc hidden hidden reference reference Named Coreference: Entity Recognition: javadoc javadoc hidden hidden reference reference Collapsed endencies: amod Named Entity Recognition: 6

22 Debugging Method Names [Høst et Østvold, 2009] Building semantic profiles from the program bytecode E.g., Semantic profile of an iterator method These methods often call other methods with the same name and create objects. They never return void, write parameter values to fields or call themselves recursively, and very rarely write to fields or return parameter values, and rarely have parameters, contain loops, use local variables, do runtime type-checking or casting, return field values, have branches or have multiple return points. public Iterator iterator() throws DomainRegistryException{

23 Debugging Method Names [Høst et Østvold, 2009] E.g., Semantic profile of an is-<adjective> method public void iscaching(boolean value) { this.caching = value; Name: is-<adjective> Implementation: set-<adjective>: returns void, writes field, parameter to field. iscaching => setcaching

24 Relation with Software Quality and Program Comprehension: the good news LBS improve bug prediction [Abebe et al., 202] LAs are perceived as poor practices by the majority of the surveyed developers (69% and 5% of the external and internal developers, respectively) [Arnaoudova et al., 205]

25 Relation with Software Quality and Program Comprehension: the bad news Developers rename towards abbreviations [Arnaoudova et al., 204] Only 0% of the LAs were fixed by developers [Arnaoudova et al., 205]

26 How did we identify poor lexicon? LBS: smart people got together, discussed, and identified a list of poor practices LAs: sampled source code from open-source projects and looked for inconsistencies among name, type, and comments of programming entities Debugging method names: a corpus of Java projects to identify common semantics for methods with similar names

27 Guidelines for writing good quality lexicon? 9 Naming Conventions Naming conventions make programs more understandable by making them easier to read. They can also give information about the function of the identifier for example, whether it's a constant, package, or class which can be helpful in understanding the code. Identifier Type Rules for Naming Examples Packages The prefix of a unique package name is always written in all lowercase ASCII letters and should be one of the top level domain names, currently com, edu, gov, mil, net, org, or one of the English twoletter codes identifying countries as specified in ISO Standard 366, 98. Subsequent components of the package name vary according to an organization's own internal naming conventions. Such conventions might specify that certain directory name components be division, artment, project, machine, or login names. com.sun.eng com.apple.quicktime.v2 edu.cmu.cs.bovik.cheese Classes Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML). class Raster; class ImageSprite; Interfaces Interface names should be capitalized like class names. interface RasterDelegate; interface Storing; Methods Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized. run(); runfast(); getbackground(); Variables Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter. Internal words start with capital letters. Variable names should not start with underscore _ or dollar sign $ characters, even though both are allowed. Variable names should be short yet meaningful. The choice of a variable name should be mnemonicthat is, designed to indicate to the casual observer the intent of its use. One character variable names should be avoided except for temporary "throwaway" variables. Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters. int i; char c; float mywidth; static final int MIN_WIDTH = 4; Constants The names of variables declared class constants and of ANSI constants should be all uppercase with words separated by underscores ("_"). (ANSI constants should be avoided, for ease of debugging.) static final int MAX_WIDTH = 999; static final int GET_THE_CPU = ;

28 Challenges for the future How should we identify poor lexicon? prioritize the reporting of poor lexicon? define guidelines for writing good quality lexicon?

Data Types, Literals, Operators

Data Types, Literals, Operators Data Types, Literals, Operators Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 Learning

More information

CSCI 1060U Programming Workshop

CSCI 1060U Programming Workshop CSCI 1060U Programming Workshop Professor: Dr. Jeremy S. Bradbury Phone: 905-721- 8668 ext. 3685 E- mail: jeremy.bradbury@uoit.ca Office hour: To be announced (UA4016), otherwise by appointment Teaching

More information

Documentation Requirements Computer Science 2334 Spring 2016

Documentation Requirements Computer Science 2334 Spring 2016 Overview: Documentation Requirements Computer Science 2334 Spring 2016 These requirements are based on official Java coding conventions but have been adapted to be more appropriate to an academic environment.

More information

QueueBlock, ReversalADT, LinkedList,CustomerAccount, not MaintainCustomerData

QueueBlock, ReversalADT, LinkedList,CustomerAccount, not MaintainCustomerData Naming Conventions Rules Classes Use nouns Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML) Begin with upper case

More information

Datatypes, Variables, and Operations

Datatypes, Variables, and Operations Datatypes, Variables, and Operations 1 Primitive Type Classification 2 Numerical Data Types Name Range Storage Size byte 2 7 to 2 7 1 (-128 to 127) 8-bit signed short 2 15 to 2 15 1 (-32768 to 32767) 16-bit

More information

JOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide

JOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide Module 3 Identifiers, Keywords, and Types Objectives Upon completion of this module, you should be able to: Use comments in a source program Distinguish between valid and invalid identifiers Recognize

More information

int n = 10; int sum = 10; while (n > 1) { sum = sum + n; n--; } cout << "The sum of the integers 1 to 10 is " << sum << endl;

int n = 10; int sum = 10; while (n > 1) { sum = sum + n; n--; } cout << The sum of the integers 1 to 10 is  << sum << endl; Debugging Some have said that any monkey can write a program the hard part is debugging it. While this is somewhat oversimplifying the difficult process of writing a program, it is sometimes more time

More information

Computer Components. Software{ User Programs. Operating System. Hardware

Computer Components. Software{ User Programs. Operating System. Hardware Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

Introduction to Programming Using Java (98-388)

Introduction 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 information

Basic Operations jgrasp debugger Writing Programs & Checkstyle

Basic Operations jgrasp debugger Writing Programs & Checkstyle Basic Operations jgrasp debugger Writing Programs & Checkstyle Suppose you wanted to write a computer game to play "Rock, Paper, Scissors". How many combinations are there? Is there a tricky way to represent

More information

User Interface Programming OOP/Java Primer. Step 3 - documentation

User Interface Programming OOP/Java Primer. Step 3 - documentation User Interface Programming OOP/Java Primer Step 3 - documentation Department of Information Technology Uppsala University What is the documentation? Documentation about program in the program Clearly written

More information

Computational Expression

Computational Expression Computational Expression Variables, Primitive Data Types, Expressions Janyl Jumadinova 28-30 January, 2019 Janyl Jumadinova Computational Expression 28-30 January, 2019 1 / 17 Variables Variable is a name

More information

Objectives. Coding Standards. Why coding standards? Elements of Java Style. Understand motivation for coding standards

Objectives. Coding Standards. Why coding standards? Elements of Java Style. Understand motivation for coding standards Objectives Coding Standards Understand motivation for coding standards Be able to write code that conforms to JOSSE coding standards. Philip Johnson Collaborative Software Development Laboratory Information

More information

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Overview of Source Code Components Comments Library declaration Classes Functions Variables Comments Can

More information

2. Introduction to Internet Applications

2. Introduction to Internet Applications 2. Introduction to Internet Applications 1. Representation and Transfer 2. Web Protocols 3. Some Other Application Layer Protocols 4. Uniform Resource Identifiers (URIs) 5. Uniform Resource Locators (URLs)

More information

What does this program print?

What does this program print? What does this program print? Attempt 1 public class Rec { private static int f(int x){ if(x

More information

CS 251 Intermediate Programming Coding Standards

CS 251 Intermediate Programming Coding Standards CS 251 Intermediate Programming Coding Standards Brooke Chenoweth University of New Mexico Fall 2018 CS-251 Coding Standards All projects and labs must follow the great and hallowed CS-251 coding standards.

More information

CSCI 2101 Java Style Guide

CSCI 2101 Java Style Guide CSCI 2101 Java Style Guide Fall 2017 This document describes the required style guidelines for writing Java code in CSCI 2101. Guidelines are provided for four areas of style: identifiers, indentation,

More information

CS 152 Computer Programming Fundamentals Coding Standards

CS 152 Computer Programming Fundamentals Coding Standards CS 152 Computer Programming Fundamentals Coding Standards Brooke Chenoweth University of New Mexico Fall 2018 CS-152 Coding Standards All projects and labs must follow the great and hallowed CS-152 coding

More information

3. Java - Language Constructs I

3. Java - Language Constructs I Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks

More information

CS 491M. Introduction to Systems Engineering. Michael Zink. Lecture 11. Documentation. Lecture 11:Documentation

CS 491M. Introduction to Systems Engineering. Michael Zink. Lecture 11. Documentation. Lecture 11:Documentation CS 491M Introduction to Systems Engineering Lecture 11 Documentation Michael Zink Lecture 11:Documentation -1- Overview Systems Engineering Management Plan Systems Requirements Document - Content - IEEE

More information

CS 351 Design of Large Programs Coding Standards

CS 351 Design of Large Programs Coding Standards CS 351 Design of Large Programs Coding Standards Brooke Chenoweth University of New Mexico Spring 2018 CS-351 Coding Standards All projects and labs must follow the great and hallowed CS-351 coding standards.

More information

Programmers should write code that is self-documenting and split into small sections.

Programmers should write code that is self-documenting and split into small sections. Writing Programs What are good program writing techniques? Programmers should write code that is self-documenting and split into small sections. Specifically, the programmers should: use meaningful identifier

More information

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 3 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Java Programming Style Guide

Java Programming Style Guide Java Programming Style Guide Computer Science Program Cedarville University Goal: Our goal is to produce well-written code that can be easily understood and will facilitate life-cycle maintenance. These

More information

Chapter 2.5 Writing maintainable programs

Chapter 2.5 Writing maintainable programs Chapter 2.5 Writing maintainable programs Good program writing techniques Maintenance is the updating of a program after it has been released. Maintenance will be helped when the programmer uses good programming

More information

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and Classes CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

CS 251 Intermediate Programming Methods and More

CS 251 Intermediate Programming Methods and More CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

Synchronization SPL/2010 SPL/20 1

Synchronization SPL/2010 SPL/20 1 Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization

More information

( &% class MyClass { }

( &% class MyClass { } Recall! $! "" # ' ' )' %&! ( &% class MyClass { $ Individual things that differentiate one object from another Determine the appearance, state or qualities of objects Represents any variables needed for

More information

Chapter 2 Elementary Programming

Chapter 2 Elementary Programming Chapter 2 Elementary Programming Part I 1 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from this chapter, you will learn how to solve practical

More information

Basics of Java Programming

Basics of Java Programming Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

IT Web and Software Developer Software Development Standards

IT 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 information

Computer Components. Software{ User Programs. Operating System. Hardware

Computer Components. Software{ User Programs. Operating System. Hardware Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point

More information

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs Programming Logic and Design Chapter 2 Elements of High-Quality Programs Objectives In this chapter, you will learn about: Declaring and using variables and constants Assigning values to variables [assignment

More information

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple

More information

Beginning Style. 16-Nov-15

Beginning Style. 16-Nov-15 Beginning Style 16-Nov-15 Be consistent! Most times, you will enter an ongoing project, with established style rules Follow them even if you don t like them In this course you will be working in teams

More information

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java Chapter 1 Introduction to Computers and Java Objects Background information» important regardless of programming language Introduction to Java Chapter 1 Java: an Introduction to Computer Science & Programming

More information

Assignment Marking Criteria

Assignment Marking Criteria Assignment Marking Criteria Analysis Your analysis documentation must meet the following criteria: All program inputs, processing, and outputs. Each input and output must be given a name and description

More information

A New Family of Software Anti-Patterns: Linguistic Anti-Patterns

A New Family of Software Anti-Patterns: Linguistic Anti-Patterns A New Family of Software Anti-Patterns: Linguistic Anti-Patterns Venera Arnaoudova 1,2, Massimiliano Di Penta 3, Giuliano Antoniol 2, Yann-Gaël Guéhéneuc 1 1 Ptidej Team, DGIGL, École Polytechnique de

More information

Expanded Guidelines on Programming Style and Documentation

Expanded Guidelines on Programming Style and Documentation Page 1 of 5 Expanded Guidelines on Programming Style and Documentation Introduction Introduction to Java Programming, 5E Y. Daniel Liang liang@armstrong.edu Programming style deals with the appearance

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

Data types Expressions Variables Assignment. COMP1400 Week 2

Data types Expressions Variables Assignment. COMP1400 Week 2 Data types Expressions Variables Assignment COMP1400 Week 2 Data types Data come in different types. The type of a piece of data describes: What the data means. What we can do with it. Primitive types

More information

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started

More information

TABLE OF CONTENTS 2 CHAPTER 1 3 CHAPTER 2 4 CHAPTER 3 5 CHAPTER 4. Algorithm Design & Problem Solving. Data Representation.

TABLE OF CONTENTS 2 CHAPTER 1 3 CHAPTER 2 4 CHAPTER 3 5 CHAPTER 4. Algorithm Design & Problem Solving. Data Representation. 2 CHAPTER 1 Algorithm Design & Problem Solving 3 CHAPTER 2 Data Representation 4 CHAPTER 3 Programming 5 CHAPTER 4 Software Development TABLE OF CONTENTS 1. ALGORITHM DESIGN & PROBLEM-SOLVING Algorithm:

More information

A DNS Tutorial

A DNS Tutorial http://ntrg.cs.tcd.ie/undergrad/4ba2/multicast/ Copyright Table of Contents What is a DNS?... 3 Why do we need a DNS?... 3 Why do computers prefer addresses based on numbers?... 3 What is a Domain Name,

More information

Final Project Discussion. Adam Meyers Montclair State University

Final Project Discussion. Adam Meyers Montclair State University Final Project Discussion Adam Meyers Montclair State University Summary Project Timeline Project Format Details/Examples for Different Project Types Linguistic Resource Projects: Annotation, Lexicons,...

More information

Technical Questions. Q 1) What are the key features in C programming language?

Technical Questions. Q 1) What are the key features in C programming language? Technical Questions Q 1) What are the key features in C programming language? Portability Platform independent language. Modularity Possibility to break down large programs into small modules. Flexibility

More information

Key Differences Between Python and Java

Key Differences Between Python and Java Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.

More information

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 2: Review of Object Orientation 2.1 What is Object Orientation? Procedural paradigm: Software is organized

More information

COMP90042 LECTURE 3 LEXICAL SEMANTICS COPYRIGHT 2018, THE UNIVERSITY OF MELBOURNE

COMP90042 LECTURE 3 LEXICAL SEMANTICS COPYRIGHT 2018, THE UNIVERSITY OF MELBOURNE COMP90042 LECTURE 3 LEXICAL SEMANTICS SENTIMENT ANALYSIS REVISITED 2 Bag of words, knn classifier. Training data: This is a good movie.! This is a great movie.! This is a terrible film. " This is a wonderful

More information

Java Programming Unit 3: Variables and Arithmetic Operations

Java Programming Unit 3: Variables and Arithmetic Operations Java Programming Unit 3: Variables and Arithmetic Operations Bensalem Township School District Standards Link: PA State Standards for Business Education: http://www.pdesas.org/standard/views#114,115,116,117

More information

CPE 101. Overview. Programming vs. Cooking. Key Definitions/Concepts B-1

CPE 101. Overview. Programming vs. Cooking. Key Definitions/Concepts B-1 CPE 101 Lecture 2: Problems, Algorithms, and Programs (Slides adapted from a UW course, copyrighted and used by permission) Overview High-level survey Problems, algorithms, and programs Problem solving

More information

Frequently Asked Questions

Frequently Asked Questions Frequently Asked Questions This PowerTools FAQ answers many frequently asked questions regarding the functionality of the various parts of the PowerTools suite. The questions are organized in the following

More information

CS101 Introduction to Programming Languages and Compilers

CS101 Introduction to Programming Languages and Compilers CS101 Introduction to Programming Languages and Compilers In this handout we ll examine different types of programming languages and take a brief look at compilers. We ll only hit the major highlights

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

Empirical Software Engineering. Empirical Software Engineering with Examples. Classification. Software Quality. precision = TP/(TP + FP)

Empirical Software Engineering. Empirical Software Engineering with Examples. Classification. Software Quality. precision = TP/(TP + FP) Empirical Software Engineering Empirical Software Engineering with Examples a sub-domain of software engineering focusing on experiments on software systems devise experiments on software, in collecting

More information

Software and Programming 1

Software and Programming 1 Software and Programming 1 Lab 1: Introduction, HelloWorld Program and use of the Debugger 17 January 2019 SP1-Lab1-2018-19.pptx Tobi Brodie (tobi@dcs.bbk.ac.uk) 1 Module Information Lectures: Afternoon

More information

CS11 Java. Fall Lecture 1

CS11 Java. Fall Lecture 1 CS11 Java Fall 2006-2007 Lecture 1 Welcome! 8 Lectures Slides posted on CS11 website http://www.cs.caltech.edu/courses/cs11 7-8 Lab Assignments Made available on Mondays Due one week later Monday, 12 noon

More information

Data Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Data Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani Data Types, Variables and Arrays OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani Identifiers in Java Identifiers are the names of variables, methods, classes, packages and interfaces. Identifiers must

More information

C++ Programming Style Guide

C++ Programming Style Guide C++ Programming Style Guide Computer Science Program Cedarville University Goal: Our goal is to produce well-written code that can be easily understood and will facilitate life-cycle maintenance. These

More information

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java Introduction Objectives An overview of object-oriented concepts. Programming and programming languages An introduction to Java 1-2 Problem Solving The purpose of writing a program is to solve a problem

More information

Object Declaration. <class name>: the name of the class to which the object belongs <object name>: the name of the object (any valid identifier)

Object Declaration. <class name>: the name of the class to which the object belongs <object name>: the name of the object (any valid identifier) Object Declaration Every object used must be declared Syntax: ; : the name of the class to which the object belongs : the name of the object (any valid

More information

Fall 2017 CISC124 9/16/2017

Fall 2017 CISC124 9/16/2017 CISC124 Labs start this week in JEFF 155: Meet your TA. Check out the course web site, if you have not already done so. Watch lecture videos if you need to review anything we have already done. Problems

More information

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in:

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in: CS 215 Fundamentals of Programming II C++ Programming Style Guideline Most of a programmer's efforts are aimed at the development of correct and efficient programs. But the readability of programs is also

More information

G Programming Languages - Fall 2012

G 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 information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Supplement D: Expanded Guidelines on Programming Style and Documentation

Supplement D: Expanded Guidelines on Programming Style and Documentation Page 1 of 5 Introduction Supplement D: Expanded Guidelines on Programming Style and Documentation For Introduction to Java Programming Y. Daniel Liang mailto:liang@armstrong.edu Programming style deals

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

CEN 414 Java Programming

CEN 414 Java Programming CEN 414 Java Programming Instructor: H. Esin ÜNAL SPRING 2017 Slides are modified from original slides of Y. Daniel Liang WEEK 2 ELEMENTARY PROGRAMMING 2 Computing the Area of a Circle public class ComputeArea

More information

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods COMP-202 Unit 2: Java Basics CONTENTS: Using Expressions and Variables Types Strings Methods Assignment 1 Assignment 1 posted on WebCt and course website. It is due May 18th st at 23:30 Worth 6% Part programming,

More information

Ex: If you use a program to record sales, you will want to remember data:

Ex: If you use a program to record sales, you will want to remember data: Data Variables Programs need to remember values. Ex: If you use a program to record sales, you will want to remember data: A loaf of bread was sold to Sione Latu on 14/02/19 for T$1.00. Customer Name:

More information

CT 229 Fundamentals of Java Syntax

CT 229 Fundamentals of Java Syntax CT 229 Fundamentals of Java Syntax 19/09/2006 CT229 New Lab Assignment Monday 18 th Sept -> New Lab Assignment on CT 229 Website Two Weeks for Completion Due Date is Oct 1 st Assignment Submission is online

More information

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are: LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words

More information

A JavaBean is a class file that stores Java code for a JSP

A JavaBean is a class file that stores Java code for a JSP CREATE A JAVABEAN A JavaBean is a class file that stores Java code for a JSP page. Although you can use a scriptlet to place Java code directly into a JSP page, it is considered better programming practice

More information

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public

More information

Error annotation in adjective noun (AN) combinations

Error annotation in adjective noun (AN) combinations Error annotation in adjective noun (AN) combinations This document describes the annotation scheme devised for annotating errors in AN combinations and explains how the inter-annotator agreement has been

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( Please enter another number: ); scanf( %d, &num2); CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful

More information

Identifiers and Variables

Identifiers and Variables Identifiers and Variables Lecture 4 Based on Slides of Dr. Norazah Yusof 1 Identifiers All the Java components classes, variables, and methods need names. In Java these names are called identifiers, and,

More information

Empirical Software Engineering. Empirical Software Engineering with Examples! is not a topic for examination. Classification.

Empirical Software Engineering. Empirical Software Engineering with Examples! is not a topic for examination. Classification. Empirical Software Engineering Empirical Software Engineering with Examples is not a topic for examination a sub-domain of software engineering focusing on experiments on software systems devise experiments

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP 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

CS1004: Intro to CS in Java, Spring 2005

CS1004: Intro to CS in Java, Spring 2005 CS1004: Intro to CS in Java, Spring 2005 Lecture #16: Java conditionals/loops, cont d. Janak J Parekh janak@cs.columbia.edu Administrivia Midterms returned now Weird distribution Mean: 35.4 ± 8.4 What

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and

More information

2 rd class Department of Programming. OOP with Java Programming

2 rd class Department of Programming. OOP with Java Programming 1. Structured Programming and Object-Oriented Programming During the 1970s and into the 80s, the primary software engineering methodology was structured programming. The structured programming approach

More information

Accelerating Information Technology Innovation

Accelerating Information Technology Innovation Accelerating Information Technology Innovation http://aiti.mit.edu Cali, Colombia Summer 2012 Lesson 02 Variables and Operators Agenda Variables Types Naming Assignment Data Types Type casting Operators

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

Summer May 11, 2010

Summer May 11, 2010 Summer 2010 Department of Computer Science and Engineering York University Toronto May 11, 2010 1 / 40 What we did last time Overview of C to the language Program structure Types in C Operators in C IO

More information

Programming in Visual Basic with Microsoft Visual Studio 2010

Programming in Visual Basic with Microsoft Visual Studio 2010 Programming in Visual Basic with Microsoft Visual Studio 2010 Course 10550; 5 Days, Instructor-led Course Description This course teaches you Visual Basic language syntax, program structure, and implementation

More information

THE CONCEPT OF OBJECT

THE CONCEPT OF OBJECT THE CONCEPT OF OBJECT An object may be defined as a service center equipped with a visible part (interface) and an hidden part Operation A Operation B Operation C Service center Hidden part Visible part

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic BIT 3383 Java Programming Sem 1 Session 2011/12 Chapter 2 JAVA basic Objective: After this lesson, you should be able to: declare, initialize and use variables according to Java programming language guidelines

More information

Java Fall 2018 Margaret Reid-Miller

Java Fall 2018 Margaret Reid-Miller Java 15-121 Fall 2018 Margaret Reid-Miller Reminders How many late days can you use all semester? 3 How many late days can you use for a single assignment? 1 What is the penalty for turning an assignment

More information

ADAMS version 2.2 Release Notes

ADAMS version 2.2 Release Notes ADAMS version 2.2 Release Notes November 13, 2009 Table of Content 1. Introduction... 3 2. Important Requirements... 3 2.1 Clear Browser Cache... 3 2.2 Verify Bookmark if Any... 3 2.3 Allow Pop-Ups...

More information

Summary. Recursion. Overall Assignment Description. Part 1: Recursively Searching Files and Directories

Summary. Recursion. Overall Assignment Description. Part 1: Recursively Searching Files and Directories Recursion Overall Assignment Description This assignment consists of two parts, both dealing with recursion. In the first, you will write a program that recursively searches a directory tree. In the second,

More information

3. Java - Language Constructs I

3. Java - Language Constructs I Names and Identifiers A program (that is, a class) needs a name public class SudokuSolver {... 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations,

More information