6
Fundamentals of Softw are Development 1 Slide 1 Why start with Why start with WordGames? WordGames? You wrote your first lines of code You wrote your first lines of code in this course in WordGames. in this course in WordGames. Why start with such a complex Why start with such a complex project? project? Answer: Answer: It is practical to do so, by using an It is practical to do so, by using an interface interface to connect your code to ours to connect your code to ours It makes the point that It makes the point that most software most software engineers modify/extend existing programs engineers modify/extend existing programs rather than creating their own “from rather than creating their own “from scratch” scratch” See next slides for details on these two points

Fundamentals of Software Development 1Slide 1 Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote your first

Embed Size (px)

Citation preview

Page 1: Fundamentals of Software Development 1Slide 1 Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote your first

Fundamentals of Software Development 1

Slide 1

Why start with Why start with WordGames?WordGames?

• You wrote your first lines of code in this You wrote your first lines of code in this course in WordGames.course in WordGames.

• Why start with such a complex project?Why start with such a complex project?• Answer:Answer:

– It is practical to do so, by using an It is practical to do so, by using an interfaceinterface to connect your code to ours to connect your code to ours

– It makes the point that It makes the point that most software most software engineers modify/extend existing engineers modify/extend existing programsprograms rather than creating their own rather than creating their own “from scratch”“from scratch”

See next slides for details on these two points

Page 2: Fundamentals of Software Development 1Slide 1 Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote your first

Fundamentals of Software Development 1

Slide 2

UML class diagram for UML class diagram for WordGamesWordGames

Capitalizer NameDropper xxx xxx…

<<interface>StringTransformable

---------------------------

transform(String) : String

All our stuffThe StringTransformable interface is how our code knows how to “connect” to your code

Questions on this important idea?

Page 3: Fundamentals of Software Development 1Slide 1 Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote your first

Fundamentals of Software Development 1

Slide 3

““From scratch” projectsFrom scratch” projects

• Today’s software engineering is almost NEVER “from Today’s software engineering is almost NEVER “from scratch”scratch”– Compilers translate from high-level language to machine codeCompilers translate from high-level language to machine code– We use libraries for printing and (in Java) much moreWe use libraries for printing and (in Java) much more– We reuse existing codeWe reuse existing code

• During a 20 year career, a typical software engineer During a 20 year career, a typical software engineer might:might:– Work on about 20 projectsWork on about 20 projects– Be involved with the creation of only 1 or 2 projects from Be involved with the creation of only 1 or 2 projects from

scratchscratch• For all the other projects, she modifies/extends existing projectsFor all the other projects, she modifies/extends existing projects

• We’ll do a “from scratch” project today called HelloWorldWe’ll do a “from scratch” project today called HelloWorld– So that you can see what one is likeSo that you can see what one is like– And so that you can see “under the hood” of some of the concepts And so that you can see “under the hood” of some of the concepts

that you have been studyingthat you have been studying

Page 4: Fundamentals of Software Development 1Slide 1 Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote your first

Fundamentals of Software Development 1

Slide 4

Hello World concepts – Hello World concepts – outlineoutline

• The next slide shows the entire The next slide shows the entire HelloWorldHelloWorld program program– It illustrates the following concepts:It illustrates the following concepts:

• The The mainmain method method• StaticStatic methods methods• ConsoleConsole projects projects• How to use How to use System.out.printlnSystem.out.println to to printprint a String to a String to

the consolethe console

– You will experience these same concepts in You will experience these same concepts in your own HelloWorld project immediately your own HelloWorld project immediately afterwardsafterwards• So pay attention and ask questions!So pay attention and ask questions!

Page 5: Fundamentals of Software Development 1Slide 1 Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote your first

Fundamentals of Software Development 1

Slide 5

Hello World – the complete Hello World – the complete programprogram

public class HelloWorld {

public static void main(String[] args) {

System.out.println("Hello world"); }}

main is the name of the special method at which any Java application begins

A static method is a method that “belongs” to the class instead of to each instance of the class. The static method cannot refer to the class’ non-static fields.

The special main method is, by definition, static.

System is a class that has “system” stuff

System has a public static

field called out that is a PrintStream – a thing that

can print to the console

main has command-line arguments sent as a String array

println is a PrintStream method that prints its argument on a line

Instructor: run this zipped HelloWorld project

Page 6: Fundamentals of Software Development 1Slide 1 Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote your first

Fundamentals of Software Development 1

Slide 6

Hello World – the complete Hello World – the complete programprogram

public class HelloWorld {

public static void main(String[] args) {

System.out.println("Hello world"); }}

What is special about the main method?

The main method is static. What does that mean?

Is System a class, method or field? How can you tell?

Is out a method or field? How can you tell?

Is println a method or field? What does println do?

Find a partner with whom you would like to do the HelloWorld project. With that partner, answer the questions below.

Ask for help as needed from your instructor or assistants!

Once you are satisfied that you understand the HelloWorld program shown below, do the HelloWorld, Part 1 project with your partner.