Soul Players Index du Forum


Chain Pattern

 
Poster un nouveau sujet   Répondre au sujet    Soul Players Index du Forum -> Guilde -> Event & Autres
Sujet précédent :: Sujet suivant  
Auteur Message
ritcath


Hors ligne

Inscrit le: 08 Mai 2016
Messages: 95
Localisation: Milano

MessagePosté le: Sam 21 Mai - 13:50 (2016)    Sujet du message: Chain Pattern Répondre en citant




Chain Pattern > bit.ly/1U5swvp





Participants..The..pattern..in..the..short..version..includes:..The..Handler:..defines..an..interface..for..handling..requestsWriting...to...console:...Order...record...retrievedThis..section..is..incompleteA....clever....design....should....be....a....flexible....oneChain...of...ResponsibilityAbstractLogger.java}...else...{...//...request...is...not...spamAnd,...to...make...our...work...even...harder,...we...also...happen...to...be...denied...access...to...the...object...which...needs...to...handle...the...eventIn..the..meantime,..try..navigating..to..any..of..these..pages..-..Home..page..-..Products..page..-..References..page..Real...world...examples...include...the...making...of...a...car...(chassis,...interior,...exterior,...painting,...wheels,...etc.),...or...the...creation...of...a...web...page...(header,...body,...content,...and...footer)If...the...first...handler...can't...handle...the...request,...the...request...is...forwarded...to...the...next...handler,...and...it...is...passed...down...the...chain...until...the...request...reaches...a...handler...that...can...handle...the...request...or...the...chain...endsUse...on...existing...codeAll..view..objects..(NSView/UIView),..view..controller..objects..(NSViewController/UIViewController),..window..objects..(NSWindow/UIWindow),..and..the..application..object..(NSApplication/UIApplication)..are..responder..objects*....*....param....mixed....$request....*....*....return....mixed....*/....abstract....public....function....handle($request);....}....Below....is....an....example....(not....fully....implemented)....continuing....with....the....code....above:....class....FirstHandler....extends....BasicHandler....{....public....function....handle($request)....{....//provide....a....response,....call....the....next....successor....}....}....//....File::Logger:....This....is....an....debug....level....information..2016..-..Data..&..Object..Factory,..LLCThe...UML...diagram...of...classes...below...will...help...us...understand...better...the...way...the...Chain...worksA...Client...makes...the...request...to...the...start...of...the...handler...chainpackage...com.cakes;...public...abstract...class...PlanetHandler...{...PlanetHandler...successor;...public...void...setSuccessor(PlanetHandler...successor)...{...this.successor...=...successor;...}...public...abstract...void...handleRequest(PlanetEnum...request);...}...Avoiding...spam...requestsThis....C#....examples....uses....the....logger....application....to....select....different....sources....based....on....the....log....level;I..encourage..you..to..explore..other..pattern..modificationsOne..way..to..solve..this..is..by..checking..if,..at..the..end..of..the..chain,..the..request..has..been..handled..at..least..once,..otherwise..we..will..have..to..implement..handlers..for..all..the..possible..requests..that..may..appearStandard....Console::Logger:....This....is....an....debug....level....informationIn...designing...a...shipping...system...for...electronic...ordersNext,....well....look....at....some....suggestions....on....common....CoR....issues....like....configuring....the....priority....and....speeding....up....the....chainclass..CheckAuthority..{..public..static..void..main(String[]..args)..{..ManagerPPower..manager..=..new..ManagerPPower();..DirectorPPower..director..=..new..DirectorPPower();..VicePresidentPPower..vp..=..new..VicePresidentPPower();..PresidentPPower..president..=..new..PresidentPPower();..manager.setSuccessor(director);..director.setSuccessor(vp);..vp.setSuccessor(president);..//..Press..Ctrl+C..to..endDZoneMany..concrete..handler..objects:..process..the..request..and..optionally..provide..access..to..successors;..CoR..can..also..include:....a..Client..object..to..perform..the..request..and..set..up..the..chain;....a..Request..object;....a..Response..object;....other..design..patternsabstract..class..AdvancedHandler..{..//code..While..the..example..below..doesnt..solve..all..the..CoR..issues,..it..shows..how..the..pattern..can..be..easily..restructured..and..adapted..to..different..logicChain....of....Responsibility....PatternImplementations[edit]Of...course...in...real...life...we...can...not...use...primary...data...types...as...a...requestWriting...to...console:...Order...DispatchedThis...pattern...promotes...the...idea...of...loose...couplingProducts...All...Products...and...Pricing....NET...Design...Pattern...Framework...TM...4.5...--...C#...Edition....NET...Design...Pattern...Framework...TM...4.5...--...VB...Edition...PRO....NET...Design...Pattern...Framework...TM...4.5...--...C#...Edition...PRO....NET...Design...Pattern...Framework...TM...4.5...--...VB...Edition...JavaScript...+...jQuery...Pattern...Framework...TM...SQL...+...Database...Pattern...Framework...TM...PRO...SQL...+...Database...Pattern...Framework...TM...Customers...Meet...our...Customers...Success...Stories...Reference...Guides....NET...Design...Patterns...JavaScript...Design...Patterns...JavaScript...Tutorial...SQL...Tutorial...Connection...Strings...Visual...Studio...Shortcuts...C#...Coding...Standards...HTML...Color...Codes...All...References...Community...Questions...Ask...Question...Explore...Tags...Users...About...Us...Company...Our...Story...Services...Training...Contact...Us...Broken..Chainabstract..class..PurchasePower..{..protected..static..final..double..BASE..=..500;..protected..PurchasePower..successor;..abstract..protected..double..getAllowable();..abstract..protected..String..getRole();..public..void..setSuccessor(PurchasePower..successor)..{..this.successor..=..successor;..}..public..void..processRequest(PurchaseRequest..request){..if..(request.getAmount()..Director..->..Vice..President..->..PresidentFor..example,..the..chain..can..be..configured..by..each..Request..object,..as..in..the..example..below,..with..a..little..code..modification f5880b0734



Revenir en haut
Publicité






MessagePosté le: Sam 21 Mai - 13:50 (2016)    Sujet du message: Publicité

PublicitéSupprimer les publicités ?
Revenir en haut
Montrer les messages depuis:   
Poster un nouveau sujet   Répondre au sujet    Soul Players Index du Forum -> Guilde -> Event & Autres Toutes les heures sont au format GMT + 2 Heures
Page 1 sur 1

 
Sauter vers:  


Index | Panneau d’administration | créer forum | Forum gratuit d’entraide | Annuaire des forums gratuits | Signaler une violation | Conditions générales d'utilisation