0

An abstract data type(ADT) is defined in a package. There must be some operations defined, be able to handle objects of ADT. I think that there is no rule telling us in which order routines of a ADT must be sorted. For example, should be first all inspectors (get routines) and then all modifiers (set routines) listed? Or should these routines by inspected or modified attribute sorted? Is there a rule to sort ADT routines in its package specification (ADS) file?

I want to make a sensible order starting out types of routines.

stardust
  • 343
  • 3
  • 17
  • Lots of good examples in the Ada [LRM](http://www.adaic.org/resources/add_content/standards/05rm/html/RM-TOC.html). – trashgod Dec 27 '11 at 23:27

2 Answers2

2

It’s a bit difficult talking about ADTs in the abstract, but I’d probably structure by use case, at a higher level than inspect and modify.

As @trashgod suggests, the LRM is a good starter; for example, Ada.Text_IO. You may also find the Quality and Style Guide useful.

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
0

What about this structure, as an example (LIFO):

AbstractDataType Queue {
   1.Constructors:
      a.CreateQueue
   2.Destructors:
      a.DeleteQueue
   3.Inspectors: 
      a.EqualQueues
      b.EmptyQueue
      c.QueueSize
      d.QueueFront
      e.QueueRear
      f.PrintStack
   4.Modifiers:
      a.Enqueue
      b.Dequeue
      c.AssignQueues
}
stardust
  • 343
  • 3
  • 17
  • See also [`Ada.Containers.Doubly_Linked_Lists`](http://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-18-3.html), which may obviate the need for explicit destructors. – trashgod Dec 28 '11 at 13:32
  • 1
    Although there will be “constructor”, assignment, and “destructor” aspects, you ought to use default component values and `Finalization` to manage this. Otherwise, not unreasonable. I think you shouldn’t have the word Queue (or Stack!) in the names; the package name tells us that. Operation 3a’s name should be `“=“`. – Simon Wright Dec 28 '11 at 13:41