design consideration

This is a discussion on design consideration within the C++ Programming forums, part of the General Programming Boards category; Hello I'm working on a simple web application and I need some design consideration with you guys.. I have 2 ...

  1. #1
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630

    design consideration

    Hello

    I'm working on a simple web application and I need some design consideration with you guys..

    I have 2 'cache' vectors where I store all dns records..

    Both record types derive from base class base_record which is abstract class (has some virtual functions and stuff)..

    They are:

    Code:
    class a_record : public base_record {
    }
    
    class aa_record : public base_record {
    }

    There is a vector of strings in each of those classes which stores all ip addreses for the specific domain.. I want to be able to get first ip address in the list and then try connecting to it.. If connection cannot be established I move to the next ip address string in the vector inside the record class object..

    The next time I access the same object (of record class) and I want to get ip address it should return the last ip address that was used (the one we were able to connect to).

    So I've been thinking of some options that would be suitable:

    1. make a simple size_type member in each record class that would store the current position

    2. use boost iterator libraries (which I dont fully understand how they work and if they would really be suitable for this - I would need some kind of endless iterators)

    3. overload * operator so that it would return current ip address (string), overload ++ so that it would move to the next element in the list (this seems as the most sensible solution to me)

    I want this to be professional and as simple as possible.. What do you guys think which design should I go for? Maybe some other suggestion? I know it sounds really easy but this kind of problems always make me (probably) think too much..


    Thanks a lot for help!

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    1 and 3 are not mutually exclusive. In fact, 1 is an excellent way of implementing 3. And 3 sounds like good design - the dereference operator seems appropriate.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. design consideration
    By l2u in forum C++ Programming
    Replies: 14
    Last Post: 10-14-2008, 11:24 AM
  2. any comments about a cache design?
    By George2 in forum C Programming
    Replies: 6
    Last Post: 09-14-2006, 01:53 PM
  3. Implementing Inheritence into your design
    By bobthebullet990 in forum C++ Programming
    Replies: 6
    Last Post: 08-05-2006, 05:40 PM
  4. Cprog tutorial: Design Patterns
    By maes in forum C++ Programming
    Replies: 7
    Last Post: 10-11-2004, 02:41 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21