Domain-Driven Design: Tackling Complexity in the Heart of Software


Shift the responsibility for creating instances of complex objects and



Download 7,21 Mb.
Pdf ko'rish
bet90/343
Sana17.11.2022
Hajmi7,21 Mb.
#867526
1   ...   86   87   88   89   90   91   92   93   ...   343
Bog'liq
Eric Evans 2003 - Domain-Driven Design - Tackling Complexity in the Heart of Software

Shift the responsibility for creating instances of complex objects and 
AGGREGATES
 to a
separate object, which may itself have no responsibility in the domain model but is still
part of the domain design. Provide an interface that encapsulates all complex assembly
and that does not require the client to reference the concrete classes of the objects
being instantiated. Create entire 
AGGREGATES
 as a piece, enforcing their invariants.
There are many ways to design 
FACTORIES
. Several special-purpose creation patterns— 
FACTORY
METHOD, ABSTRACT FACTORY
, and 
BUILDER
—were thoroughly treated in Gamma et al. 1995. That
book mostly explored patterns for the most difficult object construction problems. The point here is
not to delve deeply into designing 
FACTORIES
, but rather to show the place of 
FACTORIES
as
important components of a domain design. Proper use of 
FACTORIES
can help keep a 
MODEL-DRIVEN
DESIGN
on track.
The two basic requirements for any good 
FACTORY
are
Each creation method is atomic and enforces all invariants of the created object or
AGGREGATE
. A 
FACTORY
should only be able to produce an object in a consistent state. For an
ENTITY, this means the creation of the entire 
AGGREGATE
, with all invariants satisfied, but
probably with optional elements still to be added. For an immutable 
VALUE OBJECT
, this means
that all attributes are initialized to their correct final state. If the interface makes it possible
to request an object that can't be created correctly, then an exception should be raised or
some other mechanism should be invoked that will ensure that no improper return value is
possible.
1.
The 
FACTORY
should be abstracted to the type desired, rather than the concrete class(es)
created. The sophisticated 
FACTORY
patterns in Gamma et al. 1995 help with this.

Download 7,21 Mb.

Do'stlaringiz bilan baham:
1   ...   86   87   88   89   90   91   92   93   ...   343




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish