-
3 tier application implementation
I would like to find a simple example of a 3 tier java application.
For example, that gets some students names and grades from a database,
uses a separate business layer to calculate an average and then displays
the info on a thin client GUI. I get many compile errors when I try to go
from 2 tier to 3 tier and I do not know why?
-
Re: 3 tier application implementation
"Rob" <Robert.S.Cascella@lmco.com> wrote:
>
>I would like to find a simple example of a 3 tier java application.
>For example, that gets some students names and grades from a database,
>uses a separate business layer to calculate an average and then displays
>the info on a thin client GUI. I get many compile errors when I try to go
>from 2 tier to 3 tier and I do not know why?
What kind of compile errors?
Remember that there is a difference between physical and logical tiers.
You can have 3 (or n) logical tiers but it runs on one machine. You should
code your 'application' in such a way that it is easily dividable in any
combination necessary. How it is deployed should be a separate concern from
the GUI/Business Logic/Persistance concern(s). This is a better way to think
about it than thinking in tiers because what we have today is n-tier. Don't
architecting a good distributed 'app' is not easy and usually not right the
first time.
How much detail do you want? This could easily become a book (and has).
Mark
-
Re: 3 tier application implementation
The way I had done it I got unresolved symbol error when I tried to assign
a value from a calcAvg() method.
This is the problem. My application starts in a class called myApp which
is the GUI layer. myApp has a member variable called myDBLook which is an
object of my Database connection class and I pass into the constructor a
Textfield and 2 choice (comboboxes). while in myDBLook's constructor, I populate
the gui list with students names and sum up 3 test scores.
Now the only way I could get this to work was to have a member variable
in myDBLook called myBusiness whose constructor is passed SUM. The Business
logic in myBusiness just divides SUM by 3 and returns the students average.
I have sucessfully compiled and run it this way. The business layer is even
in a different file and I can change the business logic without having to
re-compile the gui/DB stuff. But each tier is nested in anothers
constructor and I am passing parameters. Is there a better or more widely
used approach? Somehow creating an instance of a layer inside another seems
like a poor approach. I think I would rather create all 3 layers in a
'holder class' and have each layer exposed to each other.
I got the compile error before I nested the layers but in my working design
the business layer cannot access the GUI layer directly.
Hope you are up to this. All this is running on one machine, in one
application.
-Rob
"Markn" <m@n.com> wrote:
>
>"Rob" <Robert.S.Cascella@lmco.com> wrote:
>>
>>I would like to find a simple example of a 3 tier java application.
>>For example, that gets some students names and grades from a database,
>>uses a separate business layer to calculate an average and then displays
>>the info on a thin client GUI. I get many compile errors when I try to
go
>>from 2 tier to 3 tier and I do not know why?
>
>What kind of compile errors?
>
>Remember that there is a difference between physical and logical tiers.
>You can have 3 (or n) logical tiers but it runs on one machine. You should
>code your 'application' in such a way that it is easily dividable in any
>combination necessary. How it is deployed should be a separate concern
from
>the GUI/Business Logic/Persistance concern(s). This is a better way to
think
>about it than thinking in tiers because what we have today is n-tier. Don't
>architecting a good distributed 'app' is not easy and usually not right
the
>first time.
>
>How much detail do you want? This could easily become a book (and has).
>
>
>Mark
-
Re: 3 tier application implementation
Have a look at this article on MVC and let me know what you think. There
are variations on the theme so don't take everything as gospel. But Scott,
the author, is pretty good with Java.
http://www7.software.ibm.com/vad.nsf/Data/Document2672
From first glance it seems you are connecting things at the wrong place.
Typically one would have a UI - Business Layer - Persistance Layer. The
UI shouldn't have a reference to a Database. Usually how we hook Views(UI)
and business logic together is with Controllers. And we us alot of interfaces.
Mark
"Rob" <Robert.S.Cascella@lmco.com> wrote:
>
>The way I had done it I got unresolved symbol error when I tried to assign
>a value from a calcAvg() method.
>
>This is the problem. My application starts in a class called myApp which
>is the GUI layer. myApp has a member variable called myDBLook which is an
>object of my Database connection class and I pass into the constructor a
>Textfield and 2 choice (comboboxes). while in myDBLook's constructor, I
populate
>the gui list with students names and sum up 3 test scores.
>
> Now the only way I could get this to work was to have a member variable
>in myDBLook called myBusiness whose constructor is passed SUM. The Business
>logic in myBusiness just divides SUM by 3 and returns the students average.
>
>I have sucessfully compiled and run it this way. The business layer is even
>in a different file and I can change the business logic without having to
>re-compile the gui/DB stuff. But each tier is nested in anothers
>constructor and I am passing parameters. Is there a better or more widely
>used approach? Somehow creating an instance of a layer inside another seems
>like a poor approach. I think I would rather create all 3 layers in a
>'holder class' and have each layer exposed to each other.
>
>I got the compile error before I nested the layers but in my working design
>the business layer cannot access the GUI layer directly.
>
> Hope you are up to this. All this is running on one machine, in one
>application.
>
>-Rob
>
>
>
>
>
>
>
>
>"Markn" <m@n.com> wrote:
>>
>>"Rob" <Robert.S.Cascella@lmco.com> wrote:
>>>
>>>I would like to find a simple example of a 3 tier java application.
>>>For example, that gets some students names and grades from a database,
>>>uses a separate business layer to calculate an average and then displays
>>>the info on a thin client GUI. I get many compile errors when I try to
>go
>>>from 2 tier to 3 tier and I do not know why?
>>
>>What kind of compile errors?
>>
>>Remember that there is a difference between physical and logical tiers.
>
>>You can have 3 (or n) logical tiers but it runs on one machine. You should
>>code your 'application' in such a way that it is easily dividable in any
>>combination necessary. How it is deployed should be a separate concern
>from
>>the GUI/Business Logic/Persistance concern(s). This is a better way to
>think
>>about it than thinking in tiers because what we have today is n-tier.
Don't
>>architecting a good distributed 'app' is not easy and usually not right
>the
>>first time.
>>
>>How much detail do you want? This could easily become a book (and has).
>>
>>
>>Mark
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks