Using local SQL and services

James Gardner's Avatar

James Gardner

08 Aug, 2011 12:45 PM

Hi,

I'm still shaping my thinking around how to best use robot legs and need a bit of guidance towards best practices.

My question is, how do I map the process of connecting to a database to the layout of a robotlegs app? For example where should the code go for setting up and accessing the database and so on? I've had a look at some example apps which all use different methods. Joel's address book app uses a helper which is situated in the services folder.

I'd really appreciate any advice on this just so I can be confident that I am heading in the right direction.

  1. Support Staff 1 Posted by creynders on 09 Aug, 2011 05:39 PM

    creynders's Avatar

    In general anything that accesses something outside your application is considered a service. Obviously this doesn't mean that you need to cram everything in one or more services, you create helper classes and delegates that can be reused by several services for instance.
    When it comes to accessing a local database I tend to delegate accessing the database to a helper class, an adapter or facade that makes it easier to CRUD the database records. I tend to create use-case specific services and generic helpers.
    For instance a UserDataRetrieverService with a retrieveUserDataByID method and then a SQLLiteFacade class with a generic method retrieveFromTable (just making it up as I write, but I think you catch my drift)
    Obviously you'll want to map both against an interface to ensure you can easily switch implementation if you'd want.

  2. Support Staff 2 Posted by Ondina D.F. on 02 Nov, 2011 03:14 PM

    Ondina D.F.'s Avatar

    Closing the thread.
    If you need more help with this, feel free to re-open this discussion. Please open new threads for new issues.
    Thanks!
    Ondina

  3. Ondina D.F. closed this discussion on 02 Nov, 2011 03:14 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac