View Single Post
Old 16-09-2011, 09:04 PM   #5
jonh_sabugs
Abandonia nerd

 
Join Date: May 2010
Location: Brazil
Posts: 91
Default

From my experience, using GOTO's outside of assembly is a deadful approach. It has nothing to do with elitism, it's part of software engineering/quality theory, whereas reading and otherwise analysing execution flow becomes really painful in a goto-filled mess. All in all, I learned to never ever use it in my own codes.

About the object-oriented 'approaches' versus switch statements things, I think what they probably meant was using some kind of inheritance for key handling. After reading the code, I find this rather unfair really, since keyboard handling would be annoying to implement in such fashion.

I am no expert in C#, I usually implement in C/C++ and Java, but usually an alternative to switch is have the many elements as specific objects, extending some super class, so you only need to call the appropriate (overloaded) method in each one. However you get these object from the API in this case, and I can't see how you could effectively implement this. Another more object-oriented alternative is to build a class, backed by a hashtable or something, which would provide you dynamically (and quicker) the methods (or objects) for each possible key.

Well, I am thinking this on-the-fly here, so it's just some ideas of what they could be expecting. Maybe the idea was to evaluate your grasp on inheritance, or they were simply being asses.

Hope this helps shed some light on the issue.

EDIT: Dunno If I sounded otherwise, but switch statements are perfectly acceptable in OO programming, under certain circunstances.

Last edited by jonh_sabugs; 16-09-2011 at 09:10 PM. Reason: More info
jonh_sabugs is offline                         Send a private message to jonh_sabugs
Reply With Quote