Re: Differentiating between Connectors and Objects



On Wed, Jul 9, 2008 at 11:20 PM, Fred Morcos <fred morcos gmail com> wrote:

(pseudo code)
if (objtype == "Standard - Line" || "UML - Generalization" || "UML -
Dependency" || etc...)

It seems from the rest of the conversation that you will indeed be
stuck with comparing strings. If that is actually the case, I would
suggest that you make your code as future-proof as possible.

For starters, quite a few string constants are already declared as
macros. Instead of hard-coding the value as you have shown in the
pseudocode, you should consider using such macros. You could possibly
define them if they don't already exist, and replace all occurences of
each string with the corresponding macro. (As an aside, actually I had
promised to clean up many of these hard-coded strings, but that's one
of my commitments that has been left by the way-side due to my current
busy status)

In addition, try to create a function that captures your intention
clearly. Instead of inserting a long series of comparisons in the
condition part of an if-statement, make it a function with a name like
(is_connector) or something specific and meaningful like that. If you
can figure out an appropriate file to put that function, that is even
better, so that others could also use it.

If you really want to get into details, consider implementing this as
a function in the Object vtable. Both Lars and Hans will give you a
very hard time if you decide to take this last option, but it can
sometimes be worth it!

Sameer.
-- 
Research Scholar, Department of CSE, IIT Bombay
http://www.it.iitb.ac.in/~sameerds/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]