TweetFollow Us on Twitter

March 93 - Camelot — Not Just Another Pretty Face

Camelot — Not Just Another Pretty Face

Juan Guillen

Camelot is an object oriented environment which has been built "from the ground up" by developers for developers. Camelot is designed from first principles rather than being based on other products, and it does more than making it easier to write graphical user interfaces.

The environment incorporates some significant new capabilities for the management of the complexity introduced by large system developments. One of these is an additional level of modularity which permits individual components to be created independently, then combined with other components to create a complete system (see Figure 1). The use of object repositories to store both objects and instance specific methods provides an additional degree of encapsulation, and its open architecture guarantees full interoperability with existing systems.

Camelot is supported by a comprehensive visual development environment. Nevertheless, as some of the concepts which we are going to discuss are best expressed syntactially, we begin with a background description of Camelot's Fire language.

Fire

The Fire language is a strongly typed, late binding language which has been designed to express fundamentally procedural logic in an object oriented context. Its data types can be characterized as follows:
  • Object, which references a Fire object.
  • Standard Types, which include integer, float and string.
  • Utility types, including pointer, which is used to store information useful to foreign systems, and variable, which assumes the data type of the value it contains.
  • Structured types other than object, including record, field and collection. A variable of type collection can contain any number of objects of any class, and can be sequential or keyed.

Variables are accessed either normally (one := two), hierarchically (one += two.three.four) or indirectly (one.two -= <<"th"+"ree">>.four.<<"fi"+"ve">>). In the indirect form, any expression which results in a string value can be placed between the <<Ê>> bracketing. Fire implements an hierarchical variable name resolution scheme which searches for a variable first in the method, then in the object, etc. until it searches the global name space. These levels are method -> object -> connected object -> module -> global, and are discussed in greater detail below.

The code fragment below illustrates a several Fire principles.

01 #include "DCCDefinitions.D"
02  #ifndef DCC
03      # define DCC 5
04  #endif

05  method open( arg integer ) returning string
06  {
07      name string : initial value "DNX";
08      element object.dcc(ne);
09       if ( arg:assigned )
10      {
11           name := elements[ DCC, arg ].name;
12      }
13      if ( name:length >= 17 )
14      {
15          [ New(element) ConnectionAddFirstTo( self ) ];
16      }
17      return ( name );
18  }

Lines 01 to 04 show that Fire incorporates a full preprocessor which allows the usual #include, #define, #if(n)def etc. directives.

Line 05 is the standard Fire method definition line, in this case for a method called open with an argument called arg of type integer. The method returns a string value. All Fire methods run in the context of an object of a minimum class, i.e. the class in which the method is defined (the "method class") or one which inherits from the method class.

Lines 07, 09 and 13 show that Fire variables have attributes -in this case, an initial value, an assignment status and a string length. Assignment status (:assigned) can be both read and set, and is particularly useful because it prevents the use of a variable before it has been assigned.

Line 08 shows that Fire variables of type object can have a minimum class as defined above which further qualifies their data type. In this case, the minimum class of the element variable is dcc in module ne.

Line 11 illustrates access to a two dimensional array called elements. Any Fire variable can be defined to be an array of any number of dimensions.

Fire has standard procedural flow of control constructs, as illustrated in the code fragment below: if-else, while, for each, for ( ), break, continue and return.

if ( boolean )
{
    while ( x < y ) {
        for each element in collection {
            for ( index := 0; : index < 10 : index += 1; ) {
                if ( condition( index ) ) {
                    break;
                }
                else {
                    if ( !otherCondition ) {
                        continue;
    }   }   }   }    }
    return ( x >= y );
}

Fire also has an expanded form of the case statement and a full set of both logical and arithmetic binary and unary operators, as well as the tertiary ?: construct found in C.

case ( complexCalculation() )
{
    = valueOne: {
        x *= ( y + 3 ) % 4;
    }
    != valueTwo: {
        x = ( y & z ) | w;
    }
    ~^ valueThree: {
        x /= ( w < 1 ) ? -w : w;
    }
    > valueFour| x > y: {
    }
    default:
    { }
}

Methods in Fire are always executed in the context of an object, which is called the method object. "Sending a message to an object" is synonymous with "executing a method in the context of an object." Some examples of method invocation are shown below:

01  close( x.y, 142 + 857, subvalue() + 3.89 );
02  close() : super;
03  [ otherObject close() ];
04  [ findObject( name ) close() : if defined ];
05  [ otherObject update(), display(), close() ];

Line 01 invokes the close method in the current object context, passing arguments x.y, 142 + 857, etc. Line 02 also invokes a close method in the current context, but the method it invokes is at a higher level of inheritance-the inherited close method.

Line 03 invokes the close method in the context of otherObject. In fact, it invokes the close method defined by otherObject or by its progenitors. Line 04 shows that the object context can itself be any expression which returns an object reference, and the if defined clause means that, if the close method is not defined, processing continues without error.

The construct shown in line 05 is a convenience; the update, display and close methods are all invoked in the context of otherObject. All return values except that of the last method invoked, in this case close, are discarded.

In addition to these syntactic constructs, the entire Camelot environment has been designed to support the object oriented paradigm, especially the principle of encapsulation.

Asynchronous Methods

Any Fire method, regardless of the language in which it is written, may be invoked asynchronously. This is illustrated in the code segment below, which invokes the update method in the context of the object referenced by the window method. update is invoked asynchronously, to start after delay seconds and to be executed repeatedly every repeat ticks.

