Extreme Pgms

Embed Size (px)

Citation preview

  • 8/9/2019 Extreme Pgms

    1/21

    Building Web Based N-Tier Applications using C#This article explores the N-tier and Distributed Application Architecture. Over the lastdecade, the way applications are designed has evolved and come a long way. We havestand-alone applications, server based applications, client server applications, web basedapplications, n-tier applications, distributed applications, Peer-to-peer apps, service-orientedArchitectures, component based Development and the list goes on. This article discusses the

    advantages, disadvantages of n-tier applications and methods to implement web based n-tier Applications using C#, .NET

    Why N-Tier Applications?N-Tier Applications can easily implement the concepts of Distributed Application Design andArchitecture. The N-Tier Applications provide strategic benefits to Enterprise Solutions.While 2-tier, client-server can help us create quick and easy solutions and may be used forRapid Prototyping, they can easily become a maintenance and security night mare.

    The N-tier Applications provide specific advantages that are vital to the business continuityof the enterprise. Typical features of a real life n-tier may include the following:

    1) Security: Application has Appropriate Authentication, logging and monitoring

    mechanisms

    2) Availability and Scalability: Application should be reliable and should have sufficientfail-over mechanisms ( redundancy) such as fail-over clusters

    3) Manageability: Application should be designed to have the capability to Deploy, Monitorand troubleshoot. Methodology to handle Errors, log Errors and provide useful informationfor problem resolution

    4) Easy Maintenance: This is generally achieved by adopting coding standards,deployment standards, modular application design, data abstraction and applicationframeworks.

    5) Data Abstraction: Easily make changes to the functionality, business rules with theleast amount of impact to the entire applications

    The above mentioned points are some of the Key design goals of a successful n-tier application that intends to provide a good Business Solution.

    What does it take to build the n-tier Application?The single most important factor that decides the success of the n-tier application is athrough business or domain knowledge.

    The second most important access is the technical and design know how. N-tier applicationsrequire us to put in a sufficient amount of thought to successfully distribute the overallfunctionality of the application in the appropriate tiers.

    What does it take to build the n-tier Application?The single most important factor that decides the success of the n-tier application is athrough business or domain knowledge.

  • 8/9/2019 Extreme Pgms

    2/21

    The second most important access is the technical and design know how. N-tier applicationsrequire us to put in a sufficient amount of thought to successfully distribute the overallfunctionality of the application in the appropriate tiers.

    When n-tier Applications should not be used?Building and implementing a successful n-tier application requires a lot of Effort, Skill,experience, commitment and Organizational Maturity.

    It also implies cost.

    Hence a favorable Cost-Benefit Ratio is necessary before you decide to go ahead with the n-tier Application.

    When n-tier Applications should not be used?Building and implementing a successful n-tier application requires a lot of Effort, Skill,

    experience, commitment and Organizational Maturity.

    It also implies cost.

    Hence a favorable Cost-Benefit Ratio is necessary before you decide to go ahead with the n-tier Application.

    What is a n-tier Application?Simply stated, an n-tier application helps us distribute the overall functionality into varioustiers or layers.

    For example in a typical implementation you can have one or more of the following layers

    1) Presentation Layer2) Business Rules Layer3) Data Access Layer4) Database/Data store

    In certain scenarios some of the layers mentioned above may be split further into one ormore sub layers.

    Each Layer can be developed independently of the other provided that it adheres to thestandards and communicates with the other layers as per the specifications.

    This is one of the biggest advantages of the n-tier application.Each layer can potentially treat the other layers as black-box

    In other words, each layer does not care how the other layer processes the data as long asit sends the right data in a correct format.

    Building them with C#, .NET:

  • 8/9/2019 Extreme Pgms

    3/21

    C#.NET provides us an excellent, robust feature rich platform.C# being Object Oriented Programming Language it helps in practically laying down thestandards. For instance you could create a base class with standard functions and requirethat all new classes should be derived from this base class. Please see the article onInheritance in this series.

    NET provides type safety, automatic Garbage Collection which is very important inimplementing good n-tier apps.

    The Logical Building Blocks

    The above diagram describes the logical building blocks of the Application.

    1) The Presentation Layer: Also called as the client layer comprises of components thatare dedicated to presenting the data to the user. For example: Windows/Web Forms andbuttons, edit boxes, Text boxes, labels, grids, etc.

    2) The Business Rules Layer: This layer encapsulates the Business rules or the businesslogic of the encapsulations. To have a separate layer for business logic is of a greatadvantage. This is because any changes in Business Rules can be easily handled in thislayer. As long as the interface between the layers remains the same, any changes to thefunctionality/processing logic in this layer can be made without impacting the others. A lotof client-server apps failed to implement successfully as changing the business logic was apainful process.

    3) The Data Access Layer: This layer comprises of components that help in accessing theDatabase. If used in the right way, this layer provides a level of abstraction for the databasestructures. Simply put changes made to the database, tables, etc do not effect the rest ofthe application because of the Data Access layer. The different application layers send thedata requests to this layer and receive the response from this layer.

  • 8/9/2019 Extreme Pgms

    4/21

    The database is not accessed directly from any other layer/component. Hence the tablenames, field names are not hard coded anywhere else. This layer may also access any otherservices that may provide it with data, for instance Active Directory, Services etc. Havingthis layer also provides an additional layer of security for the database. As the other layersdo not need to know the database credentials, connect strings and so on.

    4) The Database Layer: This layer comprises of the Database Components such as DBFiles, Tables, Views, etc. The Actual database could be created using SQL Server, Oracle,Flat files, etc.In an n-tier application, the entire application can be implemented in such a way that it isindependent of the actual Database. For instance, you could change the Database Locationwith minimal changes to Data Access Layer. The rest of the Application should remainunaffected.

    Many packaged n-tier Applications are created so that they can work the same with SQLServer, Oracle, UDB and so on. In the above pages we have seen the background and thelogical design of the n-tier application. Large enterprise apps are typically designed as n-tierapplications and large portion of them are web based applications. Therefore they can be

    viewed in a secure manner, from any PC with a browser. This is a good combination of easeof use and security.

    How do the Layers communicate with each other?Each Layer comprises of one or more components. Each component being a part of the appmay communicate with one or more component. The component may speak to the othercomponents using one of the many protocols, HTTP, FTP, TCP/IP and mechanisms such asXML/RPC, SOAP, REMOTING etc. The data as such may be passed across in many formatssuch as binary, string , XML. For the purpose of this article we will use XML format forpassing data between the components.

    Communication Techniques in n-tier .NET Apps :

    The different layers of the n-tier applications can be located on physically differentmachines.Various techniques can be used to communicate between the various layers andcomponents. The most common include

    XML Web Services.NET Remoting

  • 8/9/2019 Extreme Pgms

    5/21

    A Web Based N-Tier Application

    In the diagram above we observe that the Presentation Layer is made ofWeb Pages, WebComponents and Web Server such as IIS. The end user sees the web pages on a Browsersuch as IE.

    To create a web based n-tier Application using C#, .NET the following steps need to befollowed:

    1) Define what the Application should do. In other words the functionality of the application.

    2) Segregate the application logic. The logic related to the User Interface or presentationlayer will be part of the presentation layer, The logic related to the Business Rules goes tothe Business Layer and so on.

  • 8/9/2019 Extreme Pgms

    6/21

    3) Design the Database Structures, such as Tables, Views and so on. The Database designis a very crucial step and it effects the overall application performance, reliability andusability

    4) After this you can design the Data Access Layer. This Layer comprises of code to accessthe database. The Data Access Layer components may typically be called by the Business

    Layer Components. The Design also defines how this call should be made. This includes theinterface definition, Inputs, Outputs, Data Structure Definition and so on.

    5) Similarly Business Application Layer design will define the Components that are part ofthis layer. Specifications for each component should include the Interface Definition, Inputs,outputs and Data structures (example XML DTD).

    6) The Presentation Layer is designed keeping in mind the ease of Use. The User Interfaceshould be intuitive and pleasant. The Presentation Layer may comprise of Web Pages suchas .aspx,HTML, and compiled components.

    Sponsored Links

    C Sharp Tutorials

    y Structural and Behavioral Design Patterns

    y Creational Design Patterns

    y Software Architecture & Design Patternsy C# Language Basics

    y . NET Type Safety

    y Regular Expressions in C# - Quantifiers and Delegatesy .NET Remoting

    y Regular Expressions and C#,.NETy Inheritance in C#y Building Web Based N-Tier Applications using C#

    y Delegates in C#

    Home Tutorials C Sharp

    Building Web Based N-Tier Applications using C#

    Category: C Sharp

    Comments (19)

    Building Web Based N-Tier Applications using C#This article explores the N-tier and Distributed Application Architecture. Over the lastdecade, the way applications are designed has evolved and come a long way. We havestand-alone applications, server based applications, client server applications, web basedapplications, n-tier applications, distributed applications, Peer-to-peer apps, service-oriented

  • 8/9/2019 Extreme Pgms

    7/21

    Architectures, component based Development and the list goes on. This article discusses theadvantages, disadvantages of n-tier applications and methods to implement web based n-tier Applications using C#, .NET

    Why N-Tier Applications?N-Tier Applications can easily implement the concepts of Distributed Application Design andArchitecture. The N-Tier Applications provide strategic benefits to Enterprise Solutions.While 2-tier, client-server can help us create quick and easy solutions and may be used forRapid Prototyping, they can easily become a maintenance and security night mare.

    The N-tier Applications provide specific advantages that are vital to the business continuityof the enterprise. Typical features of a real life n-tier may include the following:

    1) Security: Application has Appropriate Authentication, logging and monitoring

    mechanisms

    2) Availability and Scalability: Application should be reliable and should have sufficientfail-over mechanisms ( redundancy) such as fail-over clusters

    3) Manageability: Application should be designed to have the capability to Deploy, Monitorand troubleshoot. Methodology to handle Errors, log Errors and provide useful informationfor problem resolution

    4) Easy Maintenance: This is generally achieved by adopting coding standards,deployment standards, modular application design, data abstraction and applicationframeworks.

    5) Data Abstraction: Easily make changes to the functionality, business rules with theleast amount of impact to the entire applications

    The above mentioned points are some of the Key design goals of a successful n-tier application that intends to provide a good Business Solution.

    What does it take to build the n-tier Application?The single most important factor that decides the success of the n-tier application is athrough business or domain knowledge.

    The second most important access is the technical and design know how. N-tier applicationsrequire us to put in a sufficient amount of thought to successfully distribute the overallfunctionality of the application in the appropriate tiers.

  • 8/9/2019 Extreme Pgms

    8/21

    When n-tier Applications should not be used?Building and implementing a successful n-tier application requires a lot of Effort, Skill,experience, commitment and Organizational Maturity.

    It also implies cost.

    Hence a favorable Cost-Benefit Ratio is necessary before you decide to go ahead with the n-tier Application.

    What is a n-tier Application?Simply stated, an n-tier application helps us distribute the overall functionality into varioustiers or layers.

    For example in a typical implementation you can have one or more of the following layers1) Presentation Layer2) Business Rules Layer3) Data Access Layer4) Database/Data store

    In certain scenarios some of the layers mentioned above may be split further into one ormore sub layers.

    Each Layer can be developed independently of the other provided that it adheres to thestandards and communicates with the other layers as per the specifications.

    This is one of the biggest advantages of the n-tier application.Each layer can potentially treat the other layers as black-box

    In other words, each layer does not care how the other layer processes the data as long asit sends the right data in a correct format.

    Building them with C#, .NET:C#.NET provides us an excellent, robust feature rich platform.C# being Object Oriented Programming Language it helps in practically laying down thestandards. For instance you could create a base class with standard functions and requirethat all new classes should be derived from this base class. Please see the article on Inheritance in this

    .NET provides type safety, automatic Garbage Collection which is very important inimplementing good n-tier apps.

  • 8/9/2019 Extreme Pgms

    9/21

    The Logical Building Blocks

    The above diagram describes the logical building blocks of the Application.

    1) The Presentation Layer: Also called as the client layer comprises of components thatare dedicated to presenting the data to the user. For example: Windows/Web Forms andbuttons, edit boxes, Text boxes, labels, grids, etc.

    2) The Business Rules Layer: This layer encapsulates the Business rules or the businesslogic of the encapsulations. To have a separate layer for business logic is of a greatadvantage. This is because any changes in Business Rules can be easily handled in thislayer. As long as the interface between the layers remains the same, any changes to thefunctionality/processing logic in this layer can be made without impacting the others. A lotof client-server apps failed to implement successfully as changing the business logic was apainful process.

    3) The Data Access Layer: This layer comprises of components that help in accessing the

    Database. If used in the right way, this layer provides a level of abstraction for the databasestructures. Simply put changes made to the database, tables, etc do not effect the rest ofthe application because of the Data Access layer. The different application layers send thedata requests to this layer and receive the response from this layer.

    The database is not accessed directly from any other layer/component. Hence the tablenames, field names are not hard coded anywhere else. This layer may also access any otherservices that may provide it with data, for instance Active Directory, Services etc. Having

  • 8/9/2019 Extreme Pgms

    10/21

    this layer also provides an additional layer of security for the database. As the other layersdo not need to know the database credentials, connect strings and so on.

    4) The Database Layer: This layer comprises of the Database Components such as DBFiles, Tables, Views, etc. The Actual database could be created using SQL Server, Oracle,

    Flat files, etc.In an n-tier application, the entire application can be implemented in such a way that it isindependent of the actual Database. For instance, you could change the Database Locationwith minimal changes to Data Access Layer. The rest of the Application should remainunaffected.

    Many packaged n-tier Applications are created so that they can work the same with SQLServer, Oracle, UDB and so on. In the above pages we have seen the background and thelogical design of the n-tier application. Large enterprise apps are typically designed as n-tierapplications and large portion of them are web based applications. Therefore they can beviewed in a secure manner, from any PC with a browser. This is a good combination of ease

    of use and security.

    How do the Layers communicate with each other?Each Layer comprises of one or more components. Each component being a part of the appmay communicate with one or more component. The component may speak to the othercomponents using one of the many protocols, HTTP, FTP, TCP/IP and mechanisms such asXML/RPC, SOAP, REMOTING etc. The data as such may be passed across in many formatssuch as binary, string , XML. For the purpose of this article we will use XML format forpassing data between the components.

    Communication Techniques in n-tier .NET Apps :The different layers of the n-tier applications can be located on physically differentmachines.Various techniques can be used to communicate between the various layers andcomponents. The most common include

    XML Web Services.NET Remoting

  • 8/9/2019 Extreme Pgms

    11/21

    A Web Based N-Tier Application

    In the diagram above we observe that the Presentation Layer is made ofWeb Pages, WebComponents and Web Server such as IIS. The end user sees the web pages on a Browsersuch as IE.

    To create a web based n-tier Application using C#, .NET the following steps need to befollowed:

    1) Define what the Application should do. In other words the functionality of the application.

  • 8/9/2019 Extreme Pgms

    12/21

    2) Segregate the application logic. The logic related to the User Interface or presentationlayer will be part of the presentation layer, The logic related to the Business Rules goes tothe Business Layer and so on.

    3) Design the Database Structures, such as Tables, Views and so on. The Database design

    is a very crucial step and it effects the overall application performance, reliability andusability

    4) After this you can design the Data Access Layer. This Layer comprises of code to accessthe database. The Data Access Layer components may typically be called by the BusinessLayer Components. The Design also defines how this call should be made. This includes theinterface definition, Inputs, Outputs, Data Structure Definition and so on.

    5) Similarly Business Application Layer design will define the Components that are part ofthis layer. Specifications for each component should include the Interface Definition, Inputs,

    outputs and Data structures (example XML DTD).

    6) The Presentation Layer is designed keeping in mind the ease of Use. The User Interfaceshould be intuitive and pleasant. The Presentation Layer may comprise of Web Pages suchas .aspx,HTML, and compiled components.

    Each of the layers can typically be located on physically separate machines for variousreasons such as reliability, security and scalability.

    To understand the actual coding aspects for building an n-tier application or a distributedapplication architecture refer to our articles on Creating Components in C#.

    Summary:In the above article we discussed the evolution of various architectures and specifically n-tier applications and distributed application Architecure.

    Pass references to methods

    using System;

    class MyClass {

    int a, b;

    public MyClass(int i, int j) {

  • 8/9/2019 Extreme Pgms

    13/21

    a = i;

    b = j;

    }

    /* Return true if ob contains the same values as the invoking object. */public bool sameAs(MyClass ob) {

    if((ob.a == a) & (ob.b == b))return true;

    else return false;

    }

    public voidcopy(MyClass ob) {

    a = ob.a;

    b = ob.b;

    }

    public voidshow() {

    Console.WriteLine("a: {0}, b: {1}",

    a, b);

    }

    }

    class MainClass {

    public static voidMain() {

    MyClass ob1 = new MyClass(4, 5);

    MyClass ob2 = new MyClass(6, 7);

    Console.Write("ob1: ");

    ob1.show();

    Console.Write("ob2: ");

    ob2.show();

    if(ob1.sameAs(ob2))Console.WriteLine("ob1 and ob2 have the same values.");

    else

    Console.WriteLine("ob1 and ob2 have different values.");

    Console.WriteLine();

    // now, make ob1 a copy of ob2

    ob1.copy(ob2);

    Console.Write("ob1 after copy: ");

    ob1.show();

    if(ob1.sameAs(ob2))

    Console.WriteLine("ob1 and ob2 have the same values.");else

    Console.WriteLine("ob1 and ob2 have different values.");

    }

    }

    ob1: a: 4, b: 5

  • 8/9/2019 Extreme Pgms

    14/21

    ob2: a: 6, b: 7

    ob1 and ob2 have different values.

    ob1 after copy: a: 6, b: 7

    ob1 and ob2 have the same values.

    Objects are passed by reference.

    using System;

    class Test {

    public int a, b;

    public Test(int i, int j) {

    a = i;

    b = j;

    }

    /* Now, ob.a and ob.b in object

    used in the call will be changed. */public voidchange(Test ob) {

    ob.a = ob.a + ob.b;

    ob.b = -ob.b;

    }

    }

    class MainClass {

    public static voidMain() {

    Test ob = new Test(15, 20);

    Console.WriteLine("ob.a and ob.b before call: " +

    ob.a + " " + ob.b);

    ob.change(ob);

    Console.WriteLine("ob.a and ob.b after call: " +

    ob.a + " " + ob.b);

    }

    }

    ob.a and ob.b before call: 15 20

    ob.a and ob.b after call: 35 -20

    Use ref to pass an int value type by reference

    using System;

  • 8/9/2019 Extreme Pgms

    15/21

    class RefTest {

    /* This method changes its argument.

    Notice the use of ref. */public voidsqr(ref int i) {

    i = i * i;

    }

    }

    class MainClass {

    public static voidMain() {

    RefTest ob = new RefTest();

    int a = 10;

    Console.WriteLine("a before call: " + a);

    ob.sqr(ref a); // notice the use of ref

    Console.WriteLine("a after call: " + a);

    }

    }

    a before call: 10

    a after call: 100

    Passing ref-types by value

    using System;

    class Person

    {

    public string fullName;

    public int age;

    public Person(string n, int a)

    {

    fullName = n;

    age = a;

    }

    public voidPrintInfo()

    {Console.WriteLine("{0} is {1} years old", fullName, age);

    }

    }

    class MainClass

    {public static voidSendAPersonByValue(Person p)

    {

  • 8/9/2019 Extreme Pgms

    16/21

    p.age = 99;

    p = new Person("TOM", 999);

    }

    public static voidMain()

    { Person fred = new Person("Fred", 12);

    fred.PrintInfo();

    SendAPersonByValue(fred);

    fred.PrintInfo();

    }

    }

    Fred is 12 years old

    Fred is 99 years old

    Value types are passed by value

    using System;

    class Test {

    /* This method causes no change to the arguments used in the call. */public voidnoChange(int i, int j) {

    i = i + j;

    j = -j;

    }

    }

    class MainClass {

    public static voidMain() {

    Test ob = new Test();

    int a = 15, b = 20;

    Console.WriteLine("a and b before call: " +

    a + " " + b);

    ob.noChange(a, b);

    Console.WriteLine("a and b after call: " +

    a + " " + b);}

    }

    a and b before call: 15 20

    a and b after call: 15 20

  • 8/9/2019 Extreme Pgms

    17/21

    Sort an array

    using System;

    class MainClass {

    public static voidMain() {int[] nums = { 5, 4, 6, 3, 14, 9, 8, 17, 1, 24, -1, 0 };

    Console.Write("Original order: ");

    foreach(int i in nums)

    Console.Write(i + " ");

    Console.WriteLine();

    Array.Sort(nums);

    Console.Write("Sorted order: ");foreach(int i in nums)

    Console.Write(i + " ");

    Console.WriteLine();

    }

    }

    Original order: 5 4 6 3 14 9 8 17 1 24 -1 0Sorted order: -1 0 1 3 4 5 6 8 9 14 17 24

    Sort an array and search for a value

    using System;

    class MainClass {

    public static voidMain() {

    int[] nums = { 5, 4, 6, 3, 14, 9, 8, 17, 1, 24, -1, 0 };

    Array.Sort(nums);

    // Search for 14.int idx = Array.BinarySearch(nums, 14);

    Console.WriteLine("Index of 14 is " + idx);

    }}

    Index of 14 is 9

    Display the contents of the sorted array

  • 8/9/2019 Extreme Pgms

    18/21

    using System;

    using System.Collections;

    class MainClass

    {public static voidMain(string[] args)

    {

    // Create a new array and populate it.int[] array = { 4, 2, 9, 3 };

    // Sort the array.

    Array.Sort(array);

    foreach (int i in array) {

    Console.WriteLine(i);

    }

    }

    }

    2

    3

    4

    9

    Use System.Array.Sort() to sort an int array

    using System;

    class MainClass

    {public static voidMain()

    {int[] arr = {5, 1, 10, 33, 100, 4};

    Array.Sort(arr);

    foreach (int v in arr)

    Console.WriteLine("Element: {0}", v);

    }}

    Element: 1

    Element: 4

    Element: 5

    Element: 10

    Element: 33

  • 8/9/2019 Extreme Pgms

    19/21

    Element: 100

    Implementing IComparable and sort by Array.Sort

    using System;

    public class Employee: IComparable{

    public Employee(string name, int id)

    {

    this.name = name;

    this.id = id;

    }

    int IComparable.CompareTo(object obj)

    {Employee emp2 = (Employee) obj;if (this.id > emp2.id)

    return(1);

    if (this.id < emp2.id)

    return(-1);

    else

    return(0);

    }

    public override string ToString()

    {return(String.Format("{0}:{1}", name, id));

    }

    string name;int id;

    }

    class MainClass

    {public static voidMain()

    {

    Employee[] arr = new Employee[4];

    arr[0] = new Employee("A", 1);

    arr[1] = new Employee("B", 2);

    arr[2] = new Employee("C", 4);

    arr[3] = new Employee("D", 3);

    Array.Sort(arr);

    foreach (Employee emp in arr)

    Console.WriteLine("Employee: {0}", emp);

    Console.WriteLine("Find employee id 2 in the list");

    Employee employeeToFind = new Employee(null, 2);

  • 8/9/2019 Extreme Pgms

    20/21

    int index = Array.BinarySearch(arr, employeeToFind);

    if (index != -1)

    Console.WriteLine("Found: {0}", arr[index]);

    }

    }

    Employee: A:1Employee: B:2

    Employee: D:3

    Employee: C:4

    Find employee id 2 in the list

    Found: B:2

    Use Array.Sort to sort object array

    using System;using System.Collections.Generic;

    using System.Text;

    class MyClass : IComparable

    {public int TheValue;

    public int CompareTo(object obj)

    {

    MyClass mc = (MyClass)obj;

    if (this.TheValue < mc.TheValue)

    return -1;

    if (this.TheValue > mc.TheValue)

    return 1;

    return 0;

    }

    }

    class MainClass

    {

    static voidMain()

    {

    MyClass[] objectArray = new MyClass[5];

    for (int i = 0; i < 5; i++){

    objectArray[i] = new MyClass();

    objectArray[i].TheValue = 100 - i;

    }

    foreach (MyClass i in objectArray)

    Console.Write("{0} ", i.TheValue);

  • 8/9/2019 Extreme Pgms

    21/21

    Array.Sort(objectArray);

    foreach (MyClass i in objectArray)

    Console.Write("{0} ", i.TheValue);

    }

    }

    100 99 98 97 96 96 97 98 99 100

    Use the Sort() method to sort the elements in an int array

    using System;

    class MainClass

    {

    public static voidMain()

    {int[] intArray = {5, 2, 3, 1, 6, 9, 7, 14, 25};

    Array.Sort(intArray);

    Console.WriteLine("Sorted intArray:");for (int i = 0; i < intArray.Length; i++)

    {

    Console.WriteLine("intArray[" + i + "] = " +

    intArray[i]);

    }

    }

    }

    Sorted intArray:intArray[0] = 1intArray[1] = 2intArray[2] = 3intArray[3] = 5intArray[4] = 6intArray[5] = 7intArray[6] = 9intArray[7] = 14intArray[8] = 25