Client

更新时间:2022-11-08 22:41:52 阅读: 评论:0


2022年11月8日发
(作者:lol剑圣出装)

Asmbler

k

LIFIA-DepartamentodeInformática,FacultaddeCienciasExactas,UNLP

CC11(1900)LaPlata,BuenosAires,Argentina

[gaston,fede]@

Tel/Fax:(54)(21)228252

1.-PatternName

Asmbler

2.-AlsoKnownAs

Grouper/Packager

3.-Intent

Provideanobjectartifactresponsibletogroupacollectionofobjects,

resultingobjectorcollectionofobjectsmaybepartofanewcollectiontoasmbleagain.

4.-Motivation

ItiscommoninfinancialapplicationstofindtherequirementtogroupTransactions,TransactionFundSplits

(TransactionFundSplitsreprentsthesplitpaymenttodifferentcounterpartaccounts)orInstrumentsin

otherobjects.

SometimestheurofatradesupportapplicationneedstogroupTransactionswiththesameCounterpart

ultisanewfinancialobjectthatencapsulatesthe

henewfinancialobjectsarepolymorphicwiththeinitialones,thettlement

xistsawell-definedlectioncriterioninorderto

grouptheobjects;intheexampleabovethecriteriawasbycounterpart+maturityDate.

rtimes,thiscriteriaishardcoded

intosomemethodofadomainobject.

Wepropotomodelthelectioncriteriaasacomponentthatwillbeudbyanasmblerobjectinorder

mponentcanbereplacedbyotherlectioncriteriawithoutaffectingthe

inancialmodel1(eFig1.)instancesofclassNetteractslikeanasmbler,while

instancesofNetTransactionFundSplitplaytheasmbledobjectrole.

AbstractTransactionFundSplit

price()

tradeDate()

Client

elements()

Netter

netElements(col)

NetTransactionFundSplit

ttlementDate

quantity

price

TransactionFundSplit

fund

amount

quantity

NettingCriteria

lectFrom:aCollfor:aNet

canBeNetted:anObjwith:baObj

^lfnettingAlgorithmprice

NettingAlgorithm

quantity

price

“lectfromaColltho

objectsthatcouldbe

addedtoaNettedObject”

“AnswerifanObj

canbenetted

withbaObj”

uctureofthefinancialimplementationoftheAsmblerpattern

doingfinancialapplications(trade,

confirmation&ttlementoftransactions)implementedinVisualWorkswithENVY/Developerand

SybaRDBMS

PartoftheknowledgeoftheNetTransactionFundSplitisbadonthecomputingofagivenaspectofthe

groupedelements,suchas:price,quantity,,itispossibletodefineoperationstocomputethe

transformations.

Weusblemwiththis

approachisthatitisdifficulttoreutheasmbledobjectsinceitistightlycoupledwiththecontextwhere

otosplitthisknowledgeinanewobjectcalledCalculationAlgorithmwhichisa

privatecollaboratoroftheasmbledobject(inourmodelTransactionFundSplit).Theasmbledobject

delegatestotheCalculationAlgorithmtheresponsibilitytorespondtosomemessages.

5.-Applicability

UtheAsmblerpatternwhen:

The

resultingtisanewabstraction,Thatisbadonitscomponents.

Thelectioncriteria'salgorithmshouldbeindependentandmaybereplacedbyanotherone.

TheAsmbledObjectwantstobeudinmanycontextswithouthavingtomodifyit.

6.-Structure

hegeneralstructureoftheAsmblerpattern.

AbstractBaObject

aspectA

aspectB

aspectC

Client

elements

elements:aColl

Asmbler

netElements:aColl

AsmbledObject

add:anElement

aspectA

aspectB

BaObject

aspectA

aspectB

GroupingCriteria

canNet:with:

CalculationAlgorithm

aspectA

eralstructureoftheAsmblerpattern

7.-Participants

•Asmbler(Netter)

-Definesaninterfaceforreceivingtheobjectstogroup.

-DefinesaninterfaceforreceivingtheGroupingCriteria.

-ConstructsandasmblesAsmbledObjectsfromaninitialcollectionofobjectsaccording

totheGroupingCriteria.

•GroupingCriteria(NettingCriteria)

-Specifieswhichobjectscouldbegroupedaccordingtothecriteria.

•AsmbledObject(NettedObject)

-Implementsthedefaultbehaviorforitsinterfaceaccordingtothehierarchywhereitbelongs.

-ImplementstheCollectioninterface(#add:,#addAll:,#includes:,etc.).

-HoldsareferencetotheGroupingCriteriaudtobuilditlf.

-HoldsareferencetotheCalculationAlgorithmtouinordertorespondtosomemessages.

•CalculationAlgorithm(NettingAlgorithm)

-ImplementsthebehaviornecessarytocalculatesomeaspecsoftheAsmbledObject

8.-Collaborations

•TheClientcreaty

beaccomplishedwithaBuilder(refertotheBuilderpatternformoreinformation[Gamma95]).The

Clientmustalsoprovidethecollectionofobjectstogroup.

•TheAsmbleraskstheGroupCriteriatolectwhichobjectsofthecollectioncouldbegroupedinan

AsmbledObject.

•TheAsmblerrequeststheAsmbledObjectclasstocreateanewinstancewhichwillcontainagiven

collectionofobjectsaccordingtoaGroupingCriteria.

•TheAsmbledObjectcollaborateswiththeCalculationAlgorithminordertorespondtosome

messages.

9.-KnownUs

Buildingageographicalapplicationthatshowsdifferenttemperatureandpressuremeasures,wehadto

lethisacurvewhichjointpointswithequal

asolutionbadontheAsmblerpatterninordertomodelanIsoplethobject.

catheIsoplethhierarchyhasa

Composite[Gamma95].ASingleIsoplethisinstantiatedwhenthefirsttwopointsarefound;afterwardsonly

CompodIsoplethinstancesareudtogeneratethetemperatureorpressureisopleth.

Client

elements

elements:

IsoplethBuilder

build

Isopleth

maximunMeasure

minimunMeasure

matchAMeasure:

CalculationAlgorithm

value:

GroupingCriteria

canGroup:with:inDistance:

canGroup:with:

SingleIsopleth

measure

position

CompodIsopleth

measure

add:

position

graphicalimplementationoftheAsmblerpattern

10.-Implementations

Wehaveentwodifferentimplementationsofthispattern,thefirstoneinthefinancialdomainwas

prentedinction4“motivation”,thecondonewasthegeographicalexamplethatwasprentedinthe

knownus(ction9).Themaindifferencebetweenbothcasisthespecificimplementationof

asshastobeimplementedfollowingtherulesgivenbythedomain.

InthefinancialcatheresultofthewholenettingoperationisacollectionofNetTransactionFundSplit,

whilethesourceisacollectionofTransactionFundSplitandNetTransactionFundSplit.

Inthegeographicalca,theIsoplethBuilderproduceoneIsoplethasresult,whilethesourceisacollection

ofmeasureandIsopleth(SingleorCompod).

TheGrouppingCriteriaandtheCalculationAlgorithmmaybeimplementedasstrategiessinceanyofthem

otheStrategypatternformoreinformation

[Gamma95]

11.-Conquences

•ThecreationofAsmbledObjectisbadonaGroupingCriteria(alogicbadonthe

domain),whichcouldchange,orappliedagain.

•TheAsmblerobjectcanbeeasilyreudinmanydifferentcontextsjustbyreplacingthe

GroupingCriteria.

•ForsmallcollectionsofobjectswheretheGroupingCriteriaistoosilly,itmaybewirto

extendCollectioninordertorespondto#groupBy:insteadofimplementingtheAsmbler

pattern.

12.-RelatedPatterns

Actually,dbestructurally

describedintermsofaCompositewhichinteractswithtwoStrategies;oneforbuildingandtheotherfor

dbepartofacondorderpatternclassification.

TheAsmbledObjectissimilartoComposite,becauitgroupsobjectswithadefined

structure.

TheGroupingCriteriaprovidesthedomainbadlogictolectobjectsthatwillbegrouped,it

couldbeimplementedasaStrategy.

TheCalculationAlgorithmimplementsoperationstocomputeorreprentthe

AsmbledObject’dbeimplementedasaStrategy.

Asmbler,likeaBuilder,the

GroupingCriteriainordertoaccomplishthistask.

13.-References

[Gamma95],,n,des:

"DesignPatterns.

ElementsofreusableObject-OrientedSoftware"

.AddisonWesley,1995.


本文发布于:2022-11-08 22:41:52,感谢您对本站的认可!

本文链接:http://www.wtabcd.cn/fanwen/fan/82/455296.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:responsible
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图