method

startUpdate( delay integer, repeat integer, arg float ) {
    [   window()
        update( arg ) : asynchronous
        , after delay seconds 0 ticks
        , every 0 seconds repeat ticks  ]
}

Connections

Fire objects can be dynamically connected to other objects at run time, and can have many objects connected to them in turn (see Figure 2). This mechanism is useful for two reasons: first, the identities of connected objects in either direction can be determined and connected objects can be sequenced; and second, the connected objects are used for variable name space resolution. This means that, in the example below, the class C object at the lower right has access to variables W, X, Y, Z, ß and Ø directly, and any method executing in the context of this object would be able to refer to all of these variables, including W and X, as if they were defined in the object itself.

Instance Specific Methods

One of the difficulties encountered by other object oriented environments is the proliferation of classes. This happens for two reasons: the need to have all classes inherit from a common progenitor and the need to create a new class ("subclass") whenever even a small degree of specialization is required for a particular object. Fire's solution to the former is the introduction of modules, which are discussed in other sections below. The need to subclass for single instance specializations is addressed by instance specific methods, which allow specialization without the associated administrative overhead.

To understand instance specific methods we must start with an explanation of Fire's normal method dispatch mechanism (see Figure 3). Although this mechanism is optimized, it operates completely in accordance with the theory illustrated in the diagram below. All Fire objects reference a dispatch table which contains a list of methods in the order in which they were defined. The diagram illustrates an object of class C which inherits from class B which inherits from class A. The object in question has six methods defined: from the bottom up, Z, Y, super Y, X, super X and W. Let us assume that the object in this example receives a message Y. Its dispatch table is searched from the bottom up and the method defined by class C is executed.

Figure 4 shows instance specific methods Y, Z and Ø which have been added to the object in question. References to these methods are appended at the bottom of the dispatch table for the object, and when it receives a message Y it invokes the instance specific method, which is the first one found when searching the table from the bottom up. The first super invocation resolves to the method Y which was defined by class C, and the next to the method Y which was defined by class B.

Instance specific methods are a convenient way of implementing specific functionality which is only required by a single instance of an object. A good example of their use is in specifying the action of a button object on a panel, which in all probability is an action unique to that object. Of course, if the object is duplicated (e.g., to create a new copy of the window) so is the reference to its instance specific methods.

Object Repositories

The usefulness of instance specific methods is greatly increased when they are used in conjunction with Camelot's object repositories. When a Camelot object is placed in an object repository, all of the objects which it explicitly references are stored with it. This includes objects which it references directly or through collections, and those which reference the object through Fire's connection mechanism. Since Camelot's object repositories are implemented in host operating system files, they can be as large or as small as necessary, making it possible, for example, to place all of the objects which make up a window into a repository.

Camelot's object repositories are stored in both binary and machine independent forms, which means that any repository can be copied to any machine which Camelot supports. Camelot recognizes that the repository comes from a different machine and recreates its binary form, providing immediate portability.

This combination of object repositories and instance specific methods makes it possible to introduce new functionality without increasing the size of the environment as a whole. It also extends the benefits of encapsulation to a higher level by allowing the developer to ignore encapsulated functionality which does not pertain to the problem at hand. In addition, it makes distribution of new functionality a straightforward matter of copying a file from one system to another.

Modules

Object oriented development efforts are often characterized by rapid progress in the early stages, followed by increasing difficulties and, in the end, the inability to implement required functionality. This pattern is due primarily to the inheritance mechanism, which in any substantial development results in a multilayered tree which is difficult to understand and even more difficult to modify.

To circumvent this difficulty Camelot implements modules, which are higher level encapsulations of functionality. Camelot module definitions organize separate classes and methods into a self-contained unit with a well defined interface and a single objective, in much the same way that classes themselves organize data definitions and their associated methods. This means that a portion of a system can be developed and modified with a greater degree of independence.

External Code

Camelot provides a simple mechanism for declaring that functions stored in DLLs or code resources are to be treated as methods for a specified class. Although this is not strictly speaking an encapsulation feature, it does make external code appear to be defined specifically for a Camelot class. The object oriented model is maintained as far as possible in that the resultant methods are defined for their associated class and all subclasses, and can be overridden by subclasses as necessary. In addition, functions from one DLL can be associated with several different classes, and a single class can have functions from several different DLLs.

Garbage Collection

Camelot's developers maintain that encapsulation is impossible without garbage collection. In a system that is not garbage collected and in which object A refers to object B, it is necessary for object A to know when it can tell object B to destroy itself. This functionality can not be implemented by object B, even with reference counts, which suffer from isolated mutual references or "disconnected loops." It is therefore necessary for the developer writing object A to have knowledge of the system's overall architecture, which limits the size and complexity of systems which can be created to those which can be understood by a team of programmers.

Example

One way of describing such a graphical environment is used is to provide a practical example of its use. Our task will be to implement a simple panel which will convert between miles and kilometers (this example is shown and explained in Figures 5-12).

We should note here that Camelot's philosophy is to use native mode controls (buttons, check boxes, etc.) whenever possible, although the user always has the option of using a control defined by Camelot. This means that, at the user's discretion, all buttons can look the same-or that a button can look like a Macintosh button on Macintosh computers, a Windows™ button under Windows, etc. This is an option settable both as a user preference and on a control by control basis.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.