Andrea Bizzotto 💙 Profile picture
Feb 9, 2022 7 tweets 3 min read Read on X
Domain-Driven Design helps us write complex software.

At the heart of it lies the *domain model*, which is a conceptual model that incorporates both behavior and data.

Sounds complicated?

Let's explain with an example. 🧵
Suppose we want to build an eCommerce app.

To better understand this domain, we need to figure out:

- the entities we care about and their relationships
- the behaviour (or business logic) for manipulating them

The end result may look like this:
In Dart, we can represent each entity as a simple model class.

As we define this, it helps to think about all the properties that we need to show in the UI:
In some cases we need both a model class and the logic for manipulating it.

For example, here's how we may define a shopping cart class along with some methods for mutating its items:
Note how the Cart class and MutableCart extension don't have dependencies to any objects that live outside the domain layer.

This makes them very easy to test:
Eric Evans has written an ENTIRE book about Domain-Driven Design, and it's well worth a read if you want to expand your skills as an application developer.

But here's a short summary that may help you take the first steps in this complex field:
Did you find this useful or have feedback to share? Let me know in the comments. 👇

And for more Flutter (and app development) tips, just follow me: @biz84

Happy coding!

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Andrea Bizzotto 💙

Andrea Bizzotto 💙 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!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @biz84

Mar 20, 2023
Can GPT-4 and GPT-3.5 play Wordle? 🤔

I decided to find out! Here's what I discovered:

✅ GPT-4 understands the game and can improve on each move
❌ GPT-3.5 doesn't quite get it 😅

Want to know all the details (prompt & answers)? Then read on! 🧵 GPT-4 completed Wordle in 4 moves: - apple (XXXXO) - ember (
First of all, I've used the same prompt for both models.

I tried to be very explicit about the game rules and provided an example.

Here's what it looks like. 👇 I need your help playing Wordle. Your job is to guess an exi
Here's how things went with GPT-4.

First three guesses: Yes, I understand the rules. I will try to guess the 5-lette
Read 12 tweets
Sep 30, 2022
I know that many people out there are looking for their first tech job (Flutter or otherwise) and times are tough.

Having hired talent twice in the last year, I received many applications but very few good ones.

So here's some advice from a "hiring manager" perspective.

🧵
If you knew you had FIVE seconds to make a good impression, what would you do?

This is not a hypothetical question.

If a hiring manager has 50 applications sitting in the inbox, how would they quickly tell the good from the bad ones?

In other words, how do you stand out?
Things that go a long way:

1️⃣ competence
2️⃣ enthusiasm
3️⃣ trustworthiness

Let me elaborate on each one. 👇
Read 15 tweets
Sep 29, 2022
If your users speak another language, you’ll need to localize your Flutter app 🗺

Here’s how to setup Flutter app localizations in just 5 minutes, using code generation.

Also covered: template vs non-template files and synthetic vs non-synthetic package. 👀

🧵 Image
1️⃣ As a first step, we need to add the required packages to the pubspec.yaml file. Image
2️⃣ Create l10n.yaml at the root

✔️ arb-dir is the input folder where Flutter will look for the localized strings
✔️ output-dir is where the localizations classes will be generated
✔️ template-arb-file is the main template that contains a description for each localized message Image
Read 14 tweets
Jul 25, 2022
What's the difference between errors and exceptions in Flutter?

→ Errors are programmer mistakes. They are fatal and we should not try to recover from them
→ Exceptions are failure conditions that are out of our control. We should handle them and recover gracefully

Thread 🧵 Image
Errors are fatal and when they happen the program *cannot* recover normally.

→ we want to discover (and fix) them as early as possible in the development process
→ we should track them in production using a crash reporting solution, so that we can measure impact and severity
The most common errors we may encounter are:

- AssertionError
- TypeError
- ArgumentError
- RangeError
- UnimplementedError
- StateError

and many others.

They all *extend* the base Error class, and the full list of errors can be found here:

api.flutter.dev/flutter/dart-c…
Read 7 tweets
Jul 11, 2022
In the last few months, I've been sharing many useful Flutter tips & tricks. 💙

Here are the top 10! 👇🧵 Here's a list of my top 10 Flutter tips & tricks.
1) Rules to follow for good app architecture

Read 12 tweets
Jun 9, 2022
Sometimes we need to write business logic inside classes that have multiple dependencies.

To do this, we can pass the dependencies as constructor arguments.

A much simpler solution is to pass `ref.read` as an argument.

Here's a thread with all the details. 🧵
Reader is just a function we can use to read a provider's value, *just once*.

And once we get the underlying value (a repository in this case), we can call methods on it.

Note: when we want to access a provider inside a widget callback, we do exactly the same thing.
An alternative way of doing this is to pass "ref" directly.

As a result, we have to call "ref.read(provider).someMethod()" inside our class methods.

Though if you only ever need to read (and not watch or listen), using Reader makes your intention more explicit.
Read 4 tweets

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/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

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

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(