Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: Map coordinate cleanups.
Home

[Freeciv-Dev] Re: Map coordinate cleanups.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gaute B Strokkenes <gs234@xxxxxxxxx>
Cc: rf13@xxxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Map coordinate cleanups.
From: Kevin Brown <kevin@xxxxxxxxxxxxxx>
Date: Thu, 16 Aug 2001 14:40:04 -0700

Gaute B Strokkenes <gs234@xxxxxxxxx> wrote:
> > These methods provide abstraction.
> 
> They don't.  get_tile_type() takes a terrain identifies and returns a
> struct describing that terrain, without any error checking.  An array
> look-up is a perfectly acceptable, commonplace idiom to go from a FOO
> identifier to FOO_TYPE descriptor struct.  

That's true...when you're dealing with an array.

But who says that we'll always be dealing with an array, instead of
something like a hash table, tree, or whatever?  Using a function like
get_tile_type() lets you change the underlying implementation with
minimal consequences for the rest of the code.

So it *does* provide an abstraction, in that the caller doesn't need
to know how the tile types are stored.

So I happen to find functions a better approach overall for stuff like
this, at least when there are lots of places that make use of it.


-- 
Kevin Brown                                           kevin@xxxxxxxxxxxxxx

    It's really hard to define what "unexpected behavior" means when you're
                       talking about Windows.


[Prev in Thread] Current Thread [Next in Thread]