Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
github
github
1. StartEclipse 2. Closeanyopenproject Wearenextgoingto
clonetheAirplanecode fromGit Hub
1.select
2.select
github
1.select
2.select
3.select
github
1.select
2.select
github
1.Fill in git://github.com/odedlac/Strategy.git
github
1.select
github
1.select
github
1.select
github
1.select
github
1.select
github
1.select
observe
Factory Method
Factory Method
1. Replace with this code
Factory Method
1.select
2.select
New Code
FlyingFactory
Factory Method
1.select 2.select
3.select 4.select
Factory Method
1. Replace with this code if(string.equals("FighterJet")){ return new IFlyLikeFJ(); } Now it remains to create an instance of FlyingFactory in AirplaneTest
Factory Method
1. Insert this code @BeforeClass public static void onlyOnce(){ flyingFactory =new FlyingFactory(); }
Factory Method
1.select 2.select
Factory Method
1.select 2.select
Factory Method
1. Changetherestofthetestsothattheyuseafactory
method
2. Dothisalsoforliftoff Ifyouhaventfinishedyoucancloneitfrom
git://github.com/odedlac/StrategyMethodFactory.git
Abstract Factory
Abstract Factory
harrierFactory.createFlying(); harrierFactory.createLiftOff();
Abstract Factory
1. Insert code
Abstract Factory
1. UseexistingcodetogenerateHarrierFactorycode. 2. Useexistingcodetogeneratestubsformissing
methodsinHarrierFactory. Youshouldget
Abstract Factory
1. CodeforcreateFlyingmethodinHarrierFactory
public FlyingcreateFlying(){ FlyingFactory flyingFactory =new FlyingFactory(); return flyingFactory.createFlying("FighterJet"); }
2. CreateyourowncodeforcreateTakeOffmethodin
HarrierFactory
3. Exctract interfacefromHarrierFactoryandcallit
AirPlaneFactory.
4. Writeafactoryforallthekindsofairplanes
Abstract Factory
Ifyouhaventfinishedyoucancloneitfrom
git://github.com/odedlac/StrategyAbstractFactory.git
Builder
Builder
1. Ifyouhaventdonesoalready.Clonecodefrom:
git://github.com/odedlac/StrategyAbstractFactory.git
Builder
1.Replace code
Builder
Usenewcodeto:
1. 2. 3. 4. 5.
Builder
1.Replace code
this.builder =builder;
Builder
1.Replace code
Builder
1.Replace code
return airplane;
Builder
1.Replace code
2.Replace code
3.Replace code
4. Use new code to generate missing fields 5. Run test if they all pass, then commit
Builder
1. ExtractinterfaceBuilderfromHarrierBuilder 2. Runtestifpasses,thencommit
HarrierBuilder Code
1.select
2.select
Builder
1.select Observe!
2.select
Builder
1. ApplythestatictoliftoffFactory 2. Writeandtestabuilderformodelairplaneandpassenger
airplane
3. Removeredundantcode
(dontforgettocommiteverytimeyouarehappywiththeresults)
4. Possibleresult:git://github.com/odedlac/StrategyBuilder.git 5. Whynotgetthebuilderfromafactorymethod
(whymightitbeaproblemtohaveastaticdirector)