Key point to keep in mind when writing database interaction layer (DAL) -


what key aspects or points when writing data access layer (dal).

do allow higher layers pass "unique" queries dal, ie not standard update, insert , delete...?

how 1 allow scalability in such layer?

any comments great

aiden

speaking experience there few key aspects when writing dal.

  1. making dal interface
  2. pick right level of abstraction
  3. keep caching in mind

(1) make sure dal interface. allows mock methods might call database testing. if have getitems() function in interface, can implement class goes out database and class mocks data quick unit testing.

(2) while you're doing (1) make sure you've picked right level of abstraction. example, i've seen bad dal @ current company used abstract query language each call.

as example, 1 call in our dal be:

getitems(list filters, int limit, int skip).

instead have liked see:

getitems(list ids, int pagesize, int page).

we let details of underlying data source (mongo in case) bleed through interface. exposing mongo specific features in our interface. careful not that!

if step can swap backing data store relational document whatever.

(3) keep caching in mind. pretty simple, make sure consider how cache dal calls. address scalability. might aop (aspect oriented programming) use dal calls.

your specific questions:

  1. i allow high layers pass unique queries. remember pick right abstraction though can swap persistence store if need to.
  2. use caching ton (likely distributed cache) provide scalability. simple that. =)

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -