This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes 3-Tier or 2-Tier? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "3-Tier or 2-Tier?" Watch "3-Tier or 2-Tier?" New topic
Author

3-Tier or 2-Tier?

Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

Hi folks, I've a design question that I was wondering whether anyone could help me with? I'm trying to decide whether an application that I have should be described a 2-Tier or 3-Tier.

The application has the following setup:

  • Presentation Layer = Swing GUI
  • Business Layer
  • Data Layer

  • The Swing GUI communicates with the Business Layer using RMI. The Swing GUI is on one machine. Both the Business Layer and Data Layer are on another, single, machine.

    I've Google'd about for descriptions of 2-Tier and 3-Tier applications and I seem to get different definitions in different places. So I can't come to a conclusion between these two descriptions of my application:

    1) A 2-tier application with three layers.
    2) A 3-tier application (obviously with three layers).

    Is my Business Layer really a seperate tier? It is simple a single Java class that calls to directly to classes in my Data Layer. So it would not be possible to put the Business Layer on a separate machine (without modifying it to allow communication between the Business and Data layer over a network).

    Any advice appreciated!


    SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
    Jimmy Clark
    Ranch Hand

    Joined: Apr 16, 2008
    Posts: 2187
    Describe what your "Data layer" consists of.
    Sean Keane
    Ranch Hand

    Joined: Nov 03, 2010
    Posts: 581

    Data File (containing a simple list of records, so a single table) -> Data Manager (reads the data file) -> DAO -> DAOFactory
    Jimmy Clark
    Ranch Hand

    Joined: Apr 16, 2008
    Posts: 2187
    In the Computer Science field, the term "tier" traditionally has been used to describe a group of physical machines.

    In regards to a traditional Client-Server application, you had a Fat-client component on the user's machine and a database component on a server machine. Here, the term two-tier still applied to the physical hardware (even though in reality there usually would be many, many client machines, not just one.)

    Designers of the J2EE three-tier programming model, however, used the term "tier" to represent a logical design, not a physical design. In essence, you can build a three-tier application on a single CPU if you wanted. The term "tier" here is an abstract software concept, it does not represent hardware.

    The J2EE three-tier model consisted of a Presentation tier, a Business tier and an Integration tier. It is typically used for describing large applications. However, for fun we can describe your little application as follows:

    Presentation tier ----> GUI Objects
    Business tier ----> Business logic objects which include data access objects
    Integration tier ----> Data file on the file-system



    Sean Keane
    Ranch Hand

    Joined: Nov 03, 2010
    Posts: 581

    Hi Jimmy, thanks for the explanation. You touched on probably the main topic that confused me. What constitutes a tier? When is a layer a tier? When is a layer not a tier? Is a layer always a tier?

    Some descriptions I read said a tier had to be a physical distinction whereas others said it could be a logical distinction.

    The descriptions that said it had to be a physical distinction also mention that you could have 3-tier with two machines (presentation on one machine, business + data layer on second machine). But, and a big but in my case, I read it must be possible to put the business and data layer on separate machines. Which is not possible with my current implementation.

    In summary, would I be correct in understanding you would describe my application as 3-tier rather than 2-tier? Your reasoning being that a logical distinction is sufficient to call my business layer a separate tier?
    Jimmy Clark
    Ranch Hand

    Joined: Apr 16, 2008
    Posts: 2187
    In summary, would I be correct in understanding you would describe my application as 3-tier rather than 2-tier?


    Hi Sean, Thanks. No, you would not be correct here. Your application really is too small to be described as having any "tiers", in the real-world. There is a size aspect as well to the term "tier."

    However, for fun, in the context of describing the software design and describing how the software components are organized, yes your application can be described as a three-tier application. The important thing here is that there is a context. You are describing the organization of the "software."

    In the English language, there are many conditions where information can be understood or interpreted in more than one way. Context usually is very critical element in resolving ambiguity or guiding interpretation. Hence, as always, a clear and sharp understanding of English is very important in software engineering.

    Your Business tier contain multiple layers, e.g. (1) business logic layer, (2) data access layer, etc.
    Sean Keane
    Ranch Hand

    Joined: Nov 03, 2010
    Posts: 581

    Jimmy Clark wrote:There is a size aspect as well to the term "tier."

    I've read quite a few descriptions of 3-tier architecture and none mention size are being a prerequiste to using this architectural description. Size is a subjective term, so this sounds quite unusual to me. This implies that the use of 3-tier architecture as a description is a subjective one. At what point is the size too small - surely open to personal opinions.

    When you mention size, what are you measuring? The number of entities? Something else?
    Jimmy Clark wrote:The important thing here is that there is a context. You are describing the organization of the "software."

    Let's talk in more concrete terms. If I take the starting point of "something is either 3-tier or it isn't 3-tier", why is this not the case?
    Jimmy Clark
    Ranch Hand

    Joined: Apr 16, 2008
    Posts: 2187
    Deciding to use the term "three-tier" to describe a design is a subjective decision. As an author, it is important to ensure that there is a clear context to your message. If there is no clearly understood context, readers may become confused.

    Basically, if you are unsure about the understanding of your readers, it is best to define what you mean by the term "tier" and then go foward and describe your design.

    Sun's J2EE three-tier programming model had nothing to do with the number of CPU or machines. A conforming application could be on 20 machines or 1 machine.
    Sean Keane
    Ranch Hand

    Joined: Nov 03, 2010
    Posts: 581

    Jimmy Clark wrote:Sun's J2EE three-tier programming model had nothing to do with the number of CPU or machines. A conforming application could be on 20 machines or 1 machine.


    So what is this size aspect to the term "tier." that you mentioned previously?
    Jimmy Clark
    Ranch Hand

    Joined: Apr 16, 2008
    Posts: 2187
    A close reading of the definition of the word "tier" should help.


    http://www.merriam-webster.com/dictionary/tier


    A "tier" of seats in a baseball stadium refers to a group of seats, not a single seat. If you wanted to refer to a single seat, you would not use the word "tier" to describe it.

    In terms of effectively describing computer hardware, you would use the term "tier" to describe a rack (or group) of machines not a single machine.

    Hope this helps!
    Sean Keane
    Ranch Hand

    Joined: Nov 03, 2010
    Posts: 581

    How many seats has a single tier of a wedding cake got ? A close reading of the following I think will show that your interpretation of the word tier is not the only one http://dictionary.reference.com/browse/tier

    But English lessons aside. This is interesting, I've not yet read any explanation of a 3-tier architecture where it stipulates that in order for a system to be regarded as 3-tier that each tier must be composed of several groups of machines. I would be interested in reading about this further, have you a reference?
    Jimmy Clark
    Ranch Hand

    Joined: Apr 16, 2008
    Posts: 2187
    A three-tier logical software architecture design can be implemented using a singe CPU or multiple CPU. Here you are describing the organization of the software components, not the physical nodes.
    Sean Keane
    Ranch Hand

    Joined: Nov 03, 2010
    Posts: 581

    Super, that sounds like many of the descriptions that I have read. So back to my original query and the application I outlined. It sounds like you would regard my application as being 3-tier from the perspective of a logical architectural design. Am I understanding you correctly?
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: 3-Tier or 2-Tier?
     
    Similar Threads
    Design choices
    shall DataInterFace be general or specfic to FBN project?
    Three or 4 Tier?
    Passed SCJD with 137/155
    Thin Client/Fat Client?