[Kde-games-devel] Design of Qt and/or KGame based programs, part 1

Tom Bradley tojabr at tojabr.com
Sun Sep 26 16:49:43 CEST 2004


>Now, further suppose that you want to set the score from several places from 
>within the same class that the slotScore() resides in.  The call will then be 
>"slotScore()" which I find kind of ugly.
>
>How do you handle this case?  Do you
>
>a) Just call the slot like above?
>
>b) have a helper method with, say, the name showScore() that does the actual 
>work, and then call it from within the slot?
>
>c) Not name the slot slotFoo() from the beginning, but just foo()?
>
>d) some other way?
>
>I find method a) somewhat ugly, although I can't really put my finger on why. 
>Method b) leads to an explosion of small methods and confusion for the people 
>that try to read the code.  I like to distinguish my slots from the rest of 
>the functions, so I don't like method c) either.
>
>Currently I am leaning towards method a).  What do you think? Is there a 
>common convention for this?
>
>	-Inge
>  
>

There is no need to really distinguish between a slot and any other 
member function, because a slot is just another member funtion. You call 
it the same way. If I were doing this I would just call it 
updateScore(). The key word slots is just "notes" for the moc compiler 
about the functions. Other than that are are just regular member functions.

For common convention just look at other Qt and KDE slot functions, they 
are just verb based names.

Tom



More information about the kde-games-devel mailing list