Package Design


Table of Contents

  1. Version Information
  2. How the package is designed
  3. Design Patterns
  4. How the Parser is constructed?

Version Information

Version 1:

  1. Supported Parsing of Numbers, operands, Variables, constants, and Fixed Functions. The last sub version of this series was 1.3. It was never published since all versions were Beta.

  2. Variable Names And Function Names can be constructed using letters and numbers plus spaces. For example:
            Variables or Function names can be:
     

    SpaceAvailable SpaceValue
    PowerWood SupplyHussam Almulhim

     

    Variable and function names are case Insensitive.

     

  3. The parser or expression reader use to read most operand signs such as {+ - * / ^ }

  4. The parser supported most basic functions such as Abs(), Min(), Max(), Log(), Exp(), etc...

  5. This Design and implementation of the package took around 2 to 3 weeks of developing.

 

Version 2:

  1. Supported Custom and Dynamic Functions. Functions can be dynamically created inside the parser. The parser recognizes new Functions and asks for their definition. You can experience this using the applet at the 'New Formula Sheet' Mode. Enter any Expression and use a new function, for example, write:

                100 * test ( 5 )

    After you press enter, the parser will ask for the definition of the new function in the second table. Notice that the function test() uses one parameter. Write this definition for example:

              size ^ min(size, 3)

    The answer of the first expression will be : 100 * test ( 5) >>>> which equals to (substitute (size) with 5:
                100 * (5 ^ min (5 , 3)) >>>>> 100 * 125 >>>> 12500.

    Test it in the Applet.

  2. Logical Operators and Operands were added, such as { & , | , = , < , > } and more.

  3. The last sub version was 2.7 which is published can be tested here. The package had most functions, and operands and operators.

  4. Arabic Support was added to the package. Now you can write Arabic Functions and variables such as:

                    إذا (سرعة السيارة > سرعة الطيارة ، سرعة الطيارة ، سرعة السيارة - سرعة الطيارة) انتهت المعادلة

    Translation:

                    IF ( Car Speed > Plane Speed , Car Speed , Car Speed - Plane Speed )

  5. The Arabic upside down Comma was added to the parser.

 

Version 3:

  1. The package supported optimization techniques. Expressions such as : (1+ 4 * 7 + x) are compiled to be 29 + x. Compilation takes more time. However, Runtime can be faster more than 4 times the previous Version.

  2. The Dynamic Function factories were changed and the implementation of the factory methods were changed. The new implementation is a lot faster than the previous implementation of custom function factories. After some experiments, the new Version has of set all records in calculation speeds. This is because Dynamic Function Factories uses models to create new functions unlike the old technique. The old technique use to reparse the expression each time a new Custom Function is needed. The insertion of the technique required a significant change in the Operation API. You can see the difference between Class Operation V2.7 and Class Operation in V3.0.

  3. The Logical Equal Sign was changed from '=' to '==' to support assignment operator. see next entry. 

  4. The assignment Operator was added to the package. Now you can assign values to Variables using the '=' sign. For Example you can write this:

                    x=10, y=90, c=x+y,

    Ofcourse the result of this operation will be c = 100.

  5. The OperationGroup implementation was changed to support the chain of commands as in a programming language. Now you can add statements that will be evaluated consecutively. Statements are separated by a comma, or un upside comma.

  6. While loop was added. It can be used in the form :

                while ( boolean , operation )

    Usually the operation would be a group of operations. Take this example:

                x=0, y=0,
                 while ( x  + y < 40,  { 
                                    x = y +3,
                                    y= x+4 ,
                                    total = total + x / y,
                               }
                  ),
                    total,


    we want the value of (total). The execution will return always return the value of the last statement. That is why you should insert the (total) variable at the end of the program. 

 

Back to Top

How the Package is Designed?

See Documentation. This entry is under construction.

Back to Top

Design Patterns

16-8-1426

The code uses many kinds of design patterns in OOP. For example, the Factory pattern is used in the OperatorFactory interface. The Decorator pattern is used with all operation classes like Variables , Constant, Function, ConstantNumber, Operator, etc. The Proxy Pattern used in the OperationProxy class. Singleton was used in the OperatorFactoryDB class. Moreover, some classes implements many patterns such as OperatorSource classes, they are treated as proxies and decorators at the same time!

 

I will write more in the near future.

Back to Top

How the parser is constructed?

Under construction.

Back to Top


Hussam Almulhim
Copyright © 2005  Almulhim. All rights reserved.
Revised: 08/28/26.