Re: Procedural design patterns?

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...
TheresNoTime said...

P.S. For example, how to implement CQRS in Euphoria? I can not figure out how this can be done without the OOP.

In fact, the code examples in the wikipedia link show you non-OOP code. Translated to euphoria here:

integer x = 0 
function value() 
  return x 
end function 
 
procedure increment_x() 
  x = x + 1 
end procedure 

I don't see why OOP makes this any easier or harder.

Matt

Of course, I did not mean such a trivial example. Let x is the level of force of an object in the game (the hero, the monsters, the boss). Pseudo-OOP-Eu:

hero = clone(person) 
hero.lifepoints = 100 
for i = 1 to 100 do 
  monsters[i] = clone(hero) 
end for 
boss = clone(hero) 
boss.lifepoints *= 10 
--------------------- 
if monsters.count = 0 then 
  attack_boss() 
  if boss.lifepoints = 0 then 
    puts(1, "You saves FairyLand!") 
  else 
    puts(1, "Boss eats you! :(") 
  end if 
end if 

How to automate reading and writing multiple parameters of the same type? Use a sequence where the first integer is hero's lifepoints, the next 100 - monsters' lifepoints, and 102nd is the boss?

sequence LifePoints = repeat(100, 101) & 1000 
 
export fuction hit(integer who) 
  LifePoints[who] -= 1 
end function 

Thank you. I'd rather look into the OOP.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu