Presentation is loading. Please wait.

Presentation is loading. Please wait.

#1Refactoring.  Xtreme Programming  Wensen van designers veranderen vaak.

Similar presentations


Presentation on theme: "#1Refactoring.  Xtreme Programming  Wensen van designers veranderen vaak."— Presentation transcript:

1 #1Refactoring

2

3

4

5

6

7  Xtreme Programming

8  Wensen van designers veranderen vaak

9

10

11 !!!

12  Wensen van designers veranderen vaak

13

14

15

16

17

18

19 refactor

20

21  Schone code vs later refactoren

22 X

23

24  Vermijdt dubbele code Welke code lijkt veel op elkaar?

25  D3DXHANDLE refractionTechnique, skyTechnique, glowTechnique;  g_refractionEffect->FindNextValidTechnique(0, &refractionTechnique);  g_refractionEffect->SetTechnique(refractionTechnique);  g_skyEffect->FindNextValidTechnique(0, &skyTechnique);  g_skyEffect->SetTechnique(skyTechnique);  g_glowEffect->FindNextValidTechnique(0, &glowTechnique);  g_glowEffect->SetTechnique(glowTechnique);

26  D3DXHANDLE refractionTechnique, skyTechnique, glowTechnique;  g_refractionEffect->FindNextValidTechnique(0, &refractionTechnique);  g_refractionEffect->SetTechnique(refractionTechnique);  g_skyEffect->FindNextValidTechnique(0, &skyTechnique);  g_skyEffect->SetTechnique(skyTechnique);  g_glowEffect->FindNextValidTechnique(0, &glowTechnique);  g_glowEffect->SetTechnique(glowTechnique); void InitalizeEffect(D3DXEFFECT *effect, D3DXHANDLE &technique) { effect->FindNextValidTechnique(0, &technique); effect->SetTechnique(technique); }

27

28  Nieuwe functie / member maken  Verhuizen naar (super)object  Verhuizen naar ‘free function’

29  void UpdateKaleidoscope(int kaleidoSides, float time)  {  …  tc[0] = center + zoom * D3DXVECTOR2(cosf(angle - 2.0f * f / 3.0f), sinf(angle - 2.0f * f / 3.0f));  tc[1] = center + zoom * D3DXVECTOR2(cosf(angle), sin(angle));  tc[2] = center + zoom * D3DXVECTOR2(cosf(angle + 2.0f * f / 3.0f), sinf(angle + 2.0f * f / 3.0f));  …  float triangleVertices[] =  {  p0.x, p0.y, 0.0f, tc[0].x, tc[0].y,  p1.x, p1.y, 0.0f, tx1.x, tx1.y,  p2.x, p2.y, 0.0f, tx2.x, tx2.y  };  g_d3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 1, triangleVertices, 5 * sizeof(float));  }

30  void UpdateKaleidoscope(int kaleidoSides, float time)  {  tc[0] = center + zoom * D3DXVECTOR2(cosf(angle - 2.0f * f / 3.0f), sinf(angle - 2.0f * f / 3.0f));  tc[1] = center + zoom * D3DXVECTOR2(cosf(angle), sin(angle));  tc[2] = center + zoom * D3DXVECTOR2(cosf(angle + 2.0f * f / 3.0f), sinf(angle + 2.0f * f / 3.0f));  }  void RenderKaleidoscope()  {  float triangleVertices[] =  {  p0.x, p0.y, 0.0f, tc[0].x, tc[0].y,  p1.x, p1.y, 0.0f, tx1.x, tx1.y,  p2.x, p2.y, 0.0f, tx2.x, tx2.y  };  g_d3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 1, triangleVertices, 5 * sizeof(float));  }

31 OBJECT Kaleidoscope METHODS Update Render ATTRIBUTES vector0, vector1, vector2 center zoom

32 OBJECT Effect METHODS Update Render OBJECT Kaleidoscope EXTENDS Effect ATTRIBUTES vector0, vector1, vector2 center zoom OBJECT Bloom EXTENDS Effect ATTRIBUTES …

33  string ToLower(string s)  {  transform(s.begin(), s.end(), s.begin(), ::tolower);  return s;  }

34  Repeat  Input->update();  Physics()->update();  World->Update();  World->Render();  Until…

35

36  Inleveren in week 12


Download ppt "#1Refactoring.  Xtreme Programming  Wensen van designers veranderen vaak."

Similar presentations


Ads by Google