Reply
Thread Tools
Posts: 999 | Thanked: 1,117 times | Joined on Dec 2009 @ earth?
#1
My day job is a systems/web Developer and often use the principles of multi-tier design.

E.g. Database layer, Business Logic layer and Presentation layer.

Assuming each layer can be an independant library, would this be a "good" design for a mobile app or will the overhead of "shuttling" data between each layer be too cpu/memory consuming.

The main reason I am asking this question is that I am writing some software on the n900 but also want it available on my Linux desktop. At some point I will be uploading the data to a website.
__________________
I like cake.
 
krk969's Avatar
Posts: 754 | Thanked: 630 times | Joined on Sep 2009 @ London
#2
Originally Posted by johnel View Post
Assuming each layer can be an independant library, would this be a "good" design for a mobile app or will the overhead of "shuttling" data between each layer be too cpu/memory consuming.
The main reason I am asking this question is that I am writing some software on the n900 but also want it available on my Linux desktop. At some point I will be uploading the data to a website.
IMHO,
being modular will also help reusability.
there is certainly no noticable lag in dynamically linking libs.
__________________
Developer of :
Buddy - budget/expense manager ( website )
Showtime - a telly channel listing viewer/reminder ( website )
Travelapp - london underground status/planner ( website )
Batlevel - desktop widget for battery level ( website )

“I hear and I forget. I see and I remember. I do and I understand.”

Last edited by krk969; 2010-05-17 at 08:56.
 

The Following User Says Thank You to krk969 For This Useful Post:
Posts: 146 | Thanked: 76 times | Joined on Feb 2010 @ Poland
#3
You should not worry about mem/cpu problem until you encouter it. Although you should always have in mind.

So in my opinion this is a "good design".

With sufficient need (when the need arises), you can stray from this design.
__________________
Remember to click Thanks! if this post is of any help
 

The Following User Says Thank You to Robb For This Useful Post:
smoku's Avatar
Posts: 1,716 | Thanked: 3,007 times | Joined on Dec 2009 @ Warsaw, Poland
#4
Originally Posted by johnel View Post
Assuming each layer can be an independant library, would this be a "good" design for a mobile app or will the overhead of "shuttling" data between each layer be too cpu/memory consuming.
In context of Maemo, it certainly is good design.
Maemo is a normal POSIX-derivative system and does not differ from desktop system.

Take a look how browser infrastructure with eal/microb/browserd/browser, or media playback with alsa/pulseaudio/gstreamer/mafw/player are split to interworking modules. Files are managed with tracker/sqlite combo. etc. etc.
__________________
smoku @xiaoka.com (SMTP/XMPP) ...:.:....:... pebbled . Poky Fish : sixaxis . psx4m . uae4all
Jolla Phone post-mortem . . . . . . . . . . -> 1+1 VGN-UX390N
 

The Following User Says Thank You to smoku For This Useful Post:
Posts: 999 | Thanked: 1,117 times | Joined on Dec 2009 @ earth?
#5
At the moment I am using python.

I've written a script that creates the database schema. I know need to write the code to read/write the data.

I can either;
(a) write the code in the above database script to access the tables directly or
(b) write an additional script that will access the tables in a "standard" way.

For me the benefit of (b) is that I can change the database script to point to something else - e.g. an online database like mysql or postgres and in theory the additional script would not need to be altered.

I've written python scripts on a "desktop" PC without any problems just wondering what other aspects of a mobile device I need to be aware of (e.g. battery consumption, memory use).
__________________
I like cake.
 
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#6
Aim for readability and maintainability before thinking about memory use and speed. If your application is slow, do the work at that time.

So, I have to agree with the people above: keep it in separate modules.

A further benefit is that it makes refactoring a lot easier.
 

The Following User Says Thank You to Joorin For This Useful Post:
Posts: 999 | Thanked: 1,117 times | Joined on Dec 2009 @ earth?
#7
Some great replies - thanks everyone.

I'm working on an exercise/workout app but with the complication that it has to run on the n900, my laptop and eventually as a web app.

I can program the crap out of a web server and stuff like that - it's been many years since I wrote a "desktop" application.

I have decided to go with 3 layers and currently thinking of the object model.

Something along the lines of:
dbobject = directly interacts with database, performs reads/writes.

the middle-tier is responsible for creating objects
(E.g. a 'fitnessUser' object - properties filled from database).
The objects do not access the database directly (e.g. do not execute sql statements) but inherit behaviour from dbobject instead.

the presentation layer will create middle-tier objects and then populate the GUI with object properties.

The database layer can be a sqlite database on the device or a 'web-service'. Ideally the middle-tier objects should not know the difference.

Ideally same for the GUI. The presenation layer could be a web page or a QT-based screen on the n900.

Does this make sense?

Do I need some kind of psychiatric help?
__________________
I like cake.
 
juise-'s Avatar
Posts: 186 | Thanked: 192 times | Joined on Jan 2010 @ Finland
#8
Originally Posted by johnel View Post
Something along the lines of:
dbobject = directly interacts with database, performs reads/writes.

the middle-tier is responsible for creating objects
(E.g. a 'fitnessUser' object - properties filled from database).
The objects do not access the database directly (e.g. do not execute sql statements) but inherit behaviour from dbobject instead.

the presentation layer will create middle-tier objects and then populate the GUI with object properties.

The database layer can be a sqlite database on the device or a 'web-service'. Ideally the middle-tier objects should not know the difference.
KISS principle applies, also don't try to predict the future too much as that's non-trivial.

But yes, making code reusable and maintainable is a good idea. A well thought-out layer structure doesn't add that much overhead, and it doesn't sound like you need to put a ton of data through it anyway.

One thing to consider is that mobile devices have varying degree of connectivity, so you might still need to cache locally and upload/download when connectivity is available.
 

The Following User Says Thank You to juise- For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 04:36.