My Authors
Read all threads
I'm working on a new workshop that will guide students through an array of different data access approaches for OO languages (.NET/C# specifically). I like to start such topics off with principles that apply to the space. Here's what I have so far - am I missing anything obvious?
These are "data access principles" which when I searched I didn't find any handy lists. I'll probably write up a blog post on the topic soon.
Acquire late; release early.

This applies to any shared, external resource, such as a database connection. It's a low level principle that most modern developers don't even think about, but I think it's still worth mentioning.
Prefer chunky to chatty interfaces.

This assumes data access is not local to the application, which is typical for most web apps. A native app with an integrated data store might not need to follow this.
Fetch only what you need.

Avoid getting more data than you need. This applies both to number of rows and number of columns (if thinking in tabular terms). Overfetching leads to performance issues at every level of the stack.
Cache frequently-used, rarely-changing data.

Such data is frequently referred to as "read-mostly". Basically, avoid constantly asking your database for the exact same data, especially if you're doing it multiple times per second.
Don't Repeat Yourself.

The DRY principle applies to data access code. Most of the patterns and abstractions we use for data access are meant to reduce the amount of repetitive plumbing code we write, so we can focus on higher level concerns (and make fewer mistakes).
Command Query Responsibility Segregation.

This often only becomes important with the need to scale or other requirements, but considering it from the start can make such changes easier.
Those are the main principles. These 4 SOLID principles also apply:
Single Responsibility
Open/Closed
Interface Segregation
Dependency Inversion

I don't have a great example of Liskov Substitution mattering to much in the context of data access or I'd just say all of SOLID...
This is for an NDC workshop next week, if you're curious. You can sign up here still:
ndcmelbourne.com/agenda?day=29-…
Now my request to you: In the words of Thomas Jefferson,

🎶"So what'd I miss?"🎵

What fundamental principle(s) of data access would you include that I haven't covered in the above thread?

#programming #dotnet #csharp
*too much*
I published my list in article form here:
ardalis.com/data-access-pr…
Missing some Tweet in this thread? You can try to force a refresh.

Keep Current with Steve "ardalis" Smith

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!