Software Development: Version Control and Interfaces Overview

Slides adapted from Alex Mariakakis,
with material from Krysta Yousoufian, Mike Ernst, Kellen Donohue
S
S
e
e
c
c
t
t
i
i
o
o
n
n
 
 
5
5
:
:
H
H
W
W
6
6
 
 
a
a
n
n
d
d
 
 
I
I
n
n
t
t
e
e
r
r
f
f
a
a
c
c
e
e
s
s
Agenda
Version control and tools review
BFS
Interfaces
Parsing Marvel Data
331 Version control
Repository
create
Working copy
update
commit
check out
add
check out
Working copy for
grading
Where is my code?
p
e
r
s
o
n
a
l
 
c
o
m
p
u
t
e
r
(/projects/instr/14au/cse331/
YourCSENetID
/REPOS/cse
331)
a
t
t
u
 
w
o
r
k
i
n
g
 
c
o
p
y
(
/
h
o
m
e
s
/
i
w
s
/
C
S
E
N
E
T
I
D
/
,
 
o
r
 
o
t
h
e
r
d
i
r
e
c
t
o
r
y
)
check out
commit
check out
update
validate
attu scratch copy
update
(../scratch from attu working copy)
repo
Where is my code?
Main repo: /projects/instr/etc
Not human readable
You can’t see files here
Personal computer: any directory, via Subclipse or other
Working copy: add and edit files here
Must check in files for them to go to the repo
attu working copy: /homes/iws/CSENETID/ or other
Just another working copy, same as personal computer
Must svn update to see changes from pc/repo
validate copy: attu directory/src/…/scratch
NEW WORKING COPY CHECKED OUT FROM REPO
May NOT be the same as attu working copy if attu wasn’t updated
Concepts vs tools, 331 vs general
 
Version control:
Tools: svn, TortoiseSVN, Subclipse
Ant:
Concept: build management
validate
Remote access:
Tools: ssh, PuTTY, WinSCP
Javadocs:
Concept: documentation
@param, @return, @throws
@requires, @modifies, @effects
 
 
concept
tool
tool
331
331
general
concept
Graphs
A
B
C
D
E
 
C
a
n
 
I
 
r
e
a
c
h
 
B
f
r
o
m
 
A
?
Breadth-First Search (BFS)
Often used for discovering connectivity
Calculates the shortest path if and only if all
edges have same positive or no weight
Depth-first search (DFS) is commonly mentioned
with BFS
BFS looks “wide”, DFS looks “deep”
Can also be used for discovery, but not the shortest
path
BFS Pseudocode
public boolean find(Node start, Node end) {
 
put start node in a queue
 
while (queue is not empty) {
  
pop node N off queue
  
if (N is goal)
   
return true;
  
else {
   
for each node O that is child of N
    
push O onto queue
  
}
 
}
 
return false;
}
Breadth-First Search
 
Q: <>
Q: <A>
Q: <>
Q: <B>
Q: <B, C>
DONE
 
 
 
A
B
C
Breadth-First Search with Cycle
 
Q: <>
Q: <A>
Q: <>
Q: <B>
Q: <>
Q: <C>
Q: <>
Q: <A>
NEVER
DONE
 
 
 
A
B
C
BFS Pseudocode
public boolean find(Node start, Node end) {
 
put start node in a queue
 
while (queue is not empty) {
  
pop node N off queue
  
if (N is goal)
   
return true;
  
else {
   
for each node O that is child of N
    
push O onto queue
  
}
 
}
 
return false;
}
 
W
h
a
t
 
i
f
 
t
h
e
r
e
s
 
a
 
c
y
c
l
e
?
W
h
a
t
 
i
f
 
t
h
e
r
e
s
 
n
o
 
p
a
t
h
 
b
e
t
w
e
e
n
 
s
t
a
r
t
 
a
n
d
 
e
n
d
?
 
M
a
r
k
 
t
h
e
 
n
o
d
e
 
a
s
 
v
i
s
i
t
e
d
!
Breadth-First Search
Q: <>
A
B
C
D
E
Breadth-First Search
Q: <>
Q: <A>
A
B
C
D
E
Breadth-First Search
Q: <>
Q: <A>
Q: <>
A
E
B
D
C
Breadth-First Search
Q: <>
Q: <A>
Q: <>
Q: <C>
A
C
E
B
D
Breadth-First Search
Q: <>
Q: <A>
Q: <>
Q: <C>
Q: <C ,D>
A
C
D
E
B
Breadth-First Search
Q: <>
Q: <A>
Q: <>
Q: <C>
Q: <C ,D>
Q: <D>
A
C
D
B
E
Breadth-First Search
Q: <>
Q: <A>
Q: <>
Q: <C>
Q: <C ,D>
Q: <D>
Q: <D, E>
A
C
D
E
B
Breadth-First Search
Q: <>
Q: <A>
Q: <>
Q: <C>
Q: <C ,D>
Q: <D>
Q: <D, E>
Q: <E>
A
C
D
E
B
Breadth-First Search
Q: <>
Q: <A>
Q: <>
Q: <C>
Q: <C ,D>
Q: <D>
Q: <D, E>
Q: <E>
DONE
A
C
D
E
B
Shortest Paths with BFS
From Node B
A
B
C
D
E
 
1
 
1
 
1
 
1
 
1
 
1
 
1
Shortest Paths with Weights
A
B
C
D
E
 
From Node B
2
100
2
6
2
3
100
 
P
a
t
h
s
 
a
r
e
 
n
o
t
 
t
h
e
 
s
a
m
e
!
Classes, Interfaces, and Types
The fundamental unit of programming in Java is a class
Classes can extend other classes and implement
interfaces
Interfaces can extend other interfaces
Classes, Objects, and Java
Everything is an instance of a class
Defines data and methods
Every class extends exactly one other class
Object if no explicit superclass
Inherits superclass fields
Every class also defines a type
Foo defines type Foo
Foo inherits all inherited types
Java classes contain both specification and
implementation!
Interfaces
Pure type declaration
 
public interface Comparable {
  
int compareTo(Object other);
 
} 
 
 
Can contain:
Method specifications (implicitly 
public abstract
)
Named constants (implicitly 
public final static
)
Does not contain implementation
Cannot create instances of interfaces
Implementing Interfaces
A class can implement one or more interfaces
class Kitten implements Pettable, Huggable
The implementing class and its instances have the
interface type(s) as well as the class type(s)
The class must provide or inherit an implementation of all
methods defined by the interface(s)
Not true for abstract classes
Using Interface Types
An interface defines a type, so we can declare variables
and parameters of that type
A variable with an interface type can refer to an object of
any class implementing that type
List<String> x = new ArrayList<String>();
void sort(List myList) {…}
Guidelines for Interfaces
Provide interfaces for significant types and abstractions
Write code using interface types like Map instead of
HashMap and TreeMap wherever possible
Allows code to work with different implementations later on
Both interfaces and classes are appropriate in various
circumstances
D
D
e
e
m
m
o
o
Parsing the Marvel data
Parsing the Marvel data
Slide Note
Embed
Share

Explore the essentials of version control, tools review, BFS, interfaces, and data parsing in the realm of software development. Learn about repository management, working copies, code update processes, and the distinctions between concepts and tools like SVN, Ant, and Javadocs. Delve into graph theory concepts and the significance of Breadth-First Search (BFS) for connectivity discovery and path calculation.

  • Software Development
  • Version Control
  • Interfaces
  • BFS
  • Graph Theory

Uploaded on Sep 22, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Section 5: HW6 and Interfaces Slides adapted from Alex Mariakakis, with material from Krysta Yousoufian, Mike Ernst, Kellen Donohue

  2. Agenda Version control and tools review BFS Interfaces Parsing Marvel Data

  3. 331 Version control create Repository check out Working copy for grading commit add update Working copy

  4. Where is my code? update (/projects/instr/14au/cse331/ YourCSENetID/REPOS/cse 331) repo commit personal computer update attu scratch copy attu working copy (/homes/iws/CSENETID/, or other directory) (../scratch from attu working copy)

  5. Where is my code? Main repo: /projects/instr/etc Not human readable You can t see files here Personal computer: any directory, via Subclipse or other Working copy: add and edit files here Must check in files for them to go to the repo attu working copy: /homes/iws/CSENETID/ or other Just another working copy, same as personal computer Must svn update to see changes from pc/repo validate copy: attu directory/src/ /scratch NEW WORKING COPY CHECKED OUT FROM REPO May NOT be the same as attu working copy if attu wasn t updated

  6. Concepts vs tools, 331 vs general Version control: Tools: svn, TortoiseSVN, Subclipse Ant: Concept: build management validate Remote access: Tools: ssh, PuTTY, WinSCP Javadocs: Concept: documentation @param, @return, @throws @requires, @modifies, @effects concept tool 331 concept tool general 331

  7. Graphs B A Can I reach B from A? C D E

  8. Breadth-First Search (BFS) Often used for discovering connectivity Calculates the shortest path if and only if all edges have same positive or no weight Depth-first search (DFS) is commonly mentioned with BFS BFS looks wide , DFS looks deep Can also be used for discovery, but not the shortest path

  9. BFS Pseudocode public boolean find(Node start, Node end) { put start node in a queue while (queue is not empty) { pop node N off queue if (N is goal) return true; else { for each node O that is child of N push O onto queue } } return false; }

  10. Breadth-First Search Q: <> Q: <A> Q: <> Q: <B> Q: <B, C> DONE A B C

  11. Breadth-First Search with Cycle Q: <> Q: <A> Q: <> Q: <B> Q: <> Q: <C> Q: <> Q: <A> NEVER DONE A B C

  12. BFS Pseudocode public boolean find(Node start, Node end) { put start node in a queue while (queue is not empty) { pop node N off queue if (N is goal) return true; else { for each node O that is child of N push O onto queue } } return false; } What if there s a cycle? What if there s no path between start and end? Mark the node as visited!

  13. Breadth-First Search Q: <> B A C D E

  14. Breadth-First Search Q: <> Q: <A> B A C D E

  15. Breadth-First Search Q: <> Q: <A> Q: <> B A C D E

  16. Breadth-First Search Q: <> Q: <A> Q: <> Q: <C> B A C D E

  17. Breadth-First Search Q: <> Q: <A> Q: <> Q: <C> Q: <C ,D> B A C D E

  18. Breadth-First Search Q: <> Q: <A> Q: <> Q: <C> Q: <C ,D> Q: <D> B A C D E

  19. Breadth-First Search Q: <> Q: <A> Q: <> Q: <C> Q: <C ,D> Q: <D> Q: <D, E> B A C D E

  20. Breadth-First Search Q: <> Q: <A> Q: <> Q: <C> Q: <C ,D> Q: <D> Q: <D, E> Q: <E> B A C D E

  21. Breadth-First Search Q: <> Q: <A> Q: <> Q: <C> Q: <C ,D> Q: <D> Q: <D, E> Q: <E> DONE B A C D E

  22. Shortest Paths with BFS 1 B From Node B Destination A B C D E Path <B,A> <B> <B,A,C> <B,D> <B,D,E> Cost 1 0 2 1 2 A 1 1 1 1 C D 1 1 E

  23. Shortest Paths with Weights 2 B From Node B Destination A B C D E Path <B,A> <B> <B,A,C> <B,A,C,D> <B,A,C,E> Cost 2 0 5 7 7 A 100 100 3 2 C D 6 2 Paths are not the same! E

  24. Classes, Interfaces, and Types The fundamental unit of programming in Java is a class Classes can extend other classes and implement interfaces Interfaces can extend other interfaces

  25. Classes, Objects, and Java Everything is an instance of a class Defines data and methods Every class extends exactly one other class Object if no explicit superclass Inherits superclass fields Every class also defines a type Foo defines type Foo Foo inherits all inherited types Java classes contain both specification and implementation!

  26. Interfaces Pure type declaration public interface Comparable { int compareTo(Object other); } Can contain: Method specifications (implicitly public abstract) Named constants (implicitly public final static) Does not contain implementation Cannot create instances of interfaces

  27. Implementing Interfaces A class can implement one or more interfaces class Kitten implements Pettable, Huggable The implementing class and its instances have the interface type(s) as well as the class type(s) The class must provide or inherit an implementation of all methods defined by the interface(s) Not true for abstract classes

  28. Using Interface Types An interface defines a type, so we can declare variables and parameters of that type A variable with an interface type can refer to an object of any class implementing that type List<String> x = new ArrayList<String>(); void sort(List myList) { }

  29. Guidelines for Interfaces Provide interfaces for significant types and abstractions Write code using interface types like Map instead of HashMap and TreeMap wherever possible Allows code to work with different implementations later on Both interfaces and classes are appropriate in various circumstances

  30. Demo Parsing the Marvel data

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#