473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Class Design Question for 3-tier web app

Hi,

We are building a 3-tier web-app and are currently in planning phase.
At the business layer, I have a class which has a 2-d array which can
potentially hold thousands of rows. The thing is on the UI, I would
like to implement some kind of paging to display only N rows at a time
from this 2-d array.

I only want to retrieve records for the current page from the database.
This way the object does not overload memory with all rows that are not
currently shown on the UI.

How should I handle this in the class design? Should I have a property
in the class which will hold the current page number? This class
represents a business object, so I am not keen on that solution.

Any suggestions on how to handle this while designing classes? We are
currently in the Planning phase, and this will be a great help.

Thanks,
JGP

Nov 19 '05 #1
4 1221
I would probably create a method for you businesslayer app that takes a
starting row and the number of rows to return.

If you are using a datagrid to display with paging enabled, it will
store the CurrentPageIndex and the PageSize.

Pass into your business layer GetPagedData( CurrentPageIndex*PageSize,
PageSize) or something to that effect. That will keep your
presentation logic and business logic separated.

BTW. This only reduces the memory requirements for the client, not
your server. Unless you are implement the paging at the database layer
(or wherever) all of rows will reside in memory on your server. I need
more specifics on where your data is coming from.

Also, instead of a 2d array you might consider a collection of objects.
It will be much easier to work with.

Hope this helps,
John

Nov 19 '05 #2
> How should I handle this in the class design? Should I have a property
in the class which will hold the current page number? This class
represents a business object, so I am not keen on that solution.
Good to see you giving this some thought! Actually, keeping track of the
current page number in the business class is not a bad idea, as the page
number is not related per se to the user interface, and is used to fetch
data from the data layer. It can be used by the interface as well, but that
is what business objects are for (to manipulate and provide data to the
interface).

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Chumma Dede" <jo******@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com... Hi,

We are building a 3-tier web-app and are currently in planning phase.
At the business layer, I have a class which has a 2-d array which can
potentially hold thousands of rows. The thing is on the UI, I would
like to implement some kind of paging to display only N rows at a time
from this 2-d array.

I only want to retrieve records for the current page from the database.
This way the object does not overload memory with all rows that are not
currently shown on the UI.

How should I handle this in the class design? Should I have a property
in the class which will hold the current page number? This class
represents a business object, so I am not keen on that solution.

Any suggestions on how to handle this while designing classes? We are
currently in the Planning phase, and this will be a great help.

Thanks,
JGP

Nov 19 '05 #3
john, just a question. Would there be any advantage to having 2 collections:
one to hold the current data (or a reference to it) until (if) it is to be
updated to the data store; and one to hold the next data to be sent to the
ui. Wouldn't that speed up the data display since you could fetch the next
data collection while the current data collection is being displayed to the
ui and you wouldn't have to make a round trip to the data store from the ui
(through the business layer) to get each page of data. Kinda like "chunking"
or "buffering", I guess.
"john_teague" <jc******@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I would probably create a method for you businesslayer app that takes a
starting row and the number of rows to return.

If you are using a datagrid to display with paging enabled, it will
store the CurrentPageIndex and the PageSize.

Pass into your business layer GetPagedData( CurrentPageIndex*PageSize,
PageSize) or something to that effect. That will keep your
presentation logic and business logic separated.

BTW. This only reduces the memory requirements for the client, not
your server. Unless you are implement the paging at the database layer
(or wherever) all of rows will reside in memory on your server. I need
more specifics on where your data is coming from.

Also, instead of a 2d array you might consider a collection of objects.
It will be much easier to work with.

Hope this helps,
John

Nov 19 '05 #4
Well, the only way I can see the speeding things up is if you an async
call back to get the next set of results.

ArrayList CurrentResults;
ArrayList NextResults;

when you view CurrentResults, you need need to keep NextResults synched
as well, so you would always be making a trip to the datastore on the
same thread.

An async callback might speed things up a little bit, but not sure it
would be worth it. It really depends on the number of records your
dealing with, the web server and database server capabilities to
determine which approach.

The common argument at my place to work is that our database is stored
on a very powerful server, so do as much as you can there. However, I
think that only holds true for extreme number of records (and if you
have that many records, maybe that should be filtered first). If I'm
dealing with <= 1000 records, I would prefer to cache the entire
collection on the webserver and pull back exactly what I want from the
cached collection.

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Aguilar, James | last post by:
My previous example used the concept of a Shape class heirarchy, so I will continue with that. Suppose I have something like fifty different shapes, and I am trying to instantiate one of them. ...
15
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design decision. This really is a toy project written for...
3
by: fernandez.dan | last post by:
I'm still learning how to use Object Oriented concepts. I'm have a basic question dealing with design. I have two classes that deal with I/O pertaining to network and usb that inherit from an...
9
by: David A. Osborn | last post by:
I have a set of classes that each have an enumeration in them, and based on dynamic input I need to access a different enumeration. For example Three classes Class_A, Class_B, and Class_C that...
3
by: Trammel | last post by:
Hi, I recently upgraded to VB.net from VB6.. and woah... I feel lost :¬O One of my reasons for upgrading is I was told that VB.net can do class inheritance and subclassing easier. ...
6
by: Orgun | last post by:
Hi, I sent this message to the moderated c++ group too but it is waiting for moderator approval and I wanted to send here too. I am new to Design Patterns. I want to write a simple...
25
by: David Sanders | last post by:
Hi, As part of a simulation program, I have several different model classes, ModelAA, ModelBB, etc., which are all derived from the class BasicModel by inheritance. model to use, for example...
6
by: JoeC | last post by:
I have a question about designing objects and programming. What is the best way to design objects? Create objects debug them and later if you need some new features just use inhereitance. Often...
5
by: pgrazaitis | last post by:
I cant seem to get my head wrapped around this issue, I have myself so twisted now there maybe no issue! Ok so I designed a class X that has a few members, and for arguments sake one of the...
6
by: Bhawna | last post by:
I am into c++ code maintenance for last 3-4 years but recently I am put into design phase of a new project. Being a small comapany I dont have enough guidance from seniors. Currently I am into a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.