ملخص شامل — Comprehensive Summary
Learning Domain-Driven Design (Vlad Khononov) — Book Overflow, Part 1 (chapters 1–6 of the book)
الملخص العربي
الفكرة الكبرى
الحلقة تناقش الثلث الأول من كتاب «تعلّم التصميم الموجّه بالمجال» (DDD). الرسالة الأساسية: مهمة المهندس ليست كتابة الكود فقط، بل فهم «مجال العمل» ونمذجته. التعقيد في البرمجيات نوعان: عَرَضي (مشاكل نصنعها لأنفسنا: أدوات، إعدادات، كود متكرر) وجوهري (صعوبة نمذجة الواقع نفسه). الأدوات والذكاء الاصطناعي تأكل التعقيد العرضي بسرعة، فتبقى القيمة الحقيقية للمهندس في التعقيد الجوهري: فهم العمل ونمذجته — وهذا بالضبط ما يعلّمه DDD.
1) شقّان لـ DDD
- الاستراتيجي: فهم العمل، تقسيمه إلى مجالات فرعية، رسم حدود السياقات، الاتفاق على اللغة. (المتحدثان يمدحانه بشدة.)
- التكتيكي: أنماط الكود: الكيانات، كائنات القيمة... (يحذّران منه إن طُبّق دون استراتيجية: يتحوّل إلى «إعصار تكتيكي» وكود مؤسسي مثقل بالأصناف الضحلة — «داء الأصناف».)
- الكتاب نفسه يحذّر: إن تخطّيت الاستراتيجي ستقع في المشاكل.
2) اللغة الموحّدة (Ubiquitous Language)
إن سمّى العمل الشيء «مطالبة» فالصنف اسمه Claim. لا طبقة ترجمة بين لغة خبراء المجال ولغة الكود والتوثيق. ناثان قرر بعد قراءة الكتاب أن يلتزم بمفردات أصحاب المصلحة «دائماً وبلا استثناء».
3) السياق المحدود (Bounded Context)
- نموذج مكتفٍ بذاته، يملكه فريق واحد (والفريق قد يملك عدة سياقات، لكن السياق لا يملكه عدة فرق).
- اختبار جيد له: أن تستهلك بيانات سياق آخر كمستهلك خالص دون معرفة تفاصيله الداخلية.
- خريطة السياقات (Context Map): من يستهلك ماذا ومن يملك ماذا.
- قاعدة ناثان العملية: يجب أن تستطيع رسم السياقات كـ رسم موجّه غير دوري (DAG) للنشر؛ لا اعتماديات دائرية (A تُخبر B وB تُخبر A = مشكلة).
- السياق ليس بالضرورة خدمة مصغّرة: قد يكون مكتبة أو وحدة داخل Monorepo.
- الكلمة نفسها قد تعني أشياء مختلفة في سياقات مختلفة: مثال «الإغلاق» (Closing) في صفقة عقارية مقابل إغلاق القرض. الحل ليس تعريفاً عالمياً واحداً، بل تعريف داخل كل سياق.
4) ثلاثة أنواع من المجالات الفرعية
| النوع | المعنى | القرار | أمثلة |
|---|---|---|---|
| أساسي (Core) | ميزتك التنافسية، مصدر المال | ابنه داخلياً بأفضل مهندسيك | خوارزمية مطابقة السائقين في أوبر، شبكة التوصيل في أمازون |
| داعم (Supporting) | ضروري ومخصّص لكن غير مميِّز | ابنه ببساطة أو خصّص أداة | استضافة Grafana ذاتياً، مرآة حزم Python، أدوات التسويق الداخلية |
| عام (Generic) | مشكلة محلولة | اشترِه/استخدم جاهزاً | Stripe للمدفوعات، البنية السحابية |
5) المجالات الفرعية تُكتشَف ولا تُخترَع
أنت لا تقرر المجالات، بل تكتشفها من واقع العمل. أما السياقات المحدودة فتُصمَّم. وليست العلاقة بينهما واحداً لواحد دائماً. «كل النماذج خاطئة وبعضها مفيد» — كالخرائط: خريطة قيادة وخريطة مشي وخريطة طبوغرافية؛ لكل سياق خريطته. النموذج الملموس يوحّد فهم الفريق كله (مثال قطعة الخشب في جيب مخترع Palm Pilot).
6) المراقبة والارتهان للمزوّد (استطراد عملي مهم)
لا تستدعِ SDK المزوّد (Datadog مثلاً) من منطق العمل مباشرة. غلّفه خلف واجهة خاصة بك (حقن التبعيات/عكس التحكم)، مع تنفيذ «لا يفعل شيئاً» للاختبارات. النتيجة: تبديل المزوّد = ملف واحد، والاختبار أسهل. مثال ناثان: غلاف lib/blob حول Vercel Blob. وتحذيره: «لن يكون يومين من العمل» إن لم تجرّد من البداية — حتى مع الذكاء الاصطناعي.
7) DDD التكتيكي وأمثلة الكود
- كائن القيمة (Value Object): هويته بقيمته، غير قابل للتغيير (المال، العنوان، اللون).
- الكيان (Entity): له هوية ودورة حياة (العميل، الطلب).
- نقاش
PhoneNumberصنفاً أم نصاً + دالة تحقق؟ الجواب: حسب أهميته للعمل. إن كانت أرقام الهواتف جزءاً من ميزتك التنافسية فاجعلها كائناً غنياً، وإلا فدالة بسيطة تكفي. - نقد أمثلة الكتاب (C#): كود مؤسسي ثقيل؛ «لن تأتي للكتاب من أجل الكود».
8) الخلاصات الشخصية
- كارتر: سينمذج المجالات الفرعية لشركته الآن استعداداً للنمو من 12 إلى 30 مهندساً، حتى لو بقيت في Monorepo.
- ناثان: سيضاعف الالتزام باللغة الموحّدة في «المخطط الموحّد» لمستودع البيانات.
- النماذج تتقادم حين يتغير العمل (إعادة هيكلة، استحواذ)، فعِش مع عواقب قراراتك وراجعها.
- العيش في عالم التعقيد العرضي وحده لم يعد مساراً مهنياً. واختر عملاً تهتم بمجاله.
English Summary
The big idea
The episode covers the first third of Learning Domain-Driven Design. Core message: an engineer's job is to understand and model the business domain, not just write code. Complexity is either accidental (problems we create: tooling, boilerplate) or essential (modeling the real world). Tools and LLMs are eating accidental complexity, so the engineer's lasting value is in essential complexity — exactly what DDD teaches.
1) Two halves of DDD
- Strategic: understand the business, split it into subdomains, draw context boundaries, agree on language. (Both hosts praise it.)
- Tactical: code patterns — entities, value objects, etc. Without strategy it becomes a "tactical tornado" and class-heavy enterprise code ("classitis", per Ousterhout).
- The book warns: skip strategic DDD and you will run into problems.
2) Ubiquitous language
If the business says "claim", the class is Claim. No translation layer between domain experts, code and docs. Nathan's takeaway: always use the stakeholders' vocabulary, without exception.
3) Bounded contexts
- A self-contained model owned by exactly one team (a team may own several contexts; a context is never shared by teams).
- Good test: you can consume another context's data as a pure consumer without knowing its internals.
- A context map shows who consumes what and who owns what.
- Nathan's rule: deployments of your contexts should form a DAG — no circular dependencies.
- A context need not be a microservice: a library or a module in a monorepo works.
- The same word can mean different things in different contexts: "closing" a real-estate deal vs. a loan closing. Define the term per context, not globally.
4) Three subdomain types
- Core: your competitive advantage — build in-house (Uber's matching, Amazon's fulfillment).
- Supporting: necessary, custom, but not differentiating (self-hosted Grafana, a Python package mirror, internal marketing tools).
- Generic: solved problems — buy or reuse (Stripe, cloud infrastructure).
5) Subdomains are discovered, not invented
Subdomains come from business reality; bounded contexts are designed; the mapping is not always one-to-one. "All models are wrong, some are useful": like maps (driving, hiking, topographic), each context gets the model it needs. Concrete models align the whole team (the Palm Pilot wooden block).
6) Observability and vendor lock-in
Never call a vendor SDK (e.g., Datadog) from business logic. Wrap it behind your own interface (dependency injection / inversion of control) with a no-op default for tests. Switching vendors becomes a one-file change. Nathan's example: a lib/blob wrapper around Vercel Blob. Without the abstraction, switching back "will not be a couple of days of work", even with AI.
7) Tactical DDD and code
- Value object: identified by value, immutable (money, address, color).
- Entity: identity plus lifecycle (customer, order).
PhoneNumberclass vs. string plus validator? It depends on how central it is to the business. Rich object if it's a competitive advantage, a plain function otherwise.- The book's C# examples feel enterprise-heavy: "you're not coming to this book for the code."
8) Takeaways
- Carter: model his company's subdomains now, ahead of growing from 12 to 30 engineers, even within a monorepo.
- Nathan: double down on ubiquitous language in a unified data-warehouse schema.
- Models decay when the business changes (reorgs, acquisitions): live with your decisions and revisit them.
- Living purely in accidental complexity is no longer a career path; work on a domain you care about.
التطبيق العملي: نطبّق المحاضرة على تطبيق مشاوير وطرود
المتحدثان ضربا مثال أوبر للمجال الأساسي. سنأخذ تطبيقاً مشابهاً (مثل «شلّة معاك») ونمرّ بخطوات DDD بالترتيب الذي يوصي به الكتاب: الاستراتيجي أولاً، ثم التكتيكي.
الخطوة 1 — صنّف المجالات الفرعية (تمرين تفاعلي)
لكل قدرة في التطبيق، اختر نوعها. القاعدة من الدقيقة 26:15: هل هي سبب اختيار الزبون لك؟ أم ضرورية ومخصصة؟ أم مشكلة محلولة؟
الخطوة 2 — اكتب اللغة الموحّدة لكل سياق
لاحظ كيف تتغير كلمة «إنهاء/Complete» وصاحبها حسب السياق، تماماً كمثال «الإغلاق» الذي ذكره ناثان 49:27.
| المصطلح عند أهل العمل | الاسم في الكود | السياق | المعنى داخل هذا السياق |
|---|---|---|---|
| سائق | Driver | المشاوير | شخص له موقع ومقاعد وتقييم |
| مندوب توصيل | Courier | الطرود | نفس الشخص، لكن يهمنا الوزن الأقصى ومنطقة العمل |
| مشوار | Ride | المشاوير | رحلة واحدة من نقطة الالتقاط إلى الوجهة |
| إنهاء المشوار | Ride::complete() | المشاوير | الوصول للوجهة وتحديد الأجرة ← يُطلق حدث RideCompleted |
| تسليم الطرد | Shipment::complete() | الطرود | لا يكتمل إلا برمز التسليم من المستلم |
| أجرة | Money (Value Object) | مشترك | مبلغ + عملة، غير قابل للتغيير، يُقارن بقيمته |
الخطوة 3 — ارسم الحدود والاتجاهات
- كل سياق يملكه فريق واحد (أو أنت وحدك الآن، لكن بمجلدات منفصلة جاهزة للتقسيم — كما يخطط كارتر 1:04:32).
- الفوترة تستهلك حدث
RideCompletedكمستهلك خالص، ولا تقرأ جداول المشاوير مباشرة 23:40. - الاعتماديات في اتجاه واحد: المشاوير ← الفوترة ← بوابة الدفع. إن احتاجت الفوترة أن «تُخبر» المشاوير فهذا إنذار 24:13.
الخطوة 4 — الكود التكتيكي (PHP 8.3، بنية Laravel)
الكود كامل وقابل للتشغيل، وقد شغّلته فعلاً (المخرجات بالأسفل). كل ملف يشير إلى الدقيقة التي جاء منها مفهومه.
ربطه بـ Laravel
// app/Providers/AppServiceProvider.php
public function register(): void
{
// المكان الوحيد الذي يعرف اسم المزوّد (Datadog / Sentry / Grafana)
$this->app->singleton(Telemetry::class, fn () => match (app()->environment()) {
'testing' => new NoopTelemetry(),
'production' => new DatadogTelemetry(),
default => new StdoutTelemetry(),
});
$this->app->bind(PaymentGateway::class, StripeGateway::class);
}
// app/Providers/EventServiceProvider.php — خريطة السياقات في سطر واحد
protected $listen = [
\App\Rides\Domain\RideCompleted::class => [
\App\Billing\Application\ChargeRiderWhenRideCompleted::class,
],
];
// composer.json → "autoload": {"psr-4": {"App\\": "app/"}}
// app/Rides app/Parcels app/Billing app/Shared ← سياق لكل مجلدالمخرجات الحقيقية لتشغيل php demo.php
== 1) Value Objects ==
PhoneNumber VO → +970591234567 (Jawwal)
Flat function → isValidMobile("12345") = false
Money equality by value → true
== 2) Core subdomain: matching + pricing (Rides context) ==
[telemetry] rides.assigned {"ride":"r-100","driver":"Ahmad"}
Assigned driver: Ahmad
[telemetry] billing.ride_charged {"ride":"r-100","amount":"26.00 ILS","txn":"txn_c0df89dc"}
Ride status: completed, charged: 26.00 ILS
== 3) Invariants protected by the model ==
Blocked: Only an assigned ride can be completed
[telemetry] rides.assigned {"ride":"r-101","driver":"Mahmoud"}
6 passengers → got Mahmoud (7 seats)
== 4) Same person, same word, different context (Parcels) ==
Parcel complete blocked: Wrong delivery code — cannot complete
Shipment status: delivered
== 5) Swap telemetry vendor without touching business logic ==
Datadog adapter received: [{"metric":"shillah.rides.assigned","tags":{"ride":"r-200","driver":"Ahmad"}}]
APP_ENV=testing يختفي كل سطر telemetry لأن التنفيذ الافتراضي لا يفعل شيئاً.الخطوة 5 — قرار PhoneNumber: صنف أم دالة؟
اخترناه هنا لأن التطبيق يتصل بالسائقين والركاب طوال اليوم ويهمه المشغّل (جوال/أوريدو) والصيغة الدولية؛ فالرقم جزء من عمله الأساسي.
لو كان الرقم مجرد حقل اختياري في صفحة «تواصل معنا»، فإن isValidMobile() تكفي. القاعدة 55:13: أهمية الشيء للعمل تحدد ثراء نموذجه.
واجبك: طبّقها على مشروعك
- اكتب قائمة بكل ما يفعله مشروعك، ثم صنّف كل بند: أساسي / داعم / عام. اسأل: لماذا يختارنا المستخدم؟
- اجلس مع صاحب العمل أو المستخدم واكتب قاموساً من 10 كلمات بلغته، واستعمل نفس الكلمات في أسماء الأصناف والجداول.
- ابحث عن كلمة واحدة تعني شيئين مختلفين في مشروعك (مثل «إغلاق»، «طلب»، «حساب») وافصل معنيَيها في سياقين.
- انقل مجلدات الكود إلى سياق لكل مجلد، وارسم الأسهم بينها. احذف أي سهم دائري.
- ابحث في الكود عن أي استدعاء مباشر لمزوّد خارجي (بريد، تخزين، دفع، مراقبة) وغلّفه بواجهة واحدة تُحقن من Service Provider.
Full English transcript
Podcast: Book Overflow — Carter Morgan & Nathan Toups
Video: https://www.youtube.com/watch?v=OPUVbTTOQgI
Length: 1:08:50
Source: YouTube auto-generated English captions (complete, unedited; may contain speech-recognition errors such as "Konov" = Khononov, "oster/Osterhalt" = Ousterhout, "Corore/Coral Logix" = Coralogix, "murders and acquisitions" = mergers and acquisitions).
Chapter 1: Intro
0:00 I was reading a lot of his book sort of adversarially being like what would oster think about these things. Um and I will say that I think in the realm of
0:09 strategic DDD there's actually a lot of good overlap with philosophy of software design.
0:19 [music]
0:21 Hey there. This is Book Overflows the podcast for software engineers by software engineers where every week we read one of the best technical books in the world in an effort to improve our craft. I am Carter Morgan and I'm joined
0:29 here as always by my co-host Nathan Tubes. How are you doing, Nathan? Doing great. Hey everybody.
0:34 I was just realizing I do that intro at every episode, but we didn't start out with that intro and I don't really want
0:41 to go back and listen to all of our early ones, but like it'd be in like when did we lock in on that? When do we lock in on that and do a great I'm gonna have to go check it out now.
0:51 I'll report back [laughter] next episode.
0:53 There we go. Um well, thanks for uh joining the podcast, everyone. Always like, comment, subscribe, join the Discord, uh book time with us on Leland.
1:01 All those links are in the episode description. Uh we're excited this week.
1:05 This is you. We had said we were going to do this one and then we actually took a break to read Mythical Man month. And I'm actually really glad we did because I think a lot of what's in this book
1:12 kind of dovetales nicely with Mythical Man month and with a lot of thoughts I've had lately about software engineering in general. Um and yeah,
1:21 that's what we got. Learning domain driven design by Vlad Konov.
Chapter 2: About the Book and Author
1:26 I think that's how you say it. K H O N O N O V. So, couple O's in there. Uh
1:35 Vlad Konov is a software engineer with over 20 years of industry experience during which he has worked for companies large and small and roles ranging from
1:42 web master to chief architect. When's the last time you've heard of someone being a web master? Old school.
1:49 That is that's old school. Yeah. What would we call a web master these days?
1:53 Just like a They kind of were like a jack of all trades. They were kind of like a CIS admin.
1:58 I I think I think CIS admin probably replaced it as a title probably.
2:04 But you probably just understood how the website worked and I'm sure you know he's probably dealing with CGI bins and Pearl scripts and all that kind of fun stuff.
2:10 Yeah. Yeah. Well, so we've got a we got a certified graveyard here. Uh Vlad maintains an active media career as a public speaker, blogger, and author. He
2:19 travels the world consulting and talking about domain driven design, microservices, and software architecture in general. Vlad helps companies make sense of their business domains,
2:27 untangle legacy systems, and tackle complex architectural challenges. He lives in northern Israel with his wife and an almost reasonable number of cats.
2:35 Uh, and I think reading this author introduction, I hadn't read this before the book, but um, this is another book that's like written by a consultant who
2:44 deals a lot with like legacy like Fortune 500ish companies. And that makes a lot of sense. Uh, Nathan and I were
2:52 talking about this kind of before the podcast starts. We're going to keep talking about it, but it's a it's kind of a different style of software. Um, as far as a book and introduction, he says, "Building software is harder than ever.
3:01 Uh, as a developer, you do you not only have to chase everchanging technological trends, but also need to understand the business domains behind the software."
3:08 This practical book provides you with a set of core patterns, principles, and practices for analyzing business domains, understanding business strategy, and most importantly, aligning software design with its business needs.
3:19 All right. So, this book is about 450 pages. How many chapters? I don't know. It's It's a decent amount of chapters.
3:26 Uh I'm looking right now. Um 16 16 chapters. So, we read the first six. Uh we're going to make this a three-parter.
3:37 So, we're about a third of the way through this book. Uh Nathan, give me your thoughts on learning domain driven design.
Chapter 3: Initial Thoughts
3:43 Yeah, overall I I think this is a great introduction to DDD. Um the you know the the famous book that started it all was
3:52 the it's the DDD Evans book. I think they call it the blue book. It rose to me if I'm mis mis attributing that. But
3:59 it's also famously difficult to read and a bit dated. Um that hasn't scared us off in the past. But I thought that if we were going to ease into proper DDD,
4:08 this one seemed highly regarded. It's also an O'Reilly book that came out um within the last five years. So I thought this would be a good good place to
4:16 start. Um, again, just from a aesthetics standpoint, the pacing is really good.
4:22 It's solidly written. Um, I really appreciate the way that DDD frames doing work in sort of this business and
4:31 terminology around things like bounded contexts and um, and sort of ubiquitous language and these other really
4:39 important things that I think a lot of teams struggle with. And I understand why DDD sort of starts with it and saying like, "Hey, uh, and we'll get
4:47 into it. Just like, hey, you can't just like reinvent the wheel and then hope that the rest of the business understands what you're trying to communicate. You have to spend a lot of time making sure that you've included
4:55 other stakeholders. And um I like that aspect of it. any criticism I have on the book is really sort of like there's
5:02 aspects of DDD that I don't love and it's probably in the same sense of that sort of consulting driven test driven
5:10 development or the getting into the tactical tornadoes type of world where I don't think it's DDD's fault itself but
5:19 I do think that there's aspects of like what's considered normal that I'm a little apprehensive about and so it's
5:26 not anything on the book itself it's really more on like do I reach the same philosophical conclusions and hopefully we can dig into that today.
5:33 Yeah, I I agree a lot on this being very well written. Uh we were joking like we've been spoiled with the podcast
5:41 where I think we've done like it's like five or six episodes in a row where we've had audiobooks and so we've been able to get through a a decent chunk of
5:50 the reading this year actually uh without actually reading. We've just been listening to the audiobooks. Um, so this is uh our first book in a while.
5:59 Um, but it is written very nicely, paced very well, strong voice from the author, uh, succinct, uh, doesn't spend any more
6:08 time. There was never a part where I'm reading and I'm like, oh, I wish she had talked more about that or kind of the opposite of like, okay, I get it. Let's move on.
6:15 Very talented author. Uh, and and this it dubtales really nicely with what we were talking about with mythical man month last week. And I' I've just been
6:24 thinking about this a lot. This idea of like accidental versus essential complexity where like all of software
6:32 engineering, the whole history of it has just been reducing accidental complexity, the problems we we cause for ourselves, right? And then there is the
6:41 essential complexity which is just the actual hard part of making software because you have to all software models
6:48 the real world in some way and choosing how you model the real world, right? uh is always going to be complex.
6:56 And so I I think in an LLM world really what that's doing is eating a lot of that accidental complexity. I think it's
7:05 chipping away at some of the essential complexity. Um but more in like a rubber duck thought partner kind of way. Um and
7:12 so this whole kind of first third of the book is about this idea of like modeling business domains. And I think that's a
7:21 really useful exercise as a software engineer because um the days of just making your living and the accidental
7:29 complexity have the they've shortened and and again the whole history of the field has been shortening those days. Um so
7:38 you know get comfortable get get used to this sort of stuff because uh I think this is where our our career I think I think this is also where you
7:45 know folks like J and um J or Will Larson have been kind of harping on this
7:53 for a while like you need to find the essential business value that's happening you know they kind of been pointing people and I think top sort of
8:01 engineers sort of intuitively find essential complexity to to spend their time Right.
8:07 Um, and I think what we are where we are now, it really just sort of it's a forcing function to get a lot more
8:14 things. And I will say if you try to dial it in, you also run into a lot of problems. I think this book, and we'll get into it, um, there's a tactical
8:23 portion of DDD and then there's also a strategic portion. And they kind of give this warning over and over again. If you skip strategic DDD, you're going to run
8:32 into problems. And I would say that that's doubly true. now, right? Uh that you really need to spend time on the
8:40 strategy side. And again, this is a a good throughine of talking about Mythical Man month, talking about Will
8:46 Larson's uh his his all of his books kind of [clears throat] get into this stuff as well. And um I I don't know.
8:54 It's It's weird that we're kind of gravitating towards this theme that's been going up. This year has been all about this, right? And I'm I don't know.
9:04 I'm pretty excited because I think books like this actually become more important as we're writing less code uh just because we need to spend time in that strategy strategy section.
Chapter 4: A Different Way of Writing Code
9:14 Yeah. I and as we're reading this book that they start getting into some code examples and I think
9:23 it's just like you said Nathan, it's just a different way of writing code and it's a way of writing code that I've kind of avoided like the plague. like there there's just a type of engineer
9:32 who who works like in that Microsoft stack. It's like C andnet and Azure and it's very like buttoned up. Um it's not
9:42 my jam. Um so I I don't really play in that. Uh
9:49 but I don't know like I've never been I've never been super interested in like
9:55 the nitty-gritty of code. Like I I like I don't know like I like good performant
10:02 readable code, right? But I'm I've always found myself much more concerned with like the higher level
10:10 decisions like architectural stuff or broader patterns throughout the code base or um how we're again modeling kind
10:20 of features in the real world. Um like people laugh my company like I'm a notoriously easy PR reviewer. Um but
10:27 I'll have a lot of thoughts about like uh yeah like the the da d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d da models I'm I'm much more picky about. Um
10:36 so I don't know like that you read a book like this which is just like a lot of like here's how you should write code, here's how you should write code, here's how you should write code. And I
10:45 don't know like part of me is like is it because we're in this age of AI that I find myself being a little like eh, you
10:52 know, why do we care that much? or was I always like that?
10:57 Yeah. And and I will say that some of these feel like obvious and good code structure and some of these kind of feel a little
11:06 contrived to prove a point. And I wouldn't again I don't knock the book too hard on it because if the code example doesn't apply to you or if it's
11:14 not in your coding style, it doesn't meet your aesthetics, who cares? You just kind of look at okay that's a way of doing it. I wouldn't do it that way. And I think that that is something you should develop over time.
11:24 This book is not about implement it this way, right? It's really sort of saying, hey, if you see this sort of class with
11:33 these fields in it, here's the here's the like accidental complexity that can come out of it. And I think regardless of the style, it's helpful, right? It's
11:42 helpful to go, oh yeah, yeah, we do that. like we don't actually have a way of knowing is this a unique ID for this user class and how does that model back
11:51 to what we store in the database right or whatever sort of thing that you kind of run into right when you're yanking something out of a data store and
11:59 interacting with it with some state machine or you know some thing that you're trying to like reason about and he doesn't get too much into at least in
12:07 these first six chapters of he'll kind of give a nod to like oh this is really easy to model if you can do a transaction, but we're going to get into
12:16 distributed data, distributed data systems and things like that. And he kind of was just like, hey, this is why you'll get tangled up. Um, but I think
12:24 it's really left to a book like designing data intensive applications or some of the other books that we've read to kind of get into that, you know, the
12:32 deeper wise. I think in this in the case of DDD, he's really focused on
12:38 um this idea of like how do I model reality in a way that minimizes trying
12:47 to boil the ocean or trying to like model everything in perfect at a global scale. Is there a way that we can structure things and so teams can be
12:55 independent, we can work with stakeholders, um that we can adapt to changes over time, all the stuff that you kind of
13:02 think about when we think about um evolutionary architectures and these other things, they all kind of like dovetail really nicely to each other.
13:09 You've done more consulting work and and and do more consulting work right now, but I also know that a lot of your work
13:15 is more like with like startups. Um, yep.
13:20 And so to me it's like I I've been fortunate that most everywhere I've worked has had pretty good code. I've looked at code and been like some of
13:29 this is is wrong. Uh or you know I at my current place like the code we inherited
13:35 like yeah there was just like a lot like you know like some 700 line functions.
13:43 But my complaint wasn't with like the the overall pattern of the code like how it was modeled. Like it actually
13:51 made sense to me that like okay we you know have these controllers and these controllers call service methods and
13:58 these service methods all farm their operations out to like database access objects, right? And like it was all like
14:06 the the highle pattern made sense but then just like the actual kind of in the weeds implementation just got very everything was too tangled with
14:15 each other. There was a lot of like oh this edge case is handled by one conditional 400 lines in here when maybe
14:24 it would have been better to do like a kind of dependency injection thing right and say like like you know there's a lot of like if we're in development mode
14:32 then log this here instead of here and I'm kind of like well maybe we should just have like and like log's a bad
14:39 example like a better example is like uh sending emails or something like that and it's like if we're in development mode, don't send the email. Instead,
14:47 just log it. And I'm a little like, what if we had like an email sender class or something like that and then at instantiation, you're you're inserting
14:55 like whether it's the dev class or the, you know, the the real class. Anyhow, but all that to say, like I haven't really worked at anywhere where it's just been like this is a rat's nest.
15:04 This is a a big ball of mud, you know, a bunch of spaghetti. Have you ever seen that? Because Oh, man. I I feel like that would make more sense because I feel that way about
15:13 kind of a clean code by Bob Martin where it's a little like I think people treat this a little too seriously or at least they used to but this is an improvement
15:20 over chaos and so like have you seen that just chaos?
15:25 Yeah. So I I've been really fortunate one of my So I've I've got some good steady direct client work that I'm doing. Um, but I also subcontract with a
15:32 company that does managed they they they provide managed uh
15:39 Kubernetes and DevOps really like mature DevOps best practices for pretty large organizations like I
15:47 would say you know organizations that are pretty mature and um are they've all been going through these like sort of modernization efforts and they realize
15:56 they don't really want to manage Kubernetes in house. So, one of the ways that they do this, they have a sort of a paid discovery process. Um, and it's
16:05 been really cool to work with them because I basically get a glimpse at where really smart engineering teams have been struggling spa basically like
16:13 victims of their own success. And some of these are startups and some of these are companies that have like established business models. And over and over and
16:21 over again, what you end up getting is the Chesterton's fence problem where you know maybe there's been churn in the organization or there's been leadership
16:30 changes that have happened and they know that things shouldn't be the way that they are and they know that they need to go a new direction but they don't even know where to get started because there's kind of this ball of mud, right?
16:39 There's just some fundamental thing that's just killing their velocity. They can't make some transition. they're kind of stuck with decisions from the past.
16:48 And it's tools like DDD that actually help you untangle, right?
16:53 So that this is where this like inverse Conway maneuver, all the things that we've talked about, team topologies, is that you're like, "Okay, so I I have
17:01 this mess. I know it's a mess. I know I don't want to be here anymore, but if I'm really afraid that if I make a change, I'm going to break the system and make it worse, and then I'm going to
17:10 get fired." Right? That's sort of the the fear thinking that comes up. And it's reasonable fear because you really can make things worse, right? You can make some you can kill the terminal patient, right?
17:20 And so how do I introduce changes or have a new way of talking to stakeholders? And this is the other
17:27 thing that I've noticed with um also in mergers and acquisitions. So I was at a series C funded company that we had
17:34 acquired a few companies and their product was good but then you get and look kind of look under the hood and you realize oh man there's some architectural and design decisions that
17:43 were made with this that are incompatible with what we're doing. We have this nice mature system. The gap
17:49 between their kind of mess and what we need to integrate is actually huge. It's this huge rift. And so again, we it's
17:56 another type of system in which we're forcing a system that's kind of working on its own into one that's actually a welloiled machine. And looking at them
18:05 next to each other, you realize that the first one's unacceptable, right? They will not be able to meet the pace of innovation and growth unless we get them
18:14 to cross the gap and and adopt these new patterns. And so these books again are super interesting because like I always look at how do we frame things and how
18:23 do we reduce sort of like they call the blast radius of a mistake, right? Can I introduce a new way of thinking? Um that
18:30 actually gives us a flywheel effect. All of a sudden the marketing team, you know, they have these landing pages and
18:38 they're super frustrated because anytime they need to make a change, it takes six months to make one silly little change.
18:44 Could we change the way we communicate with them and set expectations so that we're at least being honest with how
18:51 long something takes and then maybe we can even fix things sooner in the process so that we could iterate incomplete versions more quickly, right?
18:58 Like all the things that we talk about doing quick iteration.
19:01 Um that's and again it's hard to do that. De untangling something and then making it usable is way harder than
19:08 starting fresh and and and having a clean slate. Yeah, it's uh I also think there's a little bit with domain driven
19:15 design where like it won and so there's some again it's the whole like the fish doesn't know he's in water or you know
19:24 the fish doesn't know he's wet or whatever. Um which is like especially if you have worked at kind of more like
19:32 Fang or or or or very much like the Silicon Valley style company, right?
19:37 Then like it's very normal that you have like a users team and a payments team and a a shipping team and an orders
19:46 team. Whereas like we know it it wasn't always like that. Like it was very much like this is the database team, right?
19:53 This is the whatever you know this is the uh backend Ruby team. Um and so you
20:02 know like microservices really are very downstream of domain driven design and this idea that like you should model
20:10 everything you know based on business domains and and it's probably worth uh mentioning kind of what those some of the the principles of domain
Chapter 5: Ubiquitous Language and Bounded Contexts
20:19 driven design. I actually I made a if you look at this I made a tab called DDD primer which um so in the idea here and I think it is
20:27 good to give context before we get into like the the nuts and bolts of the book. Yeah. Yeah.
20:32 A couple of the big ones to take away and I think we've mentioned it a little bit which is um there's this sort of like tactical design and strategic
20:40 design. I think we're going to get into that more. Um that there's this this the concept that they call ubiquitous language. And I I really like this. This
20:47 again, this goes all the way back to the Evans book that started it all. But it's basically says, hey, if the business calls something, let's say an entity,
20:55 they call it a claim, right? Let's say they're an insurance company. They call something a claim, the class covering that thing better be called a claim,
21:02 right? Don't invent new words that you're going to use the same language that the business uses, right? and that it's really our responsibility to make
21:11 sure that we have to eliminate some translation layer that we really should be talking in the vocabulary of the business so that domain experts who we
21:21 rely on can easily interact with us right documentation should be in this all of these things should like serve that it's a really important core
21:28 principle um model driven design again we've kind of hinted at this but you're like hey we have to build a model of the universe we have to understand how a
21:37 business process functions and we have to have a model to to categorize this.
21:41 Um, and their whole point is that, hey, if you try to do this globally, you're going to have this huge mess. It's just way too hard. Too many people involved,
21:48 too many stakeholders. And so, you need this thing called the bounded context.
21:52 Um, and this is something actually we talk about at uh my like the the big client that I'm doing a bunch of work with right now. We're obsessed with
22:00 bounded context. Like we talk about bounded contexts all the time. Do you ever use that term or or talk about bounded context? I mean I I we don't use
22:07 it a ton but when I was reading about it I'm like okay that I I makes this makes sense.
22:12 Yeah. Right. And so like the the bounded context is this idea is and I think it's just what you were talking about here.
22:19 A team owns a bounded context and a team can even have multiple bounded contexts like multiple applications that they're
22:27 you know services or whatever that they're dealing with but one bounded context should not be owned by multiple teams right so you can have I can have multiple services that I'm building and
22:35 if we don't think about bounded context we just think like yeah these microservices or these you know the user service and the author service or whatever um one team could own both of
22:44 those that's fine but what you don't want is like the QA team and the, you know, the off team and the user team all
22:53 kind of like owning aspects of the off the user service or something. That's where things get really messy and become a big ball of mud.
23:00 Right. Right. And so you know they're really really clear that bounded context is a a self-sufficient model into itself
23:10 that uh it would you know you kind of are able to operate like autonomously and you have to obviously understand the
23:16 bigger system but about a context uh should give us a a context map right this artifact that tells us like who
23:25 consumes what from where and who owns what and you know how the system you really understand like one little chunk of the system in its completeness,
23:34 right? Like if if I'm the user's service, I'm on the user service team and that's that's my bounded context.
23:40 It's very likely that I'm going to need the orders for the user, right? But I am able to interact with those orders in a
23:48 pure like consumer matter, right? Um and uh I don't need to know the nitty-gritty of how those orders are processed, how payment is calculated, things like that.
23:59 like um it's kind of like if you can be abstracted away from the complexity of another segment of the business then
24:06 like I think that's a decent uh test for what a bounded context is.
24:13 Yep. And I'll tell you I play a game all the time from platform engineering and DevOps side. A bounded context should have you should take you should be able
24:21 to take all of your bounded contexts and create a directed asyclic graph of its deployment.
24:26 Yeah. Yeah. So you know a a good set of bounded contexts where you have nice abstractions is that I maybe I probably have a hierarchical structure right
24:34 there probably some you know let's say we're talking terraform for a second I might have a foundational Terraform deploy that really like bootstraps the system itself
24:42 but each of my services should operate independently and if they don't I need to have a directed asyclic graph that
24:49 says hey service A if it makes any changes downstream from it service B and C have to Right? And so therefore I
24:58 build this structure where what we don't want to do is say if service A changes then tell service B and if service B changes then tell service A. Right?
25:05 That's a problem. And ideally amongst my bounding context we have no hierarchal structure for the services that hopefully those are embarrassingly
25:14 parallel that I've got this flat way of fanning out and doing these things. And again when we start thinking about a bounded context it doesn't have to be a
25:23 service right one bounded context could be a shared library one bounded context could be you know you could imagine these things in which a group is
25:30 maintaining some chunk of reality understands what the business needs you know these kind of things fall into place and now all of a sudden you build
25:38 a context for your data mesh you have bound context for your web applications you have bound context for you know your all kinds of stuff that can come out of
25:47 it um and Again, this is why I think things like DDD have really been helpful because it gave people a strong set of
25:56 vocabulary to have these complex conversations.
26:00 Well, and uh so I think that that's kind of like your primer on domain driven
26:07 design. Um what I really like when he's talking about uh uh this idea of you have bounded context
Chapter 6: Core, Supporting, and Generic Subdomains
26:15 but like okay so what does a bounded context map onto and what it does it maps onto a business domain and he says there are three kinds of business domains you have core supporting and
26:24 generic core this is your competitive advantage you've got to build this inhouse um this
26:31 is you know if you're at a tech company this is you know what your basically what's making you your money, right? And so if you think about like Uber for
26:39 example, like some of their core domains are going to be like the actual routing algorithms that get like the uh that
26:48 match the drivers to the passengers. Um for Amazon, that's going to be their
26:55 fulfillment network. Um then you have supporting. These are necessary but not
27:02 differentiating. um that and this is this made sense to me because I guess maybe talk about generic first. Uh
27:09 generic is like these are solved problems, right? These are things like don't build your own cloud infrastructure, just use Stripe for payments, right? Um these are totally
27:18 fine to outsource. As far as supporting though, like I I'm trying to think about like what what are good domains that you
27:26 think fall into supporting? like is like maybe marketing is marketing a little like you might want to build some in-house tools to help facilitate marketing. Um
27:34 this is interesting. Um, I'm trying to think.
27:41 [sighs and gasps]
27:44 I think that this would be this.
27:46 Actually, I keep bringing up this idea of the of the worldly the worldly map because there's this this sort of maturity piece. think to me, again,
27:55 roast us in the comments if if we're screwing this up because I I hadn't spent a ton of time thinking about supporting, but I I think that these are
28:04 the kind of the the glue of putting things together, right? Like maybe maybe we haven't fully gone
28:12 to oh I think a perfect example of this you know you need an observability layer and you've just you haven't gone full
28:20 generic which is like I'm going to go pick graphana cloud or you know one of these or data dog or something right this just sort of off-the-shelf generic
28:28 I'm not even wor worrying about at all but I might actually decide to self-host the open source version of graphana
28:35 right that is work that we're doing we've decided decided to take this on the reliability of it. We've decided to take on the databases that support it
28:43 with the ingest pipelines, all these other things. Um, it's really not corder business, but it's it's pretty important, right? Like architecturally, we're making a lot of decisions.
28:53 And so, it's not your competitive advantage, but and it's not necessarily it's not a differentiating factor. Um,
29:00 but it's it's this it kind of helps with the the way that things work and you end up having to, you know, you're talking about open telemetry and things like
29:09 this, you have to write custom code, right? Like you're doing custom things. It's not competitive advantage core.
29:14 [snorts]
29:15 Um, it's also maybe not even appropriate to go fully generic, right? Like it you might need to actually do some custom stuff. And so I think I think in in a
29:24 lot of ways that DevOps type pipelines maybe uh you know self-hosting internal
29:32 uh you know doing a mirror of your Python libraries or something. So you've decided that you want to take on the burden of having your own you know
29:40 package repository something like this that's not core right like no customer is going to buy a widget from your factory because you self-host your
29:48 Python libraries. Um, and yet you're probably not using some generic off-the-shelf thing. Maybe you're using JROG or something. Um, but you probably
29:57 are running some sort of custom rolled stuff, right? These are the sort of supporting infrastructure that goes with that. This is only slightly related, but
Chapter 7: Observability and Vendor Lock-In
30:06 I've been curious about this. We read uh Mastering Open Telemetry by Steve Flanders and in it he's banging the drum
30:13 repeatedly that you you want to use the generic open- source open telemetry and you don't want to lock yourself in with like the data dog SDK.
30:23 Um do you think that matters as much in an LLM world? Do you think you should just I mean because you could just kind of
30:31 point Claude on Opus 4.7 and just be like, "Hey, we're swapping from data dog to Sentry. go change everything.
30:38 I am okay with it if there's certain patterns and one of them, of course, is it's controversial depending on your your style of things, but I'm a big fan
30:47 of the sort of inversion of control or dependency injection pattern. I'm okay with you pulling in data dog SDK stuff
30:55 if you wrap it in some sort of a maybe logging or telemetry, you know, container that's basically lets you hot
31:02 swap. It does a couple of things. It nerfs data dog a little bit. You're not going to reach for specific data dog SDK
31:09 things in your business logic. Um, but it does allow you to kind of like do this crawlwalk run where maybe we do
31:17 need some special magical data dog runtime things. Um, but it should really be encapsulated within your observability container, right? The the
31:25 the observability sort of like dependency injection stuff. It also will make it a lot easier to swap things out
31:32 because again, Data Dog will not be forever, right? Data Dog is not going to be a forever company. We It may just
31:40 stop being a company or it may just not be that great anymore. Or maybe it'll be great for the next 20 years. I don't really know. But I I will say that if
31:48 I'm architecting the system, I'm not going to bet the farm on a third party vendor. Right.
31:53 Right. Like that's not that's not interesting to me. I actually I was just doing a refactor this morning on my like personal I have a little website that
32:01 I'm doing like um experiments. It's called funk.lol.
32:05 Um, and I built a couple little things on it. And I realized I was trying to write some end to-end tests and it was kind of hard to mock blob storage because I'm using Verscell's blob
32:14 storage. And I just made a little wrapper function that is in I just have a lib/blob which allows me to have end
32:22 test that uses like a self-hosted web endpoint that lets me sort of like do a fake of of the blob storage. Um, and
32:30 what was nice about it is that it yanked a bunch of versellbob blob dependencies out of my business logic. Like all of a sudden now I have
32:38 this internal library. I can now hot swap it between testing and production.
32:42 It's a very small wrapper for the production workload. Um, and it again it's exactly this, right? It's like,
32:49 okay, well now if I decide to get off for cell and use a different blob storage in the future, it's a much easier thing, right? there's like one
32:56 little folder where I can hot swap the blob storage and not anything else that was relying on that just as long as it
33:03 doesn't break the lib/blob interface that I gave it, it's it's fine. Um, and so yeah, I mean it's like a yes and I
33:11 guess is that right? Um, yes, you should hopefully use the open telemetry generic library,
33:19 but um, and you could use data dog if it doesn't matter um, if you have good, you know, inversion to control.
33:28 Okay. Yeah. Yeah. No, I can see that.
33:30 I've just been thinking about that a lot because we are uh regular listeners to the podcast know about the ongoing migration at my company which I'm
33:37 pleased to say that we have achieved 93% completion on with at least pages the
33:44 amount of pages on the website like that talk to the old system. 93% of them don't talk to the new system and then there's there's like some other stuff
33:51 that we need to wrap up too. But anyhow, but just because it's such like a bounded uh problem like per page, it's
34:01 just kind of like I need you to replicate the old code in a new language with a new pattern and I know that it works because I know that all the
34:10 functionality of this page works. Like I have not been checking Claude super aggressively. Um and part of that is
34:17 just a judgment call because I'm like look do I understand all of this code exactly? No. Did I understand all of the other code, you know, the old Java code?
34:25 Exactly. Heck no, right? Like I understand this better. Um, and you know, it's just it's all trade-offs, right? Because it's like we could move
34:32 slower, but then we'd be moving slower, right? Anyhow, for for any net new stuff I've been doing, I've been supervising Cloud a lot better. And so, but just
34:39 because Claude has been doing a very good job of like like it doesn't really write code that doesn't compile anymore, right? Like, and you're using TypeScript, right?
34:49 That's TypeScript. Yeah. Yeah. So, so we're using Typescript, right? Um, and so I I do have a lot more trust in it with like
34:57 and we've invested a lot of time in skills and we have good uh like agents MD files and things like that. Um, but anyhow, and so I was just kind of like,
35:05 yeah, you know what, if if we were going, we are talking about switching to data dog right now. just use like uh
35:12 Graphfana hosted by AWS and and Prometheus hosted by AWS. But right um we're talking about getting data dog and
35:21 I was like I don't know should we just kind of point everything just use like the raw data dog SDK?
35:27 Um and then if you wanted to switch back like would it just be like a couple days of work maybe? Um but I also think it just kind of depends on like um what scale you're at?
35:36 Two things. Number one, it will not be a couple days of work if you want to switch [laughter] it back and it would I would highly recommend uh
35:46 so if we think about the the open telemetry pattern of having a sync like so the whole idea is I might want data
35:53 dog strategically maybe they offer great tools but it really would it I've I've I've been in this environment before
36:01 where we start with open source self-hosted we decide to pick a vendor um of the vendors like Data Dog does some really nice stuff. It's also very
36:10 expensive. You'll find out that it's very expensive because they want you to log everything in there. And again, it may be that it's the expense is still good value and you want to use that data
36:19 dog for that. Um, but there's other vendors now that are huge like there's a company called Corore Logix. There's a company called well actually Graphfana
36:26 Labs themselves has phenomenal tools end to end. They even have like um you know I don't know if you are using like pedag
36:33 duty or something but uh Graphfana Labs actually has a um they actually have
36:41 like a pager duty competitor and it's all in one interface right like there's the the the whole world of how observability and on call rotations and
36:50 all these other things work has shifted so much and some of the newer players do really cool things like again I I've had I've gone from data dog to Coral Logix.
37:00 I've gone from Data Dog to Grafana Labs.
37:03 Um I've even gone to self-hosted because at the scale it made more sense and we had enough team to go that way.
37:10 And I've never regretted abstracting away the observability right right platform because again you just don't know it's it's like it's cheap from an
37:19 optionality standpoint. Right. I get back to some Kim Beck ideas. It's like it doesn't it's not some abstraction nightmare. you really are just saying,
37:26 "Hey, the logging uh context goes into this thing and the you know the observability stack. You just kind of put that in there and then the business
37:33 logic just doesn't care." And we would even do this. It makes testing easier which is that like you can default to
37:41 the noop logging library, right? No logging library. I think Uber is the one who was did this a while back where they
37:49 created a framework so that you could spin up microservices cuz they had like tens of thousands of microservices.
37:54 Yeah. Yeah. Well, wait. I remember we learned about that with Will Larson, right? Or wait, no, no, who was it?
37:59 Uh, it might have been actually he he used to used to work for Will Larson worked for Stripe, not Yeah. Oh, and I think Stripe had a bunch
38:07 of microservices, too. It's Yeah. Yeah. Maybe that's it for when you do that, you basically end up having to have this sort of orthogonal coupling pattern where you have this idea that
38:15 says, "Hey, I expect you to do all these things. All of them have been abstracted away at the service layer. So just you know write the standard out and do this
38:23 thing and be have a scrapable endpoint for your metrics or whatever. Uh you just tell the teams to do that and they do it. Um and then if the DevOps team's
38:32 like oh data dog I don't want them anymore. I want to switch to Graphana. I don't have to have a conversation with 5,000 right bounded context. [laughter]
38:40 Yeah. Yeah. Right. And and you know, and that's a fair point, which is like as you get bigger and you're going to I
38:49 mean, it's very natural. You might have a team that like this is your DevOps, this is your platform engineering team, right? And they're going to be responsible for making all of those decisions. And so rather than being
38:58 like, uh, okay, everyone rip out data dog out of your services, right?
39:03 You know, um, or there's a critical vulnerability in the SDK and you have to go chase a bunch of people to get the thing in there, right? So that's
39:11 No, that's a good point. I'm I'm definitely thinking a little more like I've got startup brain these days. Um, but it's uh I've just been thinking a
39:19 lot about that idea of kind of like there's a lot of people who want to say like, oh, everything about software engineering has changed. Like the it's a it's a whole new world. You don't need
39:27 this or that. And like and we talked about that with mythical mammoth last week about like okay, how much has changed? Like I actually think there's a decent amount that's changed with from
39:35 like the software development life cycle, right? Like I think cycles have been compressed. I think there's not the
39:42 need for just as much like grunt work these days and so like that changes in terms of like how actual software is built and constructed.
39:51 I don't think that's changed like almost at all. Um yeah, I mean the the abstractions and he
39:58 kind of called it a lot in mythical man month, right? He knew that the abstractions were going to increase, right? People were complaining about compilers back in the day because like oh if you don't understand the machine
40:06 language then you can't do anything and he was like that's not true. Um the other part he was lamenting of course in
40:13 the book was ah I really wish that there was a way to like have a piece of code that was sort of could be reused by other people.
40:23 Okay. uh you know and you're like okay well the open source revolution hadn't happened yet right like we didn't have package managers version control the
40:32 Linux operating system none of that stuff had like picked up by the time he even wrote the 20th anniversary edition which completely changed how we write
40:39 software um and I think that it's kind of interesting too because these patterns we get so kind of we get
40:48 spoiled on all the great things that we just take for granted You know, u if if you actually look at like how does a build solver work,
40:57 right? It is doing some really cool computer sciency things under the hood with like understanding caching validation and hashing and integrity
41:04 checks and all these things that like if you actually wrapped your head around it, you'd be amazed amazed that we're doing things with the level of certainty
41:12 that we have. And yet um you know people are also yoloing and proven skills and like compromising
41:19 databases and you know getting exploited all the time because we haven't wrapped our head around when a cool system isn't
41:27 used in a way that's not intended to be used.
41:30 Right. Okay. Last tangent. Uh but I I had this thought the other day. Do you think that Anthropic or OpenAI are trying to develop their own programming
41:37 languages right now that are like super token efficient and optimized for the models just because like I' I've just been thinking a lot about their business
41:45 model and like obviously they're doing very well for themselves. There's no doubt about it. But like Opus 4.7 is already very very good and honestly if
41:54 Opus 4.7 never improved it'd still be a very very valuable product, right? And isn't it, it's not crazy to imagine that
42:01 in two or three years, an open-sourced model will become as good as Opus 4.7.
42:06 And so if I can get in three years from now the performance of source of Opus 4.7 for free basically, right? Like running on a Mac at your house, right?
42:17 Exactly. Right. Like why why go with anthropic? And so I I know they're they're just thinking constantly like how to get vendor lock in and and like I
42:27 don't even know if this would work, but I'm like I wonder if they would try to invent like a proprietary programming language that's like super token efficient and is like trained to the max
42:35 on their models if such a thing is even possible because obviously you have a huge disadvantage compared to like all the training data for everything in the
42:43 world. Um, but I mean talk about vendor locket, right? If you just say like you built it in our proprietary language.
42:50 I I didn't I I didn't bookmark it, but I did read in passing something on Hacker News where a group was claiming that
42:58 they're working on a large language model friendly programming language. And I saw that. Yeah, I didn't really take too much of notice,
43:07 but I do think that that domain of thinking is going to be interesting.
43:11 Actually, I think it was brain.dev. dev uh who does they do telemetry on in um eval stuff, Eval work on top of large
43:20 language models. They're a really cool company. Um full disclosure, I used to work under that CEO at a previous company he worked at um called Impira
43:28 that was acquired by Figma. And um but he he brought up something really interesting which is that they they did a bunch of internal work that large
43:36 language models do incredibly well with SQL and that if you actually can translate a question as a SQL query
43:46 that [clears throat] it actually does a much better job than like for certain types of and again I have there's like some caveats certain types of questions
43:53 that you ask the large language model it can express itself more uh accurately using SQL. than a bunch of other
44:01 programming languages because they were they were curious about this kind of question and I think my some of it has to do with like tupal calculus and some of the other like underlying principles
44:09 that that go into this um I think it's also because it requires you to structure data in a way that is SQL expressible right so I do think that
44:16 there are some constraints there but it is interesting to this this idea this inversion of saying is there a way that
44:24 we can structure data and structure code and structure things so that it's easier for prompt to come back with a useful
44:32 reply, right? Is it is it it can we do this in a way that we can maximize the odds of our success with our intended
44:40 desires? And I I don't it seems like such an obviously true way of thinking about stuff. It's the same way of like a perfect example.
44:51 My mom would tell us this story where she was just like it was raining and she wanted us she wanted me to wear my
44:58 raincoat and she did not want me to get to be obstinate because I was a very obstinate kid. And so she would say,
45:05 "Nathan, would you like to wear your red raincoat or your blue raincoat?" And I would say the red raincoat. And she's like, "Cool." And I would have I never
45:14 thought of there's no [laughter] option for not wearing a raincoat. Right. Right. Right. And so is is it manipulative?
45:20 Yes. Right. But did she get the outcome that she wanted? Also yes. Right. It's like [laughter] she didn't care which color raincoat I picked. She just wanted me to pick a
45:28 raincoat. And we did not get an argument. I went to school and I wore the rain coat like she wanted me to.
45:32 Um I think that we have to do the same thing with large language models.
45:35 [laughter]
45:38 Well, okay. that that thank you listeners for indulging me in all these tangents. I I want to get back to some of this stuff with uh subdomains. Um one
Chapter 8: Subdomains Are Discovered, Not Invented
45:47 of the really important principles Vlad mentions here is that subdomains are discovered not invented because Oh, I loved that. Yeah.
45:55 Yeah. Subdomains you're you're modeling the real world. And he has I don't remember this not his quote. It's a quote from someone else but I don't remember who said he says all models are
46:03 wrong some are useful. And that uh and I I really love the example he gave with that a map. He said it's like all maps
46:10 are models, right? And like a map is not going to be by its nature, it is not a 100% faithful reproduction of the world,
46:19 right? Um but there's lots of different kinds of maps, you know, like uh maps meant for driving, maps meant for hiking, map, you know, topographical maps. Um
46:27 and depending on what context you're in, that's the map you're going to reach for. And so uh I'm a big fan of modeling
46:35 things and I think it's very I think there is a type of engineer who gets really frustrated at an inability to
46:44 express all of the edge cases and all of the details surrounding a problem in a
46:50 model. But models are very very useful because they provide a shared language for all the members of a team including
46:59 the nontechnical members to discuss a problem. Um, I know that's uh
47:06 uh they uh and made to stick. Chip and Dan Heath talk about this idea of like sticky ideas are concrete. And one
47:15 reason that uh something being concrete is really helpful is because everyone knows what you're talking about, right?
47:22 Like there's no room for interpretation.
47:24 and uh he talks about someone who was giving a pitch I think for the Palm Pilot or it was like some sort of tablet or something and like thought the pitch was going well and so eventually he just
47:32 kind of like throws his like folder onto the table and says like you know gentleman imagined you know like it's
47:39 like his binder like imagine a device that could do this this and this that fits fits in your hand like this and but then the moment people kind of started
47:46 picking up the folder and going like oh yeah you know what like it kind of made the idea real and they were like could you fit it in this you know what what
47:54 trade-offs did he have to make? I think it was the Palm Pilot who like he carried a brick just like a or like a wooden block in his uh in his pocket and
48:02 anytime anyone would like propose a feature be like can it fit in this like this is what we have to work with here. And so um
48:10 I think models are good because they they force you to understand the problem you're working
48:17 with. And I think in creating a model, even if it's a simpler model than you might like it to be, that forces you to understand the kind of tradeoffs you're
48:25 dealing with. And I I think it's something to say like if you think that a topic is too insignificant to kind of
48:33 fit into the model uh for the problem you're discussing. Like that's a worthwhile signal into like how much time you should be investing in building out that part of the system.
48:44 Yeah. I I I [clears throat] did again I love that bounded context are designed subdomains are discovered right and that
48:51 he also argues in here that while many times a bound on context in a subdomain can be one to one they're not necessarily one to one and that a
48:59 subdomain can actually span multiple contexts right so again it's a framework for us to think about how do we divvy up
49:06 responsibility and work in these other pieces um I also loved that the uh oh, what was it? Let me see.
49:17 Boundaries are the boundaries are physical. Um, meaning that there's Oh. Oh, actually, here's what I was inside of a bounded context.
49:27 Um, the ubiquitous language is consistent and across context, the same word can mean different things. I
49:34 actually ran into this recently. So, this I think this will be a good one to to bring up. Um, I'm working with a
49:40 company that does um, uh, loan underwriting for like construction loans that transition into like building
49:48 projects, right? And it's funny because when you go and close on a house, right?
49:55 So, we call it closing on a house and it's funny because like you could close on a house where both the buyer and the seller have no mortgage involved, right?
50:06 like you actually could have a cash you I could I could have a house and and you could want to buy it from me and I we just do a cash deal. We still call it closing, right? We close on the house.
50:16 It's like all the paperwork that's gets done and things that go on and then we also have like the loan that's actually issued and the way they think of closing
50:24 is the the loan closes, right? So the loan closes at the end of whatever the term is, right? Like you've paid all of the 15 years on some loan or maybe it's
50:32 a construction loan, so it's only a couple of years long. um or maybe you go into foreclosure or there's there's all these reasons that a loan would close,
50:40 right? Um down the road. That's a very different neat term for closing than closing on like a real estate deal, right?
50:49 Yet, they will overlap. So, I could close on a house that closes out my mortgage because I've you've paid money,
50:58 you've started a new mortgage, uh the check that's written, you know, pays the balance of my mortgage and then the rest of that cash goes into my pocket. um it
51:06 becomes really confusing and this was like an argument that was happening internally of like who owns the term closing and where's the bounded context
51:15 for like we have to understand that closing means something in this part of the business in this part of the business and so it was like this it was
51:22 a perfect example we didn't have to have a universal understanding of the term closing we had to have an understanding of the term closing amongst its bounded context
51:32 right if I'm talking about the loan life cycle it has a specific meaning for closing.
51:36 If I'm talking about a real estate deal, it has a specific, you know, reason for closing. So, yeah, that's just a concrete example that came up recently.
Chapter 9: Tactical DDD and Code Examples
51:45 Well, I I want to talk, we've only got a few minutes left before we end the episode. We've talked about some of the code examples in this book. Um,
51:54 and again, it's just a very kind of like consultant enterprisey way of writing code. uh we do a lot of functional
52:01 programming at my uh at my work and so you know it's just
52:08 not my my style of things. I don't know Nathan if you want to pull up some on your end. I mean I can pull up some on my end. I mean a lot of these things
52:16 like are not crazy to me right? Like you have a person class and that person class accepts an ID and a first name and a last name and a landline phone. Like
52:25 you makes a lot of sense to me. you get to some things a little where it's like the whole idea of domain driven design,
52:32 right, is that you can model these um you could you can model everything in code and that all your code kind of maps
52:40 to realworld representations of the stuff you're working with, right? And so [snorts] you have, you know, uh value
52:48 objects, these are identities by value, immutable, they encapsulate data or behavior. Some examples are money, color, address. You have entities.
52:56 That's stuff like customers and orders.
52:58 I don't know. I get a little bit like you have here like var phone equals phone number.parse and then it's and then it's a string of
53:05 a phone number. And I'm a little like like I I see some value in that. I see some value in like
53:13 let's isolate all the phone number parsing logic to a phone number class.
53:18 And so I can be assured that when the phone number then gets attached to the customer object, it's a valid phone
53:27 number. I get it. Part of me also feels like phone numbers are strings, right?
53:32 And like I'd rather just do some validation on the string before attaching the the string phone number to a person, you know?
53:39 Yeah. And and again, these are two different schools of thought, right? Do I have this phone number object that lets me manipulate all these things? And I could ask it questions of like give me
53:48 the area code or you know like you could imagine if you're dealing with phone numbers a lot and you really care about country code versus this versus that. Um
53:57 yes, but a lot of times I think also the functional programming or you know just just having function first stuff where
54:04 you know you have a phone number validator that takes in a string and then you know lets you know if you know
54:12 basically like protects whether this um you know phone number is properly
54:19 formatted and deals with some stuff in a very flat functional way right you I don't do I actually need a phone number
54:26 class or phone number object to describe this. And I think it really comes down to what's needed. Like, you know, for instance,
54:35 if we're dealing with things like a URL, um, I actually think that a URL is really nice to have a class for that,
54:42 you know, or some sort of struct where I'm like, okay, give me URL.parameters parameters or give me URL, you know, the query, you know, is this thing in the
54:50 URL or um having it sort of this sort of object-oriented could be really nice.
54:56 But if you want to keep things simple and you're just like, you know, URL, you know, is URL valid? And then you pass in the string and then it just tells you
55:05 yes or no. Um those things, they're fine, too. I guess I um [snorts] it
55:13 really comes down to to me it comes down to like this I think this would actually come down to some of the ubiquity the
55:20 ubiquitous uh vocabulary conversations that you would have too, right? you know, is um is one of your claims to
55:28 fame is one of your core competitive advantages that you handle phone numbers better than all competitors. [laughter] And you really do, you know, like you
55:37 you can um you know, validate the accuracy and usefulness of a phone
55:44 number 17 different ways, right? Then yeah, you probably do have an object and a a bajillion ways that you can actually like slice and dice um those things. But
55:53 there this the examples in this thing definitely feels very enterprise grade code and you and I
56:02 think everyone knows if you've seen that right it's like the Java and C type coding styles where you're like wow that's a lot of boilerplate to do something that seems somewhat simple.
56:11 Yeah. Yeah. like and I remember like that XKCD comic which is like him saying like if you wrote an essay in every
56:18 language and the joke for Java is like you're six pages in and I still don't know what you're saying yet. And I remember reading that in college and co
56:27 Java was the only programming language I had ever worked with and I was like what do you mean like it's how could you be any shorter than this? And then like you start working with something like a
56:34 Python you're like oh wow. [laughter] Yeah. Um, were there any other code examples you wanted to talk about, Nathan?
56:45 We kind of, you know, you get the gist.
56:47 No, it's just again I I wouldn't, you know, you're not going to you're not coming to this book for the code. I the again it I'm not a C# programmer.
56:56 It was very easy to understand. I think maybe because we're a lot of us are writing TypeScript and the same creator of C and TypeScript is the same person.
57:05 um you know there's a lot of there's a lot of overlap and similarities but um it doesn't bring me joy. I I I do
57:14 kind of wish maybe that this was in Python, which I think is an easier sort of casual language to read, but I also
57:21 cuz just cuz I'm like, oh yeah, forget about how languages are obsessed with getters and setters and you know, all this other stuff. But again, from an
57:28 enterprise standpoint, not surprising. And I will say I was reading a lot of this book sort of adversarially being like, what would
57:37 Osterhalt think about these things? Um, and I will say that I think in the realm of strategic DDD, there's actually a lot
57:46 of good overlap with philosophy of software design. Um, where I think that this book kind of gets hung up is that, and I think this is just consulting
57:54 industry in general, the last responsible moment, the the idea of pushing things off to last responsible moment or having sort of
58:02 these tactical phases. I do think really if you have that tactical tornado type person in your organization, they really
58:10 could go completely buck wild with tactical DDD where you end up right following DDD, but you're in such a
58:19 tactical tornado that you've basically pushed off elegant deeper strategic thinking for technically implementing
58:27 what was asked, right? And I think DDD could be exploited that direction pretty easily.
Chapter 10: Final Thoughts
58:33 Well, why don't we talk about um give some of our hot takes here. Uh I I don't know. I I wrote like
58:42 maybe my code is terrible. It's possible my code is terrible. I don't think it's terrible, but like [snorts] the whole idea of like bounded context and like modeling the real world, right?
58:53 Like I don't know. This kind of comes very naturally to me. Like it it has never occurred to me that you could write code in another way, right? H I I
59:03 don't know if if everyone thinks that way, but like it's just very clear to me like of course your code just maps on to
59:10 what you're trying to model in the real world. Like in fact it seems way harder to me to code in any other way. I don't know. Tell me, am I crazy here, folks?
59:20 Um I I don't know. I I think there's two two sides to this. Number one, if you walked into an environment in which they
59:28 have a nice well-reasoned set of principles that they built things with, which I think you've had the advantage of having, right? Right.
59:35 You're you're correct. And you get a sense of aesthetics, right? There's a sense of aesthetics that you understand.
59:39 You're like, "Ah, this is what good feels like, right?" Um, I do think though, you know, it would be
59:47 interesting to revisit this in like two years. um if you're at Leland and you're like how do you feel about the decisions
59:56 you made or your understanding of the business because the other thing that'll happen is the business changes right and so all of a sudden um what a stakeholder
1:00:05 or what the requirements or how the bounded context makes sense shifts because the business itself you know they have a reorg think about something
1:00:14 new and all of a sudden your bounded context and the subdomains are not mapped up properly anymore. And I think
1:00:20 that's the other part is just like, and I've noticed this in some of these these murders and acquisitions or these other things, is like somebody did a
1:00:28 rugpull or somebody made some change to their understanding of reality and the model no longer fits. And so how do you react to that, which is a hard thing to
1:00:36 do? Um, so yeah, I think I think that's the other side of it is that even if you did a good job today, is it a good job
1:00:45 because of the external realities in Yeah. No, that's fair. And I am looking forward. I I intend to be at Leland for a while. And it's also nice at Leland
1:00:53 because I've been leading a lot more decisions that like I know George has talked about this like it's tough if you have a developer who hasn't stayed somewhere too long because
1:01:01 like what you need you need to reckon with the consequences of your decisions. Yeah.
1:01:07 Right. And I I hope to I hope to reckon with my decisions. I've already reckoned with some of them.
1:01:12 Yeah. And some of the best learning you'll ever have is that um you know I I've definitely regretted doing some of the job hopping that I did during the
1:01:20 pandemic cuz I did some of my best work at least what I thought was my best work and I didn't get to live with it two years later to see if [snorts] that
1:01:28 actually was a good idea. [laughter] Right. Right. You know.
1:01:31 Yeah. But you know they paid so much during the pandemic. That's the problem.
1:01:35 Right. I kind of look and I'm like ah should I have left this place for that place? I'm like well the next place was offering you a 50% raise. So, like,
1:01:42 yeah. Oh, I did the same thing. It was for my family, my bottom line, for me playing catch-up on my retirement accounts and things like this.
1:01:49 [laughter]
1:01:50 No regrets. No regrets. Uh, you, Nathan, and any hot takes?
1:01:54 Yeah, so I I think I kind of mentioned it a little bit. Um, yeah, I didn't push it too much, but yes, this book is very like I guess C is
1:02:04 super class heavy, but it felt like a very like classitis sort of poster help, you know, argument there, which is, you know, there's a class of a class pulling
1:02:11 in a class like there's a lot of very deep um or I should say shallow classes
1:02:19 that are being like pulled in a lot, but again, that might just be a coding style that's different than what I'm used to.
1:02:24 Uh the other hot take I had was that uh and again I kind of mentioned this earlier a little bit which is uh strategic DDD is very impressive.
1:02:34 Tactical DDD feels like it could be a complete mess. And I think that if you skip straight into the sort of like tactical modification aspects of DDD,
1:02:43 you could even probably give DDD a bad reputation if you're not careful.
1:02:48 Yeah, I I think you're right. And I've been thinking about this a lot at work, which is like There's some developers that love, you
1:02:56 know, like that kind of very tactical nature. And I I think it relates to kind of like Will Larson's like snacking, right? Where it's like, oh yeah, you just want to go in and you just want
1:03:05 to fix this thing and, you know, polish that up and whatnot. And it's a little like I think it's useful.
1:03:12 I I think it doesn't replace doing a lot of that does not replace like driving kind of key [snorts] initiatives
1:03:20 where we're seeing that with some engineers who are it's like no one is unproductive
1:03:27 but you need to be kind of I don't know you need to be driving things in a more
1:03:34 significant way. Um, right. And and for what it's worth, I think that's true with uh with AI, which is like this like
1:03:42 just here a little there a little, you know, just doing a little bit of this, a little bit of that. Like, I don't know.
1:03:46 I think it the time has come for us to be owning larger initiatives from end to end and really moving the needle in a significant way. I mean, that's why I
1:03:55 really liked uh slow productivity uh when we read it almost like a year and a half ago at this point. uh just that whole idea of
1:04:02 like pseudo productivity and like you know you can do stuff that feels like work but does it actually move the
1:04:09 needle and ever since then I've been like I got to be focusing on stuff that moves the needle um minorly related to this idea of like strategic versus
1:04:17 tactical domain driven design but I do agree that like if if you kind of just start modifying the code without like a
1:04:24 bigger picture are you really going to make it better or you just going to introduce weird pockets of domain driven design that just make the whole codebase
1:04:32 more complicated to reason about. Um, as far as what we're going to do differently because we've read this book, I would like to model our subdomains. We are a small enough team,
1:04:41 a small enough business right now that we have uh like we only have one engineering team, but like you know the hope is to
1:04:50 raise a series B in the somewhat near future. And if that happens, I mean, I think it's very possible we grow from 10 engineers, I think I think we're at 12 engineers right now, actually, to 30.
1:05:01 And and I think it would be reasonable at that point to try to split it up and say like, okay, these engineers focus on this and these engineers focus on this.
1:05:08 And even if uh even if that's still at that point like a monor repo and it doesn't make sense to go like a full microser approach, like I still think it makes sense to have like domains. And
1:05:17 I've just been thinking about that lately, like what would be our domains?
1:05:20 What would we split off? Um, and you know, I'm I I think I should just get ahead of the curve on that a bit. Oh, that's cool.
1:05:28 How about you?
1:05:29 Yeah, I'm going to double down my efforts on the ubiquitous language. Uh, we already started doing this. We've been in the process of like we've been
1:05:37 using a lot of external schema and other data stuff in this big data warehouse I'm working on. And we're working on what we're calling like a unified
1:05:44 schema. This idea of only including stuff that makes sense internally. And all of this has been led by our
1:05:52 stakeholders, you know, the domain experts that we've been working with directly. And I've learned a lot about the vocabulary, but I don't think I
1:05:59 realized how important it was that I absolutely always use the vocabulary that they use. Right. Right.
1:06:04 Um that I'm the one who is, you know, modeling their world into what we can do in deterministic, repeatable processes.
1:06:13 And um yeah, I'm going to put extra effort into that.
1:06:17 Um, as far as what we're going to or who'd recommend this book to, I'd say if you're an engineer who kind of
1:06:24 struggles to understand the business and just find yourself really absorbed in the code, this is a good book to kind of
1:06:32 get you started. Um, right.
1:06:35 And yeah, I I'm banging I've been banging this drum for a long time. Both of us have, but like this idea that you can just live purely in that in the code
1:06:43 in that accidental complexity world, it's never been a good career decision.
1:06:46 It's certainly not a good career path and it's possibly not even a career path at this point. So, um you know, if you want to understand like okay, how does
1:06:55 the business map onto the code, uh this is a good book to start with.
1:06:58 Yeah, I I completely agree. Uh I'd say this book is really super important too for senior engineer and engineering
1:07:06 leadership that maybe is struggling to figure out how to get alignment um in a more mature
1:07:14 organization. Right? So again, you've maybe been in environments where things just worked. You kind of took it for granted and you're walking into a lot of
1:07:22 dysfunction or you're realizing that domain experts don't know how to even communicate, right? These kind of this gives you a lot of tools on how to to
1:07:30 deal with that. Um, but I love your framing. I think actually you're is a really good point and maybe that's the other kind of big takeaway is um we all
1:07:39 have to think about the business and so if you don't really like the business you're working in you should probably find another type of business like if you really do want to
1:07:47 get to low-level stuff maybe your customer should be other software engineers who kernel exploits so you work for a colonel exploit software company right and then you can get in
1:07:55 the weeds all day long um I used to think with myself like oh I don't really care what I'm working on so long as the tech is interesting And I realized like that's not true. I have to
1:08:03 care. I have to be interested in what I'm building.
1:08:06 I used to say I was like, "Oh, as long as I'm solving interesting problems." And I just that's such a cope. It really is. Like you you actually have to get excited about
1:08:14 the product and who you're working with or the bad days are going to be so bad, right?
1:08:19 And that can be a lot of domains. Like I did not fantasize about building a one-on-one coaching marketplace, but I do find marketplaces inherently interesting and that makes my job a lot more interesting.
1:08:29 Well, anyhow folks, we got to sign off, but thanks for listening. We'll be back with part two next week. Uh, find us on Twitter at bookoverflow pod. Email us at bookoverflow.io.
1:08:37 Uh, I am on Twitter at Carter Morgan and Nathan has worked with his consulting agency is at functionally imperative.com. We'll see you later, folks.
1:08:49 [music]
الترجمة العربية الكاملة
البودكاست: Book Overflow — كارتر مورغان وناثان توبس
الفيديو: https://www.youtube.com/watch?v=OPUVbTTOQgI
المدة: 1:08:50
ملاحظة: ترجمة عربية كاملة للتفريغ الإنجليزي، مقطعاً مقطعاً بحسب الفصول والتوقيت. حُذفت حشوات الكلام الشفهي (مثل «أمم» و«يعني» والتكرار) مع الحفاظ على المعنى كاملاً، وصُحّحت أخطاء التعرّف الآلي على الأسماء.
المتحدثان: كارتر مورغان (مهندس في شركة Leland الناشئة) — ناثان توبس (مستشار، صاحب وكالة Functionally Imperative).
الفصل 1: المقدمة (0:00)
0:00 ناثان (مقتطف افتتاحي): كنت أقرأ كثيراً من هذا الكتاب بروح المعارِض، أسأل نفسي: ماذا كان أوسترهاوت سيقول عن هذه الأمور؟ وأستطيع القول إنه في مجال التصميم الموجّه بالمجال «الاستراتيجي» هناك في الحقيقة تقاطع جيد كبير مع كتاب «فلسفة تصميم البرمجيات».
0:21 كارتر: مرحباً، هذا «Book Overflow»، البودكاست الذي يقدّمه مهندسو برمجيات لمهندسي البرمجيات، نقرأ فيه كل أسبوع واحداً من أفضل الكتب التقنية في العالم سعياً لتحسين صنعتنا. أنا كارتر مورغان، ومعي كالعادة شريكي ناثان توبس. كيف حالك يا ناثان؟
ناثان: بأفضل حال. مرحباً بالجميع.
0:34 كارتر: انتبهت للتو أنني أقول هذه المقدمة في كل حلقة، لكننا لم نبدأ بها في الحلقات الأولى. لا أريد أن أعود وأستمع لكل حلقاتنا القديمة، لكن أتساءل متى ثبّتنا هذه الصيغة؟ سأضطر للتحقق، وسأخبركم في الحلقة القادمة [ضحك].
0:53 شكراً لانضمامكم. لا تنسوا الإعجاب والتعليق والاشتراك، وانضموا إلى الديسكورد، واحجزوا جلسات معنا على منصة Leland. كل الروابط في وصف الحلقة. نحن متحمسون هذا الأسبوع. كنا قد قلنا إننا سنقرأ هذا الكتاب، ثم أخذنا استراحة لقراءة «أسطورة الشهر-رجل» (The Mythical Man-Month)، وأنا سعيد حقاً بذلك، لأن كثيراً مما في هذا الكتاب يتكامل بشكل جميل مع «أسطورة الشهر-رجل» ومع أفكار كثيرة راودتني مؤخراً عن هندسة البرمجيات عموماً. وهذا هو كتابنا: «تعلّم التصميم الموجّه بالمجال» (Learning Domain-Driven Design) لفلاد خونونوف.
الفصل 2: عن الكتاب والمؤلف (1:23)
1:26 كارتر: أظن أن هذا هو النطق الصحيح: K-H-O-N-O-N-O-V، فيه عدة حروف O. فلاد خونونوف مهندس برمجيات بخبرة تزيد على عشرين عاماً في الصناعة، عمل خلالها في شركات كبيرة وصغيرة، وفي أدوار تتراوح من «مدير موقع» (Webmaster) إلى «كبير المعماريين». متى كانت آخر مرة سمعت فيها عن شخص يعمل «ويب ماستر»؟ هذا من الطراز القديم!
1:49 ناثان: فعلاً طراز قديم.
كارتر: ماذا نسمّي الويب ماستر اليوم؟
ناثان: كانوا أشبه بـ«أصحاب كل الصنائع»، أقرب إلى مدير الأنظمة (SysAdmin). أظن أن «مدير الأنظمة» حلّ محله كمسمّى. لكنه كان على الأرجح يفهم كيف يعمل الموقع بالكامل، وأنا متأكد أنه كان يتعامل مع مجلدات CGI وسكربتات Perl وكل تلك الأشياء الممتعة.
2:10 كارتر: نعم، لدينا هنا محارب قديم معتمد! يحافظ فلاد على حضور إعلامي نشط كمتحدث عام ومدوّن ومؤلف. يجوب العالم مستشاراً ومتحدثاً عن التصميم الموجّه بالمجال والخدمات المصغّرة (Microservices) ومعمارية البرمجيات عموماً. يساعد الشركات على فهم مجالات أعمالها، وفكّ تشابك الأنظمة القديمة (Legacy)، ومعالجة التحديات المعمارية المعقدة. يعيش في شمال إسرائيل مع زوجته وعدد «معقول تقريباً» من القطط.
2:35 عند قراءة هذه المقدمة عن المؤلف — ولم أقرأها قبل الكتاب — يتضح أن هذا كتاب آخر كتبه مستشار يتعامل كثيراً مع أنظمة قديمة في شركات بحجم «فورتشن 500» تقريباً، وهذا منطقي جداً. كنت أنا وناثان نتحدث عن هذا قبل بدء التسجيل، وسنستمر في الحديث عنه: إنه نمط مختلف نوعاً ما من البرمجيات.
أما عن الكتاب، فيقول في مقدمته: «بناء البرمجيات أصعب من أي وقت مضى. فعليك كمطوّر ألّا تلاحق فقط الاتجاهات التقنية المتغيرة باستمرار، بل أن تفهم أيضاً مجالات الأعمال التي تقف خلف البرمجيات. يقدّم لك هذا الكتاب العملي مجموعة من الأنماط والمبادئ والممارسات الأساسية لتحليل مجالات الأعمال، وفهم استراتيجية العمل، والأهم: مواءمة تصميم البرمجيات مع احتياجات العمل.»
3:19 الكتاب نحو 450 صفحة، في 16 فصلاً. قرأنا الفصول الستة الأولى، وسنجعل الكتاب ثلاثة أجزاء، فنحن الآن في ثلثه الأول تقريباً. ناثان، ما رأيك في الكتاب؟
الفصل 3: الانطباعات الأولية (3:43)
3:43 ناثان: عموماً أراه مقدمة ممتازة لـ DDD. الكتاب الشهير الذي بدأ كل شيء هو كتاب إريك إيفانز، يسمّونه «الكتاب الأزرق»، لكنه معروف بصعوبة قراءته وبأنه قديم بعض الشيء. هذا لم يخِفنا في الماضي، لكنني رأيت أنه إن أردنا الدخول إلى DDD الحقيقي بتدرّج، فهذا الكتاب يحظى بتقدير عالٍ، وهو من إصدارات O'Reilly خلال السنوات الخمس الأخيرة، فبدا لي نقطة انطلاق جيدة.
4:16 من الناحية الجمالية، إيقاعه ممتاز، ومكتوب بإحكام. أقدّر كثيراً الطريقة التي يؤطّر بها DDD العمل بلغة الأعمال ومصطلحاتها، حول مفاهيم مثل «السياقات المحدودة» (Bounded Contexts) و«اللغة الموحّدة/الشائعة» (Ubiquitous Language)، وغيرها من الأمور المهمة التي تعاني منها فرق كثيرة. وأفهم لماذا يبدأ DDD بها، ليقول: لا يمكنك أن تعيد اختراع العجلة ثم تأمل أن يفهم بقية العمل ما تحاول إيصاله؛ عليك أن تقضي وقتاً طويلاً في التأكد من إشراك أصحاب المصلحة الآخرين. وأحب هذا الجانب.
4:55 أما أي نقد لديّ، فهو أن هناك جوانب في DDD نفسه لا أحبها، وربما من نفس قبيل «التطوير الموجّه بالاختبار المدفوع بالاستشارات»، أو الدخول في عالم «الأعاصير التكتيكية» (Tactical Tornadoes). لا أظن أن الذنب ذنب DDD نفسه، لكن هناك جوانب مما يُعتبر «طبيعياً» أتوجّس منها قليلاً. إذن ليس الأمر نقداً للكتاب، بل هو: هل أصل إلى نفس الاستنتاجات الفلسفية؟ ونأمل أن نتعمق في ذلك اليوم.
5:33 كارتر: أتفق كثيراً على أنه مكتوب بشكل جيد جداً. كنا نمزح أننا تدلّلنا مؤخراً، فقد مرّت خمس أو ست حلقات متتالية كانت كتبها متاحة صوتياً، فأنجزنا جزءاً كبيراً من «القراءة» هذا العام دون أن نقرأ فعلاً، بل نستمع. هذا أول كتاب نقرؤه منذ مدة. لكنه مكتوب بجمال، وإيقاعه ممتاز، وصوت المؤلف قوي وموجز، لا يطيل. لم يمرّ بي موضع تمنّيت فيه لو توسّع أكثر، ولا العكس: «فهمت، لننتقل».
6:15 مؤلف موهوب جداً. وهو يتكامل بشكل رائع مع ما تحدثنا عنه في «أسطورة الشهر-رجل» الأسبوع الماضي. فكرت كثيراً في فكرة «التعقيد العَرَضي» مقابل «التعقيد الجوهري»: تاريخ هندسة البرمجيات كله هو تقليص للتعقيد العرضي، أي المشكلات التي نصنعها لأنفسنا. ثم هناك التعقيد الجوهري، وهو الجزء الصعب الحقيقي في صناعة البرمجيات؛ لأن كل برمجية تنمذج العالم الحقيقي بطريقة ما، واختيار كيفية نمذجة العالم الحقيقي سيكون دائماً معقداً.
6:56 أظن أن ما تفعله النماذج اللغوية الكبيرة اليوم هو التهام جزء كبير من ذلك التعقيد العرضي. وأظنها تقضم شيئاً من التعقيد الجوهري، لكن بأسلوب «البطة المطاطية» أو شريك التفكير. والثلث الأول من الكتاب كله عن فكرة نمذجة مجالات الأعمال، وأراه تمريناً مفيداً جداً لمهندس البرمجيات، لأن أيام كسب العيش من التعقيد العرضي وحده تقلّصت — وتاريخ المجال كله هو تقليص تلك الأيام. فاعتادوا على هذا النوع من التفكير، لأنني أظنه مستقبل مهنتنا.
7:45 ناثان: وأظن أن أشخاصاً مثل ويل لارسون يلحّون على هذا منذ فترة: عليك أن تجد القيمة الجوهرية للعمل. وأظن أن كبار المهندسين يجدون بالحدس التعقيد الجوهري ليصرفوا وقتهم فيه. وما نحن فيه الآن هو «وظيفة إجبار» (Forcing Function) تدفع نحو ذلك أكثر. وأقول: إن حاولت ضبط الأمور تفصيلياً فقط ستواجه مشكلات كثيرة. في هذا الكتاب جزء «تكتيكي» من DDD وجزء «استراتيجي»، والمؤلف يكرر التحذير: إن تجاوزت DDD الاستراتيجي ستقع في المشكلات. وأقول إن هذا صحيح مضاعفاً اليوم: عليك فعلاً أن تقضي وقتاً في جانب الاستراتيجية. وهذا خيط مشترك مع «أسطورة الشهر-رجل» ومع كتب ويل لارسون كلها. غريب أننا ننجذب لهذا الموضوع الذي يتصاعد؛ هذا العام كله كان عنه. أنا متحمس، لأنني أظن أن كتباً كهذه تصبح أهم كلما قلّ ما نكتبه من كود، لأننا نحتاج أن نقضي وقتاً في قسم الاستراتيجية.
الفصل 4: طريقة مختلفة لكتابة الكود (9:14)
9:14 كارتر: نعم. ومع القراءة يبدأ الكتاب بأمثلة برمجية، وكما قلت يا ناثان، هي طريقة مختلفة لكتابة الكود، طريقة تجنّبتها كما يُتجنّب الطاعون! هناك نوع من المهندسين يعمل في منظومة مايكروسوفت: C# و.NET وAzure، وكل شيء منضبط ورسمي جداً. ليس هذا أسلوبي، فلا أعمل في هذا العالم.
9:49 لم أكن يوماً مهتماً جداً بالتفاصيل الدقيقة للكود. أحب الكود الجيد السريع المقروء، لكنني كنت دائماً أكثر انشغالاً بالقرارات العليا: الأمور المعمارية، والأنماط العامة عبر قاعدة الكود، وكيف ننمذج الميزات من العالم الحقيقي. يضحك زملائي في الشركة لأنني معروف بأنني مراجع «سهل» لطلبات الدمج (PR)، لكن تكون لديّ آراء كثيرة حول نماذج البيانات، فأنا أكثر تدقيقاً فيها.
10:36 فحين تقرأ كتاباً كهذا مليئاً بـ«هكذا ينبغي أن تكتب الكود» مراراً، يتساءل جزء مني: هل لأننا في عصر الذكاء الاصطناعي صرت أقول «لماذا نهتم بهذا القدر؟» أم أنني كنت هكذا دائماً؟
10:57 ناثان: بعض هذه الأمثلة يبدو بنية كود واضحة وجيدة، وبعضها يبدو مصطنعاً قليلاً لإثبات فكرة. لكنني لا أنتقد الكتاب كثيراً على ذلك؛ فإن لم ينطبق المثال عليك أو لم يوافق أسلوبك وذوقك، فلا بأس. تنظر وتقول: «هذه طريقة، لن أفعلها هكذا». وهذا ما ينبغي أن تطوّره مع الوقت.
11:24 الكتاب ليس «طبّقها بهذه الطريقة»، بل يقول: إن رأيت صنفاً (Class) بهذه الحقول، فهذا هو التعقيد العرضي الذي قد ينتج عنه. وبغضّ النظر عن الأسلوب فهذا مفيد، أن تقول: «نعم نحن نفعل هذا»، مثلاً: ليس لدينا طريقة لنعرف هل هذا معرّف فريد لصنف المستخدم؟ وكيف يرتبط بما نخزّنه في قاعدة البيانات؟ أو أي شيء تصادفه حين تسحب شيئاً من مخزن بيانات وتتعامل معه عبر آلة حالات (State Machine).
12:07 ولا يتعمق كثيراً — على الأقل في الفصول الستة الأولى — بل يلمّح: «هذا سهل النمذجة إن كانت لديك معاملة (Transaction)، لكن سنتطرق إلى البيانات الموزعة وأنظمة البيانات الموزعة»، ويكتفي بقول: «هذا سبب تشابك الأمور». وأظن أن التعمّق متروك لكتاب مثل «تصميم التطبيقات كثيفة البيانات» (Designing Data-Intensive Applications) أو كتب أخرى قرأناها.
12:32 في حالة DDD، يركز المؤلف على: كيف أنمذج الواقع بطريقة تقلّل محاولة «غلي المحيط»، أي محاولة نمذجة كل شيء بشكل مثالي على نطاق عالمي؟ هل يمكن أن نهيكل الأمور بحيث تكون الفرق مستقلة، ونعمل مع أصحاب المصلحة، ونتكيف مع التغيرات عبر الزمن؟ كل ما نفكر فيه في «المعماريات التطورية» وغيرها يتكامل بشكل جميل.
13:09 كارتر: أنت عملت في الاستشارات أكثر وما زلت، لكنني أعلم أن كثيراً من عملك مع الشركات الناشئة.
ناثان: صحيح.
كارتر: أما أنا فكنت محظوظاً، فمعظم الأماكن التي عملت فيها كان كودها جيداً. رأيت كوداً وقلت «هذا خطأ»، وفي شركتي الحالية ورثنا كوداً فيه دوال من 700 سطر. لكن شكواي لم تكن من النمط العام للكود وكيفية نمذجته. كان منطقياً: لدينا متحكمات (Controllers) تستدعي دوال خدمات (Services)، والخدمات تفوّض عملياتها لكائنات الوصول للبيانات (DAO). النمط عالي المستوى كان منطقياً، لكن التنفيذ في التفاصيل كان متشابكاً جداً. حالة طرفية تُعالَج بشرط في السطر 400، بينما ربما كان الأفضل استعمال حقن التبعيات (Dependency Injection).
14:32 مثلاً — والتسجيل (Logging) مثال سيئ — لنقل إرسال البريد: «إن كنا في وضع التطوير فلا ترسل البريد بل سجّله فقط». وأقول: ماذا لو كان لدينا صنف «مُرسِل البريد» (EmailSender)، وعند الإنشاء نحقن إما صنف التطوير أو الصنف الحقيقي؟ المهم أنني لم أعمل في مكان كان فيه الكود «عشّ فئران» أو «كرة طين كبيرة» (Big Ball of Mud) أو كومة سباغيتي. هل رأيت ذلك؟ لأنني أشعر بنفس الشيء تجاه «الكود النظيف» لبوب مارتن: الناس يأخذونه بجدية زائدة، لكنه تحسين على الفوضى. فهل رأيت الفوضى الحقيقية؟
15:25 ناثان: نعم. لديّ عمل مباشر ثابت مع عملاء، لكنني أيضاً أعمل متعاقداً من الباطن مع شركة تقدّم خدمات Kubernetes وDevOps مُدارة بأفضل الممارسات الناضجة لمؤسسات كبيرة جداً، مؤسسات ناضجة تمرّ بجهود تحديث وتدرك أنها لا تريد إدارة Kubernetes داخلياً. ولديهم عملية «استكشاف مدفوعة»، وكان رائعاً العمل معهم لأنني أرى أين تتعثر فرق هندسية ذكية جداً، كأنها «ضحايا نجاحها». بعضها ناشئة وبعضها ذات نماذج أعمال راسخة.
16:13 ومراراً وتكراراً تواجه مشكلة «سياج تشيسترتون»: ربما حدث دوران كبير للموظفين أو تغيير في القيادة، ويعرفون أن الأمور لا ينبغي أن تكون كما هي، وأنهم بحاجة لاتجاه جديد، لكنهم لا يعرفون من أين يبدؤون، لأن هناك «كرة الطين» هذه؛ شيئاً جوهرياً يقتل سرعتهم، لا يستطيعون إجراء انتقال ما، عالقين بقرارات الماضي. وأدوات مثل DDD هي التي تساعدك على فكّ التشابك.
16:53 وهنا تأتي «مناورة كونواي العكسية» وكل ما تحدثنا عنه في «طوبولوجيا الفرق» (Team Topologies): «لديّ هذه الفوضى، أعرف أنها فوضى، ولا أريد البقاء هنا، لكنني أخاف أن أغيّر شيئاً فأكسر النظام وأجعله أسوأ، ثم أُطرد». هذا تفكير الخوف، وهو خوف معقول، لأنك فعلاً قد تجعل الأمور أسوأ، قد «تقتل المريض المحتضر». فكيف أُدخل التغييرات أو أجد طريقة جديدة للحديث مع أصحاب المصلحة؟
17:20 ولاحظت هذا أيضاً في عمليات الاندماج والاستحواذ. كنت في شركة ممولة بجولة Series C استحوذت على بضع شركات، وكان منتجها جيداً، لكن حين تنظر تحت الغطاء تدرك أن هناك قرارات معمارية وتصميمية لا تتوافق مع ما نفعله. لدينا نظام ناضج، والفجوة بين فوضاهم وما نحتاج دمجه هائلة؛ صدع ضخم. نحن نُجبر نظاماً يعمل وحده على الاندماج في نظام آخر يعمل كآلة مُزيّتة جيداً. وعندما تضعهما جنباً إلى جنب تدرك أن الأول غير مقبول: لن يواكبوا وتيرة الابتكار والنمو ما لم نعبر بهم الفجوة ويتبنّوا الأنماط الجديدة.
18:14 لذا هذه الكتب مثيرة جداً، لأنني أنظر دائماً: كيف نؤطّر الأمور؟ وكيف نقلّل ما يسمونه «نصف قطر الانفجار» للخطأ؟ هل أستطيع إدخال طريقة تفكير جديدة تعطينا «تأثير دولاب الموازنة» (Flywheel)؟ فجأة فريق التسويق — الذي لديه صفحات هبوط ومحبط لأن أي تغيير صغير سخيف يستغرق ستة أشهر — هل يمكن أن نغيّر طريقة تواصلنا معهم ونضبط التوقعات بحيث نكون على الأقل صادقين في المدة، وربما نصلح الأمور مبكراً لنكرّر نسخاً غير مكتملة بسرعة؟ كل ما نتحدث عنه من التكرار السريع. وهذا صعب: فكّ تشابك شيء ثم جعله قابلاً للاستخدام أصعب بكثير من البدء من الصفر بصفحة نظيفة.
19:08 كارتر: نعم. وأظن أيضاً أن مع DDD هناك شيء من أنه «انتصر»، فصار مثل «السمكة لا تعرف أنها في الماء». خاصة إن عملت في شركات FAANG أو شركات وادي السيليكون، فمن الطبيعي جداً أن يكون لديك فريق للمستخدمين وفريق للمدفوعات وفريق للشحن وفريق للطلبات. لكننا نعلم أن الأمر لم يكن هكذا دائماً؛ كان: «هذا فريق قاعدة البيانات، وهذا فريق Ruby الخلفي». فالخدمات المصغّرة في الحقيقة ناتجة عن التصميم الموجّه بالمجال وفكرة أنك ينبغي أن تنمذج كل شيء بناءً على مجالات الأعمال. وربما يستحق أن نذكر بعض مبادئ التصميم الموجّه بالمجال.
الفصل 5: اللغة الموحّدة والسياقات المحدودة (20:14)
20:19 ناثان: صنعت تبويباً سمّيته «كتيّب DDD التمهيدي»، وأظن من الجيد إعطاء سياق قبل الدخول في تفاصيل الكتاب. من أهم ما يجب أخذه — وقد ذكرناه قليلاً — أن هناك تصميماً تكتيكياً وتصميماً استراتيجياً، وسنتوسع فيهما. ثم هناك ما يسمّونه «اللغة الموحّدة» (Ubiquitous Language)، وأحبها كثيراً، وهي ترجع إلى كتاب إيفانز الذي بدأ كل شيء. تقول ببساطة: إن كان العمل يسمّي كياناً ما — لنقل شركة تأمين تسمّيه «مطالبة» (Claim) — فالصنف الذي يغطي هذا الشيء يجب أن يُسمّى Claim. لا تخترع كلمات جديدة؛ ستستخدم اللغة نفسها التي يستخدمها العمل.
21:02 ومسؤوليتنا أن نلغي أي طبقة ترجمة؛ يجب أن نتحدث بمفردات العمل حتى يتمكن خبراء المجال الذين نعتمد عليهم من التفاعل معنا بسهولة. التوثيق يجب أن يكون بها، وكل شيء يجب أن يخدمها. إنه مبدأ جوهري مهم جداً.
21:28 ثم «التصميم الموجّه بالنموذج» (Model-Driven Design): علينا أن نبني نموذجاً للعالم، أن نفهم كيف تعمل عملية تجارية، وأن يكون لدينا نموذج يصنّفها. ونقطتهم كلها: إن حاولت فعل ذلك على مستوى عالمي شامل فستحصل على فوضى هائلة؛ صعب جداً، أشخاص كثيرون وأصحاب مصلحة كثيرون. لذلك تحتاج ما يسمى «السياق المحدود» (Bounded Context). وهذا أمر نتحدث عنه في العميل الكبير الذي أعمل معه الآن؛ نحن مهووسون بالسياقات المحدودة، نتحدث عنها طوال الوقت. هل تستخدم هذا المصطلح؟
22:07 كارتر: لا نستخدمه كثيراً، لكن حين قرأت عنه قلت: هذا منطقي.
22:12 ناثان: السياق المحدود هو بالضبط ما كنت تتحدث عنه. الفريق يملك سياقاً محدوداً، ويمكن أن يملك الفريق عدة سياقات محدودة — عدة تطبيقات أو خدمات — لكن السياق المحدود الواحد يجب ألا يملكه عدة فرق. فلو فكرنا في الخدمات المصغّرة — خدمة المستخدمين وخدمة المصادقة مثلاً — يمكن لفريق واحد أن يملك الاثنتين، لا بأس. لكن ما لا تريده هو أن يملك فريق ضمان الجودة وفريق المصادقة وفريق المستخدمين جوانب من خدمة المستخدمين نفسها. هنا تصبح الأمور فوضوية جداً وتتحول إلى كرة طين كبيرة.
23:00 وهم واضحون جداً أن السياق المحدود نموذج مكتفٍ بذاته، يمكنك العمل فيه باستقلالية، مع أنك يجب أن تفهم النظام الأكبر بالطبع. والسياقات المحدودة يجب أن تعطينا «خريطة سياقات» (Context Map)، وهي وثيقة تخبرنا من يستهلك ماذا ومن أين، ومن يملك ماذا، فتفهم جزءاً صغيراً من النظام بكامله.
23:34 إن كنت في فريق خدمة المستخدمين، فهذا سياقي المحدود. من المرجّح أن أحتاج طلبات المستخدم، لكنني أتعامل مع الطلبات كمستهلك خالص، ولا أحتاج أن أعرف تفاصيل معالجة الطلبات أو حساب الدفع.
23:59 كارتر: يعني إن استطعت أن تكون معزولاً بالتجريد عن تعقيد جزء آخر من العمل، فهذا اختبار جيد لما هو السياق المحدود.
24:13 ناثان: بالضبط. وأنا ألعب لعبة دائماً من جانب هندسة المنصات وDevOps: يجب أن تستطيع أخذ كل سياقاتك المحدودة وإنشاء «رسم بياني موجّه غير دوري» (DAG) لنشرها. فمجموعة جيدة من السياقات المحدودة بتجريدات جيدة لها على الأرجح بنية هرمية. لنقل إننا نتحدث عن Terraform: قد يكون لديّ نشر أساسي يُقلع النظام نفسه، لكن كل خدمة يجب أن تعمل باستقلالية. وإن لم تكن كذلك، فأحتاج رسماً موجّهاً غير دوري يقول: «الخدمة A إن غيّرت شيئاً فإن B وC بعدها يجب أن تتغيرا». وما لا نريده: «إن تغيرت A فأخبر B، وإن تغيرت B فأخبر A». هذه مشكلة.
25:05 والمثالي أن لا تكون بين سياقاتي المحدودة بنية هرمية للخدمات أصلاً، بل أن تكون «متوازية بشكل محرج» (Embarrassingly Parallel)، بطريقة مسطحة تنتشر. ثم إن السياق المحدود لا يجب أن يكون خدمة: قد يكون مكتبة مشتركة، أو أي شيء تحافظ فيه مجموعة على جزء من الواقع وتفهم ما يحتاجه العمل. فتبني سياقاً لشبكة البيانات (Data Mesh)، وسياقات لتطبيقات الويب، وغيرها. ولهذا أرى DDD مفيداً جداً: لأنه أعطى الناس مجموعة مفردات قوية لإجراء هذه المحادثات المعقدة.
26:00 كارتر: إذن هذا هو كتيّبك التمهيدي عن التصميم الموجّه بالمجال.
الفصل 6: المجالات الفرعية الأساسية والداعمة والعامة (26:08)
26:07 كارتر: ما أعجبني حين يتحدث عن السياقات المحدودة: على أي شيء يُسقَط السياق المحدود؟ يُسقَط على «مجال عمل»، ويقول إن هناك ثلاثة أنواع من المجالات (الفرعية): الأساسي (Core)، والداعم (Supporting)، والعام (Generic).
الأساسي: هذه ميزتك التنافسية، ويجب أن تبنيها داخلياً. إن كنت في شركة تقنية، فهذا ببساطة ما يجلب لك المال. فكّر في أوبر مثلاً: بعض مجالاتها الأساسية خوارزميات التوجيه التي تطابق السائقين مع الركاب. وفي أمازون: شبكة التنفيذ والتوصيل (Fulfillment).
26:55 ثم الداعم: ضروري لكنه غير مميِّز. ودعني أتحدث عن العام أولاً: هذه مشكلات محلولة، مثل: لا تبنِ بنيتك السحابية بنفسك، استخدم Stripe للمدفوعات. هذه يمكن إسنادها للخارج تماماً. أما الداعم، فأحاول التفكير في أمثلة جيدة له. ربما التسويق؟ قد تريد بناء أدوات داخلية لتسهيل التسويق. هذا مثير للاهتمام، دعني أفكر...
27:46 ناثان: أظل أذكر فكرة «خريطة واردلي» (Wardley Map) لأن فيها جانب النضج. انتقدونا في التعليقات إن أخطأنا، لأنني لم أفكر كثيراً في «الداعم»، لكنني أظنه «الغراء» الذي يجمع الأشياء. مثال ممتاز: تحتاج طبقة مراقبة (Observability)، ولم تذهب إلى الحل «العام» بالكامل — أي اختيار Grafana Cloud أو Datadog جاهزاً دون أن تهتم به أصلاً — بل قررت استضافة نسخة Grafana مفتوحة المصدر بنفسك. هذا عمل نقوم به؛ قررنا تحمّل موثوقيتها، وتحمّل قواعد البيانات التي تدعمها وخطوط الإدخال وغيرها. ليس من صميم العمل، لكنه مهم جداً، ونتخذ فيه قرارات معمارية كثيرة.
28:53 ليس ميزتك التنافسية ولا عاملاً مميِّزاً، لكنه يساعد في سير الأمور، وتنتهي إلى كتابة كود مخصص — مع OpenTelemetry مثلاً — أي تفعل أشياء مخصصة. ليس «أساسياً» تنافسياً، وربما ليس مناسباً أيضاً أن يكون «عاماً» بالكامل؛ قد تحتاج تخصيصاً.
29:24 وأظن أن خطوط DevOps، أو الاستضافة الداخلية، كأن تنشئ مرآة لمكتبات Python، أي قررت تحمّل عبء مستودع الحزم الخاص بك، هذا ليس أساسياً؛ لن يشتري أي زبون قطعة من مصنعك لأنك تستضيف مكتبات Python بنفسك. ومع ذلك فأنت على الأرجح لا تستخدم شيئاً عاماً جاهزاً بالكامل — ربما JFrog — لكنك تشغّل شيئاً مخصّصاً. هذه البنية «الداعمة».
الفصل 7: المراقبة والارتهان للمزوّد (30:06)
30:06 كارتر: هذا متصل قليلاً فقط، لكنه يشغلني. قرأنا «إتقان OpenTelemetry» لستيف فلاندرز، وكان يكرر أنك تريد استخدام OpenTelemetry العام مفتوح المصدر، ولا تريد أن تقيّد نفسك بـ SDK الخاص بـ Datadog. هل ترى أن هذا مهم بنفس القدر في عالم النماذج اللغوية؟ ألا يمكنك ببساطة توجيه Claude Opus 4.7 وتقول: «سننتقل من Datadog إلى Sentry، غيّر كل شيء»؟
30:38 ناثان: أقبل بذلك إن وُجدت أنماط معينة، وأحدها — وهو مثير للجدل حسب أسلوبك — أنني من محبي نمط «عكس التحكم» أو «حقن التبعيات». لا بأس أن تستورد Datadog SDK إن غلّفته في حاوية تسجيل أو قياس عن بُعد تتيح لك «التبديل الساخن». هذا يفعل أمرين: يُضعف Datadog قليلاً، فلن تمدّ يدك إلى خصائص Datadog في منطق العمل. لكنه يسمح لك بأن «تحبو ثم تمشي ثم تجري»؛ ربما نحتاج خصائص Datadog السحرية وقت التشغيل، لكنها يجب أن تكون مغلّفة داخل حاوية المراقبة الخاصة بك.
31:25 وسيسهّل هذا التبديل كثيراً، لأن Datadog لن تدوم للأبد. قد تتوقف عن الوجود كشركة، أو لا تعود جيدة، أو ربما تبقى رائعة عشرين عاماً، لا أدري. لكن إن كنت أصمم النظام، فلن أراهن بالمزرعة كلها على مزوّد طرف ثالث.
31:53 في الواقع كنت أعيد هيكلة (Refactor) شيء هذا الصباح في موقعي الشخصي الذي أجري عليه تجارب، اسمه funk.lol. كنت أحاول كتابة اختبارات شاملة (End-to-End)، وكان صعباً محاكاة (Mock) تخزين الكائنات لأنني أستخدم Vercel Blob Storage. فصنعت دالة تغليف صغيرة في lib/blob، تسمح لي بأن تستخدم الاختبارات نقطة نهاية مستضافة ذاتياً تُزيّف تخزين الكائنات. والجميل أنها انتزعت كثيراً من تبعيات Vercel Blob من منطق العمل. صارت لديّ مكتبة داخلية أستطيع تبديلها بين الاختبار والإنتاج، وهي غلاف صغير جداً للإنتاج.
32:42 وهذا بالضبط المقصود: إن قررت لاحقاً ترك Vercel واستخدام تخزين آخر، فالأمر أسهل كثيراً؛ مجلد صغير واحد أبدّل فيه التخزين، ولا يتأثر أي شيء يعتمد عليه طالما لم أكسر واجهة lib/blob. إذن الإجابة «نعم، و...»: يُفضّل أن تستخدم مكتبة OpenTelemetry العامة، ويمكنك استخدام Datadog إن كان لديك عكس تحكم جيد.
33:28 كارتر: نعم، أفهم ذلك. أفكر فيه كثيراً لأن مستمعينا المنتظمين يعرفون الترحيل المستمر في شركتي، ويسعدني أن أقول إننا أنجزنا 93٪ منه، على الأقل من حيث عدد صفحات الموقع التي كانت تتصل بالنظام القديم؛ 93٪ منها لم تعد تتصل به، وهناك أمور أخرى نحتاج إنهاءها. ولأنها مشكلة «محدودة» لكل صفحة: أحتاج أن تعيد إنتاج الكود القديم بلغة جديدة ونمط جديد، وأعرف أنه يعمل لأنني أعرف أن كل وظائف الصفحة تعمل. لم أكن أراجع عمل Claude بصرامة شديدة، وجزء من ذلك تقدير شخصي: هل أفهم كل هذا الكود بالضبط؟ لا. وهل كنت أفهم كل الكود القديم بلغة Java؟ قطعاً لا! بل أفهم الجديد أفضل. كلها مقايضات؛ كان يمكننا التحرك أبطأ، لكننا سنكون أبطأ. أما في أي شيء جديد كلياً فأنا أشرف على Claude أكثر بكثير. لأن Claude يعمل جيداً جداً؛ لم يعد يكتب كوداً لا يُترجَم.
34:49 ناثان: وأنتم تستخدمون TypeScript؟
كارتر: نعم TypeScript. لذا لديّ ثقة أكبر، واستثمرنا وقتاً كبيراً في «المهارات» (Skills) وملفات AGENTS.md جيدة. فكنت أقول: نحن نتحدث الآن عن الانتقال إلى Datadog — حالياً نستخدم Grafana وPrometheus المستضافين على AWS — وتساءلت: هل نستخدم Datadog SDK الخام مباشرة؟ وإن أردنا العودة، هل يكون الأمر يومين من العمل ربما؟ لكنني أظنه يعتمد على الحجم.
35:36 ناثان: أمران. أولاً: لن يكون يومين من العمل إن أردت العودة [ضحك]. وأنصح بشدة بنمط OpenTelemetry بوجود «مَصبّ» (Sink): الفكرة أنني قد أريد Datadog استراتيجياً لأنهم يقدمون أدوات رائعة. وقد كنت في هذه البيئة من قبل: نبدأ بالمفتوح المصدر المستضاف ذاتياً، ثم نقرر اختيار مزوّد. Datadog يقدم أشياء رائعة لكنه مكلف جداً، وستكتشف ذلك لأنهم يريدونك أن تسجّل كل شيء عندهم. وقد تكون التكلفة قيمة جيدة رغم ذلك. لكن هناك مزوّدون ضخام الآن مثل Coralogix، وGrafana Labs نفسها لديها أدوات استثنائية من البداية للنهاية، حتى منافس لـ PagerDuty، كله في واجهة واحدة. عالم المراقبة ونوبات المناوبة تغيّر كثيراً، وبعض اللاعبين الجدد يفعلون أشياء رائعة.
36:50 انتقلت من Datadog إلى Coralogix، ومن Datadog إلى Grafana Labs، بل انتقلت إلى الاستضافة الذاتية لأنها كانت أنسب على ذلك الحجم وكان لدينا فريق كافٍ. ولم أندم قط على تجريد منصة المراقبة، لأنك ببساطة لا تعرف، وهو رخيص من حيث «الاختيارية» (Optionality). وأعود إلى أفكار كِنت بِك: ليس كابوس تجريدات، بل تقول ببساطة: «سياق التسجيل يذهب إلى هذا الشيء، ومنظومة المراقبة توضع هنا، ومنطق العمل لا يهتم». ويجعل الاختبار أسهل: يمكنك افتراضياً استخدام مكتبة تسجيل «لا تفعل شيئاً» (No-op).
37:41 أظن أن أوبر هي من فعلت هذا قبل فترة، أنشأت إطار عمل لتشغيل خدمات مصغّرة لأن لديها عشرات الآلاف منها.
كارتر: ألم نتعلم ذلك مع ويل لارسون؟
ناثان: ربما، فقد كان يعمل في Stripe، وأظن أن Stripe لديها خدمات مصغّرة كثيرة أيضاً. حين تفعل ذلك تحتاج نمط «اقتران متعامد» (Orthogonal Coupling): «أتوقع منك أن تفعل كل هذه الأمور، وكلها مجرّدة في طبقة الخدمة؛ فقط اكتب إلى المخرج القياسي، ووفّر نقطة نهاية للمقاييس قابلة للجمع». تخبر الفرق بذلك فتفعله، ثم إن قال فريق DevOps: «لا أريد Datadog بعد الآن، سأنتقل إلى Grafana»، فلن أحتاج لإجراء محادثة مع 5000 سياق محدود [ضحك].
38:40 كارتر: نعم، هذه نقطة عادلة. كلما كبرت، من الطبيعي أن يكون لديك فريق DevOps أو هندسة منصات مسؤول عن هذه القرارات، بدلاً من أن تقول: «فليقتلع الجميع Datadog من خدماتهم»، أو تظهر ثغرة حرجة في الـ SDK فتطارد الناس لتحديثها. نقطة جيدة. أنا أفكر بعقلية الشركات الناشئة هذه الأيام.
39:11 وأفكر كثيراً في أن هناك من يريد القول إن كل شيء في هندسة البرمجيات تغيّر، عالم جديد كلياً، لا تحتاج هذا ولا ذاك. تحدثنا عن ذلك مع «أسطورة الشهر-رجل»: كم تغيّر فعلاً؟ أظن أن قدراً لا بأس به تغيّر في دورة حياة تطوير البرمجيات؛ الدورات انضغطت، ولم تعد هناك حاجة لنفس القدر من العمل الروتيني الشاق. لكن كيف تُبنى البرمجيات وتُشيَّد فعلاً؟ لا أظن أن ذلك تغيّر تقريباً.
39:51 ناثان: نعم، والتجريدات... بروكس توقّع ذلك في «أسطورة الشهر-رجل»: عرف أن التجريدات ستزداد. كان الناس يشتكون من المترجمات (Compilers) قديماً: «إن لم تفهم لغة الآلة فلن تستطيع فعل شيء»، وقال إن ذلك غير صحيح. والجزء الآخر الذي كان يتحسّر عليه: «ليت هناك طريقة لجعل قطعة كود قابلة لإعادة الاستخدام من آخرين». وثورة المصادر المفتوحة لم تكن قد حدثت: لم تكن هناك مديرات حزم، ولا أنظمة تحكم بالإصدارات، ولا لينكس — لم ينتشر شيء من ذلك حتى حين كتب طبعة الذكرى العشرين — وهو ما غيّر كلياً طريقة كتابتنا للبرمجيات.
40:39 ومن المثير أننا نتدلّل بكل هذه الأشياء العظيمة التي نعتبرها مسلّمات. لو نظرت كيف يعمل «حلّال البناء» (Build Solver)، فهو يفعل أشياء علوم حاسوب رائعة تحت الغطاء: التخزين المؤقت والتحقق والتجزئة (Hashing) وفحوص السلامة، ولو استوعبتها لاندهشت من درجة اليقين التي نعمل بها. ومع ذلك يتهوّر الناس ويثبّتون مهارات غير موثوقة، ويُخترقون، وتُكشف قواعد بياناتهم طوال الوقت، لأننا لم نستوعب ما يحدث حين يُستخدم نظام رائع بطريقة لم يُصمَّم لها.
41:30 كارتر: حسناً، استطراد أخير. خطرت لي فكرة قبل أيام: هل تظن أن Anthropic أو OpenAI تحاولان الآن تطوير لغات برمجة خاصة بهما، فائقة الكفاءة في الرموز (Tokens) ومُحسّنة للنماذج؟ لأنني أفكر في نموذج عملهما. من الواضح أنهما تبليان بلاءً حسناً، لكن Opus 4.7 جيد جداً بالفعل، وحتى لو لم يتحسن أبداً لبقي منتجاً قيّماً جداً. وليس جنوناً أن نتخيل أنه خلال سنتين أو ثلاث سيصبح نموذج مفتوح المصدر بجودة Opus 4.7. فإن أمكنني بعد ثلاث سنوات الحصول على أداء Opus 4.7 مجاناً تقريباً، يعمل على جهاز Mac في منزلي، فلماذا أختار Anthropic؟
42:17 لذا أعرف أنهم يفكرون باستمرار في كيفية تحقيق الارتهان للمزوّد. ولا أعرف إن كان هذا سينجح، لكنني أتساءل إن كانوا سيحاولون اختراع لغة برمجة احتكارية فائقة الكفاءة في الرموز ومدرّبة إلى أقصى حد على نماذجهم — إن كان ذلك ممكناً أصلاً، فلديك عيب ضخم مقارنة بكل بيانات التدريب الموجودة في العالم لكل شيء آخر. لكن تحدّث عن الارتهان للمزوّد! إن قلت: «بنيته بلغتنا الاحتكارية».
42:50 ناثان: لم أحفظ الرابط، لكنني قرأت عابراً شيئاً على Hacker News عن مجموعة تدّعي أنها تعمل على لغة برمجة صديقة للنماذج اللغوية الكبيرة.
كارتر: رأيت ذلك، ولم ألتفت إليه كثيراً.
ناثان: لكنني أظن أن هذا المجال من التفكير سيكون مثيراً. أظنها شركة Braintrust (braintrust.dev) التي تعمل على القياس والتقييم (Evals) فوق النماذج اللغوية الكبيرة، وهي شركة رائعة — للأمانة، عملت تحت إدارة مديرها التنفيذي في شركة سابقة اسمها Impira استحوذت عليها Figma. طرح أمراً مثيراً: أجروا عملاً داخلياً وجدوا فيه أن النماذج اللغوية الكبيرة تتعامل بشكل ممتاز مع SQL، وأنك إن استطعت ترجمة سؤال إلى استعلام SQL فإنها تؤدي أفضل بكثير — مع تحفظات، لأنواع معينة من الأسئلة — يمكنها التعبير بدقة أكبر باستخدام SQL من لغات برمجة أخرى كثيرة.
44:01 كانوا فضوليين حول هذا السؤال، وأظن أن جزءاً منه يتعلق بـ«حساب الصفوف» (Tuple Calculus) والمبادئ الأساسية الأخرى، وأيضاً لأنه يتطلب هيكلة البيانات بطريقة يمكن التعبير عنها بـ SQL، فهناك قيود. لكن من المثير هذا «القلب»: هل هناك طريقة نهيكل بها البيانات والكود والأشياء بحيث يكون أسهل على الطلب (Prompt) أن يعود بإجابة مفيدة؟ هل يمكن أن نفعل ذلك بطريقة تعظّم فرص نجاحنا في تحقيق ما نريد؟ يبدو هذا طريقة تفكير صحيحة بشكل واضح.
44:40 مثال ممتاز: كانت أمي تروي لنا هذه القصة. كانت تمطر، وأرادت أن أرتدي معطف المطر، ولم تُرد أن أعاند لأنني كنت طفلاً عنيداً جداً. فكانت تقول: «ناثان، هل تريد أن ترتدي المعطف الأحمر أم الأزرق؟» فأقول: الأحمر. فتقول: «رائع». ولم يخطر لي قط أنه لا يوجد خيار لعدم ارتداء المعطف [ضحك]. هل هذا تلاعب؟ نعم. لكن هل حصلت على النتيجة التي أرادتها؟ نعم أيضاً. لم يهمّها لون المعطف، أرادت فقط أن أختار معطفاً، ولم يحدث جدال، وذهبت إلى المدرسة مرتدياً المعطف كما أرادت. وأظن أن علينا فعل الشيء نفسه مع النماذج اللغوية الكبيرة [ضحك].
45:38 كارتر: حسناً، شكراً للمستمعين على تحمّل كل هذه الاستطرادات. أريد العودة إلى موضوع المجالات الفرعية.
الفصل 8: المجالات الفرعية تُكتشَف ولا تُخترَع (45:43)
45:47 كارتر: من المبادئ المهمة جداً التي يذكرها فلاد أن «المجالات الفرعية تُكتشَف ولا تُخترَع».
ناثان: أحببت هذه! نعم.
كارتر: أنت تنمذج العالم الحقيقي. ويذكر اقتباساً — ليس له، لا أذكر قائله — «كل النماذج خاطئة، وبعضها مفيد». وأحببت جداً مثال الخريطة: كل الخرائط نماذج، والخريطة بطبيعتها ليست نسخة أمينة 100٪ من العالم. لكن هناك أنواعاً كثيرة من الخرائط: خرائط للقيادة، وخرائط للمشي الجبلي، وخرائط طبوغرافية، وحسب السياق الذي أنت فيه تختار الخريطة المناسبة.
46:27 أنا من محبي النمذجة، وأظن أن هناك نوعاً من المهندسين يُحبَط جداً من عدم القدرة على التعبير عن كل الحالات الطرفية وكل التفاصيل المحيطة بمشكلة ما في نموذج. لكن النماذج مفيدة جداً جداً، لأنها توفر لغة مشتركة لكل أعضاء الفريق — بمن فيهم غير التقنيين — لمناقشة المشكلة.
47:06 في كتاب «Made to Stick» يتحدث تشيب ودان هيث عن أن الأفكار «اللاصقة» ملموسة. ومن أسباب فائدة الملموسية أن الجميع يعرف ما تتحدث عنه؛ لا مجال للتأويل. ويتحدثان عن شخص كان يقدّم عرضاً — أظنه لجهاز Palm Pilot أو جهاز لوحي — وظنّ أن العرض يسير جيداً، فرمى ملفه على الطاولة وقال: «أيها السادة، تخيلوا جهازاً يفعل كذا وكذا ويتسع في يدك هكذا». ولحظة بدأ الناس يمسكون الملف ويقولون «نعم!» صارت الفكرة حقيقية، وبدؤوا يسألون: «هل يمكنك أن تضع هذا فيه؟ ما المقايضات؟» وأظن أن مخترع Palm Pilot كان يحمل قطعة خشب في جيبه، وكلما اقترح أحد ميزة يقول: «هل تتسع في هذا؟ هذا ما لدينا لنعمل به».
48:10 أظن أن النماذج جيدة لأنها تجبرك على فهم المشكلة التي تعمل عليها. وفي إنشاء نموذج — حتى لو كان أبسط مما تتمنى — تُجبَر على فهم المقايضات التي تتعامل معها. وأقول: إن رأيت أن موضوعاً ما غير مهم بما يكفي ليدخل في نموذج المشكلة التي تناقشها، فتلك إشارة قيّمة إلى مقدار الوقت الذي ينبغي أن تستثمره في بناء ذلك الجزء من النظام.
48:44 ناثان: نعم، وأحببت أيضاً أن «السياقات المحدودة تُصمَّم» و«المجالات الفرعية تُكتشَف». ويرى أيضاً أنه بينما يكون السياق المحدود والمجال الفرعي كثيراً متطابقين واحداً لواحد، فهما ليسا بالضرورة كذلك؛ قد يمتد مجال فرعي عبر عدة سياقات. إذن هو إطار لنفكر في كيفية تقسيم المسؤوليات والعمل.
49:06 وأحببت أيضاً... دعني أرى... الحدود «مادية»... آه، هذا ما أردته: داخل السياق المحدود تكون اللغة الموحّدة متسقة، وعبر السياقات قد تعني الكلمة نفسها أشياء مختلفة. صادفت هذا مؤخراً وأظنه مثالاً جيداً.
49:34 أعمل مع شركة تقوم بتقييم واكتتاب قروض البناء التي تتحول إلى مشاريع بناء. والطريف أنه حين تذهب لإتمام شراء منزل، نسمّي ذلك «الإغلاق» (Closing). ويمكنك «إغلاق» صفقة منزل لا يوجد فيها رهن عقاري لا عند البائع ولا المشتري؛ صفقة نقدية، ومع ذلك نسمّيها «إغلاقاً» — كل الأوراق والإجراءات. ثم هناك القرض الذي يُصدَر فعلاً، وطريقتهم في التفكير في «الإغلاق» أن القرض «يُغلق»: أي في نهاية مدته، دفعت كل الخمس عشرة سنة، أو قرض بناء لسنتين فقط، أو دخلت في حجز الرهن، أو أي سبب لإغلاق القرض لاحقاً. هذا معنى مختلف تماماً لكلمة «الإغلاق» عن إغلاق صفقة عقارية.
50:49 ومع ذلك يتداخلان: قد أُغلق صفقة بيع منزل فيُغلق رهني العقاري، لأنك دفعت المال وبدأت رهناً جديداً، والشيك المكتوب يسدد رصيد رهني والباقي يذهب إلى جيبي. يصبح الأمر محيّراً جداً، وكان هذا جدالاً داخلياً: من يملك مصطلح «الإغلاق»؟ وأين السياق المحدود له؟ كان علينا أن نفهم أن «الإغلاق» يعني شيئاً في هذا الجزء من العمل وشيئاً آخر في ذلك الجزء. كان مثالاً مثالياً: لم نكن بحاجة إلى فهم عالمي موحّد لمصطلح «الإغلاق»، بل إلى فهمه داخل كل سياق محدود. إن كنت أتحدث عن دورة حياة القرض فله معنى محدد، وإن كنت أتحدث عن صفقة عقارية فله معنى محدد آخر. هذا مثال ملموس صادفته مؤخراً.
الفصل 9: DDD التكتيكي وأمثلة الكود (51:45)
51:45 كارتر: بقيت لنا دقائق قليلة قبل نهاية الحلقة. تحدثنا عن بعض أمثلة الكود في الكتاب، ومرة أخرى هي طريقة «مؤسسية استشارية» جداً في كتابة الكود. نحن نستخدم البرمجة الوظيفية (Functional Programming) كثيراً في عملي، فهي ليست أسلوبي. ناثان، هل تريد استعراض بعضها؟
52:08 ناثان: كثير منها ليس غريباً عليّ. لديك صنف Person يقبل معرّفاً واسماً أول واسم عائلة وهاتفاً أرضياً؛ هذا منطقي جداً. وتصل إلى أشياء... فكرة التصميم الموجّه بالمجال كلها أنك تستطيع نمذجة كل شيء في الكود، وأن كل كودك يُسقَط على تمثيلات من العالم الحقيقي للأشياء التي تعمل عليها. فلديك «كائنات القيمة» (Value Objects): هويتها بقيمتها، غير قابلة للتغيير (Immutable)، تغلّف بيانات أو سلوكاً، ومن أمثلتها: المال، اللون، العنوان. ولديك «الكيانات» (Entities): مثل العملاء والطلبات.
52:58 كارتر: لا أدري، أنزعج قليلاً حين أرى هنا مثلاً var phone = PhoneNumber.Parse("...") ثم نص رقم الهاتف. أرى فيه بعض القيمة: لنعزل كل منطق تحليل رقم الهاتف في صنف PhoneNumber، فأتأكد أنه حين يُربط رقم الهاتف بكائن العميل يكون رقماً صالحاً. أفهم ذلك. لكن جزءاً مني يشعر أن أرقام الهواتف مجرد نصوص، وأفضّل أن أتحقق من النص قبل ربطه بالشخص.
53:39 ناثان: نعم، وهاتان مدرستان فكريتان مختلفتان: هل لديّ كائن رقم هاتف يتيح لي التعامل مع كل هذه الأمور، وأسأله: «أعطني رمز المنطقة»؟ تخيّل لو كنت تتعامل مع أرقام الهواتف كثيراً وتهتم برمز الدولة وغيره. نعم. لكن كثيراً ما يكون البديل البرمجة الوظيفية، أو «الدالة أولاً»: مُدقِّق رقم هاتف يأخذ نصاً ويخبرك إن كان منسقاً بشكل صحيح، ويتعامل مع الأمور بطريقة وظيفية مسطّحة. فهل أحتاج فعلاً صنفاً أو كائناً لرقم الهاتف؟
54:26 أظن أن الأمر يعود إلى الحاجة. مثلاً مع شيء كالـ URL، أرى أنه من الجميل جداً أن يكون له صنف أو بنية (Struct) أقول لها: «أعطني url.parameters» أو «أعطني الاستعلام»، أو «هل هذا الشيء موجود في الرابط؟»؛ الأسلوب الكائني هنا قد يكون لطيفاً جداً. لكن إن أردت البساطة، فيكفي isUrlValid(string) تعطيك نعم أو لا، وهذا مقبول أيضاً.
55:13 أظن أن الأمر يرجع إلى محادثات «اللغة الموحّدة» أيضاً: هل من مزاياك التنافسية الأساسية أنك تتعامل مع أرقام الهواتف أفضل من كل المنافسين؟ [ضحك] وإن كنت فعلاً تستطيع التحقق من دقة رقم الهاتف وفائدته بسبع عشرة طريقة مختلفة، فعندها نعم، على الأرجح سيكون لديك كائن وطرق لا تُحصى لتقطيع ذلك وتحليله. لكن الأمثلة في الكتاب تبدو بالتأكيد كوداً «بمستوى المؤسسات»، وأظن الجميع يعرفه: أسلوب Java وC# حيث تقول «يا للهول، كل هذا الكود المتكرر (Boilerplate) لفعل شيء يبدو بسيطاً!»
56:11 كارتر: نعم، وأتذكر قصة XKCD المصوّرة: لو كتبت مقالاً بكل لغة، فنكتة Java أنك في الصفحة السادسة ولا أعرف ما الذي تقوله بعد! قرأتها في الجامعة حين كانت Java اللغة الوحيدة التي عملت بها، فقلت: «ماذا تقصد؟ كيف يمكن أن يكون أقصر من هذا؟» ثم تبدأ العمل بشيء مثل Python فتقول: «واو!» [ضحك]. هل هناك أمثلة كود أخرى أردت الحديث عنها يا ناثان؟ أظن أن الفكرة وصلت.
56:47 ناثان: لا. أنت لن تأتي إلى هذا الكتاب من أجل الكود. لست مبرمج C#، ومع ذلك كان سهل الفهم جداً، ربما لأن كثيرين منا يكتبون TypeScript، ومُبتكر C# وTypeScript هو الشخص نفسه، فهناك تداخل وتشابه كبير. لكنه لا يُسعدني. ربما تمنيت لو كان بلغة Python، التي أراها أسهل للقراءة العابرة، لأنني أقول: «انسَ هوس اللغات بالـ getters والـ setters وكل ذلك». لكن من منظور مؤسسي، ليس هذا مفاجئاً.
57:28 وأقول إنني كنت أقرأ كثيراً من هذا الكتاب بروح المعارِض: ماذا كان أوسترهاوت (مؤلف «فلسفة تصميم البرمجيات») سيقول عن هذا؟ وأرى أنه في مجال DDD الاستراتيجي هناك تقاطع جيد كبير مع «فلسفة تصميم البرمجيات». أما أين يتعثر الكتاب — وأظن هذا حال صناعة الاستشارات عموماً — ففي فكرة «آخر لحظة مسؤولة»، أي تأجيل القرارات إلى آخر لحظة مسؤولة، أو وجود هذه «المراحل التكتيكية». أظن أنه إن كان في مؤسستك شخص من نوع «الإعصار التكتيكي»، فقد ينطلق بجنون مع DDD التكتيكي: تتبع DDD شكلياً، لكنك في إعصار تكتيكي يجعلك تؤجّل التفكير الاستراتيجي الأنيق الأعمق مقابل تنفيذ ما طُلب حرفياً. وأظن أن DDD يمكن استغلاله في هذا الاتجاه بسهولة.
الفصل 10: الأفكار الختامية (58:33)
58:33 كارتر: لماذا لا نعطي بعض آرائنا الجريئة؟ ربما كودي سيئ، هذا ممكن، لا أظنه سيئاً، لكن فكرة السياقات المحدودة ونمذجة العالم الحقيقي تأتيني بشكل طبيعي جداً. لم يخطر لي قط أنه يمكن كتابة الكود بطريقة أخرى! لا أعرف إن كان الجميع يفكر هكذا، لكن من الواضح جداً لي أن الكود بطبيعة الحال يُسقَط على ما تحاول نمذجته من العالم الحقيقي. بل يبدو لي أصعب بكثير أن أبرمج بأي طريقة أخرى. أخبروني، هل أنا مجنون؟
59:20 ناثان: أظن أن للأمر وجهين. أولاً: إن دخلت بيئة لديها مجموعة مبادئ جيدة ومدروسة بنَت بها الأشياء — وأظن أنك حظيت بهذه الميزة — فأنت محق، وتكتسب حسّاً جمالياً: «آه، هكذا يكون الشيء الجيد». لكن سيكون مثيراً أن نعيد النظر في هذا بعد سنتين: إن كنت ما زلت في Leland، ما شعورك تجاه القرارات التي اتخذتها أو فهمك للعمل؟ لأن الأمر الآخر الذي سيحدث هو أن العمل يتغير: فجأة ما يعنيه صاحب المصلحة، أو المتطلبات، أو كيف يكون السياق المحدود منطقياً، يتحوّل، لأن العمل نفسه أعاد التنظيم أو فكّر في شيء جديد، ففجأة لم تعد سياقاتك المحدودة ومجالاتك الفرعية مُسقطة بشكل صحيح.
1:00:20 وهذا الجزء الآخر — ولاحظته في عمليات الاندماج والاستحواذ وغيرها — أن أحدهم «سحب البساط» أو غيّر فهمه للواقع فلم يعد النموذج مناسباً. فكيف تتفاعل مع ذلك؟ أمر صعب. إذن الوجه الآخر: حتى لو أحسنت اليوم، هل يبقى إحساناً في ظل الحقائق الخارجية؟
1:00:45 كارتر: هذا عادل. وأنا أتطلع للمستقبل؛ أنوي البقاء في Leland فترة. ومن الجميل هناك أنني أقود قرارات أكثر بكثير. وأعرف أن جورج تحدث عن هذا: من الصعب أن يكون لديك مطوّر لم يبقَ في مكان طويلاً، لأنك تحتاج أن تواجه عواقب قراراتك. وآمل أن أواجه عواقب قراراتي، وقد واجهت بعضها بالفعل.
1:01:12 ناثان: نعم، ومن أفضل التعلّم الذي ستحصل عليه... أنا ندمت بالتأكيد على بعض التنقّل بين الوظائف الذي فعلته خلال الجائحة، لأنني قدمت بعضاً من أفضل أعمالي — أو ما ظننته كذلك — ولم أعش معها سنتين لاحقاً لأرى إن كانت فكرة جيدة فعلاً [ضحك].
1:01:31 كارتر: لكنهم كانوا يدفعون كثيراً جداً خلال الجائحة، تلك هي المشكلة! أنظر للوراء وأقول: هل كان يجب أن أترك هذا المكان لذاك؟ ثم أقول: المكان التالي عرض عليك زيادة 50٪!
ناثان: نعم، فعلت الشيء نفسه. كان ذلك من أجل عائلتي، ومن أجل اللحاق بحسابات التقاعد وما شابه [ضحك]. لا ندم، لا ندم.
1:01:50 كارتر: وأنت يا ناثان، أي آراء جريئة؟
1:01:54 ناثان: ذكرتها قليلاً ولم أضغط عليها كثيراً، لكن نعم: هذا الكتاب — وأظن أن C# لغة ثقيلة بالأصناف أصلاً — بدا لي مثالاً نموذجياً لما يسمّيه أوسترهاوت «داء الأصناف» (Classitis): صنف داخل صنف يستدعي صنفاً... كثير من الأصناف «الضحلة» (Shallow Classes) تُستدعى بكثرة. لكن مرة أخرى، قد يكون مجرد أسلوب برمجة مختلف عمّا اعتدته.
1:02:24 والرأي الجريء الآخر — وذكرته سابقاً — أن DDD الاستراتيجي مبهر جداً، أما DDD التكتيكي فيبدو أنه قد يكون فوضى كاملة. وأظن أنك إن قفزت مباشرة إلى جوانب التعديلات التكتيكية في DDD، فقد تمنح DDD سمعة سيئة إن لم تكن حذراً.
1:02:48 كارتر: أظنك محقاً. أفكر في هذا كثيراً في العمل: هناك مطورون يحبون الطبيعة التكتيكية جداً، وأظنها مرتبطة بما يسمّيه ويل لارسون «التسالي» (Snacking): تدخل وتريد إصلاح هذا الشيء وتلميع ذاك. وهو مفيد، لكنه لا يغني عن قيادة المبادرات الرئيسية. نرى ذلك مع بعض المهندسين: لا أحد غير منتج، لكنك تحتاج أن تقود الأمور بطريقة أكثر أهمية. وللعلم، أظن أن هذا صحيح مع الذكاء الاصطناعي أيضاً: قليل هنا وقليل هناك... أظن أنه حان الوقت لأن نملك مبادرات أكبر من البداية للنهاية ونحرّك المؤشر بشكل ملموس.
1:03:55 لهذا أحببت كتاب «الإنتاجية البطيئة» (Slow Productivity) حين قرأناه قبل نحو سنة ونصف: فكرة «الإنتاجية الزائفة» — يمكنك أن تفعل أشياء تشعر أنها عمل، لكن هل تحرّك المؤشر فعلاً؟ ومنذ ذلك الحين أقول: يجب أن أركز على ما يحرّك المؤشر. هذا مرتبط بشكل ثانوي بفكرة DDD الاستراتيجي مقابل التكتيكي، لكنني أتفق أنك إن بدأت تعديل الكود دون صورة أكبر، فهل ستحسّنه فعلاً، أم ستُدخل جيوباً غريبة من DDD تجعل قاعدة الكود كلها أعقد في الفهم؟
1:04:32 أما ما سنفعله بشكل مختلف بعد قراءة هذا الكتاب: أودّ أن أنمذج مجالاتنا الفرعية. نحن فريق صغير وعمل صغير الآن، لدينا فريق هندسي واحد فقط، لكن الأمل أن نجمع جولة Series B في المستقبل القريب نسبياً. وإن حدث ذلك، فمن الممكن جداً أن ننمو من نحو 12 مهندساً الآن إلى 30. وأظن أنه سيكون من المعقول حينها تقسيم الفريق: هؤلاء يركزون على هذا وأولئك على ذاك. وحتى لو بقينا في مستودع واحد (Monorepo) ولم يكن منطقياً الذهاب إلى خدمات مصغّرة كاملة، أظن أنه من المنطقي وجود مجالات. وأفكر في ذلك مؤخراً: ما مجالاتنا؟ ما الذي سنفصله؟ أظن أن عليّ أن أسبق المنحنى قليلاً.
1:05:28 ناثان: رائع.
كارتر: وأنت؟
1:05:29 ناثان: سأضاعف جهودي في اللغة الموحّدة. بدأنا ذلك بالفعل: كنا نستخدم كثيراً من المخططات (Schemas) الخارجية وبيانات أخرى في مستودع البيانات الكبير الذي أعمل عليه، ونعمل على ما نسمّيه «المخطط الموحّد» (Unified Schema): فكرة ألا نُدرج إلا ما له معنى داخلياً. وكل هذا يقوده أصحاب المصلحة، أي خبراء المجال الذين نعمل معهم مباشرة. تعلمت الكثير عن المفردات، لكنني لم أدرك كم هو مهم أن أستخدم دائماً وبلا استثناء المفردات التي يستخدمونها، وأنني أنا من ينمذج عالمهم إلى عمليات حتمية قابلة للتكرار. سأبذل جهداً إضافياً في ذلك.
1:06:17 كارتر: ولمن نوصي بهذا الكتاب؟ أقول: إن كنت مهندساً يعاني في فهم العمل وتجد نفسك منغمساً في الكود، فهذا كتاب جيد للبداية. وأنا أقرع هذا الطبل منذ زمن — كلانا — أن فكرة العيش بالكامل في الكود، في عالم التعقيد العرضي، لم تكن يوماً قراراً مهنياً جيداً، وبالتأكيد ليست مساراً مهنياً جيداً، وربما لم تعد مساراً مهنياً أصلاً الآن. فإن أردت أن تفهم كيف يُسقَط العمل على الكود، فهذا كتاب جيد للبدء.
1:06:58 ناثان: أتفق تماماً. وأقول إن هذا الكتاب مهم جداً أيضاً للمهندسين الكبار والقيادات الهندسية التي ربما تعاني في معرفة كيفية تحقيق التوافق في مؤسسة أكثر نضجاً. ربما كنت في بيئات كانت الأمور فيها تعمل فحسب، واعتبرت ذلك مسلّماً، ثم تدخل إلى خلل كبير، أو تدرك أن خبراء المجال لا يعرفون حتى كيف يتواصلون؛ هذا الكتاب يعطيك أدوات كثيرة للتعامل مع ذلك.
1:07:30 لكنني أحب تأطيرك، وأظنه نقطة جيدة جداً، وربما هي الدرس الكبير الآخر: علينا جميعاً أن نفكر في العمل التجاري. فإن لم تكن تحب العمل الذي تعمل فيه، فربما ينبغي أن تجد نوعاً آخر من الأعمال. إن كنت فعلاً تريد الأمور منخفضة المستوى، فربما ينبغي أن يكون زبائنك مهندسي برمجيات آخرين، فتعمل في شركة برمجيات لثغرات النواة (Kernel) مثلاً، وحينها تغوص في التفاصيل طوال اليوم. كنت أقول لنفسي: «لا يهمني ما أعمل عليه طالما التقنية مثيرة»، ثم أدركت أن هذا غير صحيح؛ يجب أن أهتم، يجب أن أكون مهتماً بما أبنيه.
1:08:06 كارتر: كنت أقول: «طالما أحل مشكلات مثيرة»، وهذا مجرد تبرير. فعلاً. يجب أن تتحمس للمنتج ولمن تعمل معهم، وإلا ستكون الأيام السيئة سيئة جداً. ويمكن أن يكون ذلك في مجالات كثيرة؛ لم أحلم يوماً ببناء سوق للتدريب الفردي (One-on-one coaching marketplace)، لكنني أجد الأسواق (Marketplaces) مثيرة بطبيعتها، وهذا يجعل عملي أكثر إثارة بكثير.
1:08:29 على أي حال، علينا أن ننهي، شكراً لاستماعكم. سنعود بالجزء الثاني الأسبوع القادم. تجدوننا على تويتر @bookoverflowpod، وعلى bookoverflow.io. وأنا على تويتر @cartermorgan، وناثان مع وكالته الاستشارية على functionallyimperative.com. إلى اللقاء!
1:08:49 [موسيقى]