CSE 211 Midterm Exam
java logical operators
! (not), && (and), II (or)
Relational Operators
==, !=, >, <, >=, <=
Mutual Exclusion (mutex)
A program object that prevents simultaneous access to a shared resource. This concept is used in concurrent programming with a critical section, a piece of code in which processes or threads access a shared resource.
Table-driven method
A schema that uses tables to look up information rather than using logic statements (such as if and case). Programmer address 2 issues: what information is stored in the table and what's the most efficient way to access it
Concurrency Primitives
A synchronization primitive is a programming abstraction provided by a programming language or the operating system that facilitates concurrency and synchronization.
immutable object
An object whose value cannot be changed. int's are mutable and Integer's are immutable
Standards in construction
Applying standards during construction helps achieve a project's objectives for efficiency, quality, cost, and security.
Construction in linear model (waterfall)
Construction occurs after requirements, design, and planning. Construction = coding
Construction in an iterative model (agile)
Construction occurs concurrently with other software development activities including requirements, design, and planning) or that overlaps them. Construction = design, coding, and testing
Construction for reuse:
Create reusable software assets.
What is the purpose of reuse?
Enables significant software productivity, quality, and cost improvements.
Code turning
Improves performance at the code level, is the practice of modifying correct code in ways that make it run more efficiently. Usually involves only small-scale changes that affect a single class, routine, or a few lines of code.
Construction Testing
Includes unit testing and integration testing. The purpose is to reduce the gap between the time when faults are inserted into the code and the time when those faults are detected, thereby reducing the cost to fix them. Test-first development.
Performance analysis
Investigation of a program's behavior using information gathered as the program executes, with the goal of identifying possible hot spots (ex. multiple executions in 1 line) in the program to be improved. Behavior of program is measured by results.
Program slicing (slicing criterion)
Involves computation of the set of program statements that may affect the values of specified variables at some point of interest.
Grammar-based input processing
Involves syntax analysis, or parsing, of the input token stream. It involves the creation of a data structure (parse tree or syntax tree) representing the input data.
Why should we anticipate change?
It helps software engineers build extensible software, which means they can enhance a software product without disrupting the underlying structure.
What is programing slicing used for?
Locating the source of errors, program understanding, and optimization analysis.
Construction for verification
Means building software in such a way that faults can be readily found by the software engineers & testers
Construction measurement
Measurements are useful for managing construction, ensuring quality during construction, and improving the construction process
Software Construction Fundamentals
Minimizing complexity, anticipating change, reuse, constructing for verification, and standards in construction
Profiling tool
Monitors the code while it runs and records how many times each statement is executed or how much time the program spends on each statement or execution path.
Why should we minimize complexity?
Most people can't hold complex structures and information in their working memories.
Why should we profile the code?
Profiling the code while it is running gives insight into how the program works, where the hot spots are, and where the developers should focus the code tuning efforts.
State-based/Automata-based Programming
Programming technology using finite state machines to describe program behaviors. These are used in all stages of software development.
Braces vs Indentation
Python uses indentation to separate code into blocks, java uses curly braces to define the beginning and end of each function and class definition
Construction with reuse:
Reuse software assets in the construction of a new system.
Construction Languages
Scripting languages, programming languages (linguistic, formal, visual)
The Software Construction knowledge area is most closely linked to what?
Software Design and Software Testing
When does construction design take place in projects?
Some projects allocate design to activity in construction while others allocate design to a phase explicitly focused on design.
Mutable version of String in java
StringBuilder represents a string of characters and has methods that change the value of the object
Test-First Programming
Test cases are written prior to writing any code to detect defects earlier and correct them more easily than traditional programming styles. Forces programmers to think about about requirements and design before coding thus finding problems sooner.
Construction planning
The choice of construction method affects the extent to which construction prerequisites are performed, the order in which they are performed, and the degree to which they should be completed before construction work begins.
Definition of Software Construction
The detailed creation of working meaningful software through a combination of coding, verification, testing, and debugging .
How can we minimize complexity?
To emphasis the creation of code that is simple and readable rather than clever by following standards and specific coding techniques.
Difference between Validation and Verification.
Validation: Are we building the right system? Verification: Are we building the system right?
How is Java code interpreted
a .class file doesn't contain code that is native to your processor, instead it contains bytecodes which can be read by the JVM. the java launcher tool runs your application by interpreting the bytecode
dynamic typing
a given variable can be repointed to different classes of objects
negative indexes in python
a negative number as an index returns the value at the index of the length + the negative number
syntax error
a problem in the structure of a program that causes the compiler to fail
Scripting Language
a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator.
type
a set of values and a set of operations on those values
Python classes rule 2
all variables are references
8 primitive types in java
byte, short, int, long, float, double, char, boolean
Python is a dynamically-typed language which means
checking is deferred until runtime, while the program is running
The term Software Construction refers to the detailed creation of working software through a combination of ....
coding, verification, unit testing, integration testing, and debugging
goals of computer programming
communicating with the computer by persuading the compiler that your program is sensible, communicating with people by making the program easy to understand so it can be fixed, improved, and adapted to in the future.
in (operator)
determine if a container contains a given object
all
does a container contain all elements evaluating to true
any
does container contain any elements evaluating to true
dynamic typing pros/cons
easier for novice programmers to use
Goals in this course include creating software that is ...
easy to understand, safe from bugs, ready for change
3 Java rules
every java program must define a class all code is inside a class, everything in java must have a type, every executable java program must have a function called "public static void main (String[]args)"
Objects in python
everything is an object, integers, floating point numbers, lists
Python classes rule 1
everything is an object. everything means everything, there are exceptions for primitive types since there are no primitive types. there are no types just classes.
side-effect free programming
functional languages don't have side-effects. declaring variables as final in java means they will not be involved in side effects
loops in java
gives you explicit control over the starting, stopping, and stepping in the three clauses inside the parenthesis
public
indicates to the Java compiler that this is a method that anyone can call
are the following types mutable or immutable? int, Integer, String
int is mutable because the memory location associated with the variable has a different value, Integer and String is immutable because the value can't be modified
immutable objects in python
int, float, string, tuple, frozen set, range
args
is a parameter list for the main method, it is an array of strings
how portable is java
it can be used to create platform-independent applications. any computer or mobile device that is able to run the JVM can run a java application
static typing
java forces you to define the type of variable when you first declare it and will not allow you to change the type later in the program
Objects in java
java has primitive types and objects, basic data types aren't objects they are primitive data types
which runs programs at a faster speed? java or python
java programs run more slowly than python programs
Java is good for
large programs, widely used in research and education, multiple platforms, web programming ability, native android programming, safety static type checking
list
mutable sequence of 0 or more objects of any type
python logical operators
not, and, and or, comparison operators can be chained
type conversion in python
numeric types can be converted to other numeric types by using the appropriate type conversion functions. the functions name is the name of the destination type
type conversion java
numerical types can be converted to other numeric types by using the appropriate cast operators. a cast operator is formed by enclosing the destination type name in parentheses
Python vs. Perl differences
python is trull object oriented and has well established principles of programming, forces readability and good practice. perl has object oriented hacked on and is write only language
dynamic typing
python uses dynamic typing which allows you to change the type of a variable, by replacing an integer with a string
static typing pros/cons
reduces the risk of undetected errors , catches errors before running, easy to misspell a variable name and create a whole new variable
len (function)
return the number of elements in a container
indexing
returns an object in the sequence
mutable objects in python
set, list, dictionary
Breakdown of SC Topics
software construction fundamentals, managing construction, practical consideration, construction technologies, and software construction tools
How is Java code compiled
source code is first written in plain text files ending in .java then they are compiled into .class files by the javac compiler
object types java
string, integer, list, biginteger
Python is good for
syntax is sparse and clear, creates powerful programs without a lot of work, model of objects and variables is consistent, easier dynamic type checking
static
tells Java that this is a method that is part of the class, but is not a method for any one instance of the class
void
tells the java compiler that the method main will not return a value
static checking
the bug is found automatically before the program even runs
dynamic chekcing
the bug is found automatically when the code is executed
file i/o python
the input function displays its argument as a prompt and waits for input. when the user presses the enter key, the function returns a string representing the input text
no checking
the language doesn't help you find the error at all, you have to watch out for it yourself or end up with wrong answers
lists in python
the len function returns the number of elements in a list. the subscript operator [] accesses an element at a given position
file i/o java
the scanner class is used for the input of text and numeric data from the keyboard. the programmer instantiates a scanner and uses the appropriate methods for each type of data being input.
syntax
the set of legal structures and commands that cam be used in a particular language.
arraylists in java
the type is determined when the arraylist is instantiated
Java is statically-typed language which means
the types of all variables are known at compile time, before the program runs. the compiler can deduce the types of all expressions as well, finding errors earlier an easier
loops in python
the variable picks up the value of each element in the iterable object and is visible in the loop body, the range function provides you with a wide variety of options for controlling the value of the loop variable
strong typing
this does mean objects themselves can be easily used when not appropriate
Construction Quality Techniques
unit, integration, test-first development, use of assertions and defensive programming, debugging and statistical analysis
Good coding practice with final variables is
using final for declaring the parameters of a method and as many local variable as possible.
Python classes rule 3
variable reference types are dynamic. not checked at compile time because there is no compile time. the same variable can reference objects of different classes at different times.
immutable references in java
variables that are assigned once and never reassigned, declare with the keyword final
engineers are pessimists because ..
write a little bit at at time and test as you go, document assumptions that your code depends on
hacking is often marked by unbridled optimism such as
writing lots of code before testing it, keeping details in your head instead of writing them down, assuming bugs dont exist
how portable is python
you need a compiler that can turn python code into code that your particular operating system can understand