Functional decomposition
Download
1 / 11

Functional Decomposition - PowerPoint PPT Presentation


  • 79 Views
  • Uploaded on

Functional Decomposition. At the beginning of this unit we discussed how most of your programs have been written like this: public class BigProgram { public static void main (String [ ] args) { statement; statement; statement; statement; statement; statement;

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Functional Decomposition' - xena-henry


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Functional decomposition

  • At the beginning of this unit we discussed how most of your programs have been written like this:

    public class BigProgram

    {

    public static void main (String [ ] args)

    {

    statement;

    statement;

    statement;

    statement;

    statement;

    statement;

    statement;

    statement;

    statement;

    statement;

    statement;

    statement;

    }

    }


Functional decomposition



Functional decomposition


Functional decomposition


Functional decomposition


Functional decomposition


Functional decomposition

  • Functional Decomposition has advantages in programming: you “chunked” the data.

    • The best way to solve a complex problem is to break it down into smaller problems.

    • Using methods, specific parts of a problem can be written at one time. You don’t have to worry about the whole program.

    • Methods allow the program to be broken up so multiple people can work on ONE program.


Functional decomposition

main method you “chunked” the data.

  • Again, this is what a program looks like when it is broken up into smaller methods:

    public class DividedProgram

    {

    public static void main (String [ ] args)

    {

    statement;

    statement;

    }

    public static void method2( )

    {

    statement;

    statement;

    }

    public static void method3( )

    {

    statement;

    statement;

    }

    public static void method4( )

    {

    statement;

    statement;

    }

    }

method 2

method 3

method 4


Functional decomposition

public static void main(String[] args) throws IOException

{

int intNumDays = 30; // Number of days of sales

String strFileName; // The name of the file to open

double dblTotalSales; // Total sales for period

double dblAverageSales; // Average daily sales

// Get the name of the file.

strFileName = getFileName();

// Get the total sales from the file.

dblTotalSales = getTotalSales(strFileName);

// Calculate the average.

dblAverageSales = calcAverageSales(dblTotalSales, intNumDays);

// Display the total and average.

displayResults(dblTotalSales, dblAverageSales);

System.exit(0);

}