0

I try to construct 3-tier application. In DAL I get data from database (No-SQL) to DataSets. In BLL I process this data if it is necessary. In PL I show appropriate data.

The question is: If data in database are still updating, and I need to have at once newest 'rows', should I update DataSet in BLL with some timer or somewhere else?

Dennis Traub
  • 50,557
  • 7
  • 93
  • 108
Saint
  • 5,397
  • 22
  • 63
  • 107

1 Answers1

1

When you say "at once" I have to assume that your application is very eager on data... for that you should use a 4th layer between your DLL and BLL and called Cache.

As it seams that you want things fast, and for fast things, you never call the database over and over, you call once and when there's an update, you clear the cache on that entity and next time your BLL asks the data, the cache is empty so it passes to the DAL to retrieve a new set of records, putting it in the cache for the next call.

To be alert with updates you can do your own notification system, or simple implement the INotifyCollectionChanged interface...

If you do not want to take all this trouble, when you send the new row to be changed, you already have the data, you can easily add it to the grid (or any colection object that you are using) with a simple

DataTable dt = bll.ListAllEmployeesByCompanyId( 2 );
dt.Rows.Insert(0, myNewRow);
gv.DataSource = dt;

You can easily create a nice UX by making a top border in that grid and make it yellow (as the data did not come from the database) and turn it into light green when the data come all from the database (and all is in sync) ...

It's all up to your strategy, it's always down to the one and only question for every software we develop:

Does the user really care about that awesome feature?

Because, we developers tend to assume a lot, and sometimes, you do assume wrongly :)

balexandre
  • 73,608
  • 45
  • 233
  • 342
  • Thanx for your answer. But if packets are comming in every second, I think better idea is only update cache, not clear. I mean when any change was caused then cache refresh own data. – Saint May 28 '12 at 08:37
  • if packages are coming every second, you would take a completely different approach, and never this normal one that only apply for 80% of the cases, with update rates like that, you would use different databases and technologies, like I have [asked in the Programmers site](http://programmers.stackexchange.com/questions/43927) – balexandre May 28 '12 at 08:50
  • I use now MongoDB (http://en.wikipedia.org/wiki/MongoDB) that has required mechanisms like "Archiving and event logging", "Aggregation", "Server-side JavaScript execution", "Capped collections" and much more so I think database is appropriate. Only question about architecture and way to data updating. – Saint May 28 '12 at 09:09