Start with Events and DDD When Building Microservices
Domain-Driven Design (DDD) is a great technique bringing designs closer to the domains we are working in, but too often we make early design decisions with a focus on structure, which is not the intention of DDD. Instead, we should start with the events in a domain, Russ Miles recently claimed while describing advantages of going “events-first” when building microservices.
Miles believes that besides focusing on structure, we are also focusing the ubiquitous language too much on things, especially on domain objects. To make things even worse we have also started to create libraries with domain objects for reuse across domain boundaries, effectively preventing different bounded contexts from evolving separately.
In Miles’ experience, this approach has become the default architecture style for enterprise layered architecture, the reason being to make things easier, not simpler or to help in improving a design. This has caused things, like entities, to move from being ubiquitous in one context to being canonical across all contexts, a direct contradiction with the ideas of DDD.
Instead Miles claims that we should start with what happens in a domain- the events. They are better in capturing the ubiquitous language in a domain, and often the easiest way to describe the domain, especially when collaborating with domain experts. He has found that this approach works well both when building a new system and when evolving an existing system.
The first step that Miles favours when working with events is Event storming , a modelling workshop technique created by Alberto Brandolini. The basic idea is to explore a domain by the things happening in it, the domain events, and capturing these events using stickers on a large modelling surface along a timeline. Examples of what can cause an event include a user action, something happening in an external system, and time passing. Events can also help in finding the boundaries within a domain; different interpretations of terms involved may indicate a boundary.
Another cause of complexity for Miles is using the wrong model for the wrong job. DDD has the repository pattern for dealing with persistent state but often uses the same model for read and writes. One advantage this gives is consistency, but if the needs are distinctively different we can gain significant benefits by separating reads from writes with different models.
Command Query Responsibility Segregation (CQRS) is a technique for doing this separation:
Event sourcing is a natural extension to CQRS, where all events emitted by the aggregates are persisted and used to recreate the state of an aggregate, instead of storing the state itself. This ability to recreate state, according to Miles, is a way of reducing the fragility of state.
CQRS together with event sourcing bring other complexities like eventual consistency ; Greg Young , who coined the term CQRS and is behind today’s interest in event sourcing, notes that they are not top-level architectures. According to Young, they should normally be applied selectively just in few places, and he emphasizes that a whole system based on event sourcing is an anti-pattern.
© Source: http://www.infoq.com/news/2016/12/microservices-events-ddd?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=news
All rights are reserved and belongs to a source media.
Dubai-based Aramex , a global provider of logistics and transportation services, has evolved into a global brand in the three decades since it was founded in 1982.
Nvidia is giving gamers using the GeForce Experience will now be able to broadcast directly to Facebook Live, CEO Jen-Hsun Huang announced at CES today.
Google is bringing its Siri, and Alexa rival, Google Assistant , to television screens. The search giant previously stated plans to bring their assistant to various hardware during their I/O conference back in May last year.
東京電力ホールディングスの広瀬直己社長は5日午前、新潟県庁で同県の米山隆一知事と初めて会談した。 米山知事は昨年10月の知事選で、東電柏崎刈羽原子力発電所(同県柏崎市、刈羽村)の再稼働に慎重な姿勢を掲げて初当選しており、再稼働の是非の検証には数年かかるとの見通しを示した。 同社の 数土 ( すど ) 文夫会長らも同席し、報道陣に公開された。再稼働に向けて協力を求めたい東電側に対し、東電福島第一原発事故の徹底的な検証を重視する米山知事は、「県民の暮らしを守るのが最優先。検証がなされない限り、再稼働の議論はできない」と応じた。 柏崎刈羽原発をめぐっては、再稼働を目指す6、7号機が、新しい規制基準に基づいて原子力規制委員会の安全審査を受けている。知事は再稼働に法的権限を持たないが、政府は地元同意を重視している。米山知事は、原発事故が健康や生活に与える影響などを検証する委員会を新たに設置する意向を示している。会談では、「検証には数年はかかると予想している」と語った。
大麻成分の入ったキャンディー208個を米国から輸入したとして、神奈川県警が5日、米国籍の30代の男を大麻取締法違反(密輸)の疑いで再逮捕したことが、捜査関係者への取材でわかった。男は「個人で使う分を友人に送ってもらっていた」と容疑を認めているという。
2016年の国内新車販売台数(軽自動車を含む)が前年比1・5%減の497万260台にとどまり、2年連続で減少したことが5日分かった。軽自動車の販売が落ち込んだためで、500万台を割り込んだのは東日本大震災があった11年以来、5年ぶり。 日本自動車販売協会連合会と全国軽自動車協会連合会が5日発表した。 軽自動車の販売台数は9・0%減の172万5462台と、2年連続のマイナスだった。軽の販売は14年に約227万台とピークを付けたが、軽自動車税が増税された15年に約189万台まで急減し、16年は一段と落ち込んだ。 軽以外の自動車(登録車)は新型モデルの投入効果もあり、3・0%増の324万4798台と2年ぶりに前年実績を上回ったが、軽の落ち込みを補えなかった。
Кібератаки з боку Росії на політичні організації США з метою вплинути на президентські вибори були «актом війни». Таку заяву зробив у середу, 4 січня, сенатор-республіканець Джон Маккейн, передає DW.
Служба безпеки України направила в Міністерство закордонних справ документи для погодження заборони в’їзду на територію України ультраправого французького політика Марі Ле Пен.