VIDISONIC

Hardware & Software Design Resources

Artificial Neural Network Shell: A Case Study of Object Oriented Concept in Old Style Structured Programming Practice

Background
People who familiar with structured programming style and not yet with object oriented programming (OOP) style often think that OOP is useless for them, because almost everything done with OOP can be done with old-structured style. In my opinion, they insist to use their old style programming is not caused solely by not understanding OOP concept and practice, but also because they are not familiar with advanced programming with their own structured style.

The Case
If they have long experience in structured programming, I believe that they should have implemented the concept of OOP, although they don’t realize it. Let’s study a case when we have to implement a complex software using traditional structured style: a back-propagation neural network shell.

Let’s define the requirement of the shell:

  1. The number of layer is configurable
  2. The number of neuron on each layer is configurable
  3. The activation function on each layer is configurable
  4. The learning rate of the network is configurable
  5. The whole system can be arranged from many neural network subsystem, which each subsystem has the properties defined in requirement 1, 2, 3, and 4 independently configurable.

When we look at the requirement no. 1-4, you can implement the coding the source code in structured style easily. Think about no. 5 requirement, now you’ll realize that the work will be much complicated.

Implementation Using Functions and Structure
The modular requirement of the software force you to think about object concept in your mind, because each module can be viewed as one class with different property values. Let’s go to code in structured style: use functions and structures.

Lets make a function called CreateANN:

CreateANN(ANN_STRUCT* ann_object, int number_of_layers, int* size_each_layers)

A structur ANN_STRUCT is needed to manage the variables used in the network, and the function CreateANN initialize all variables in the ANN_STRUCT instance. The function CreateANN is similar to constructor in the OOP concept.

After initialization, you can create many functions to operate the neural network. Look at some functions examples you can create:

  • TrainTheNeural Network(ANN_STRUCT* ann_object, double* input_pattern, double* output_pattern, double minimum_error, int max_number_of_iteration)
  • GetNeuralOutput(ANN_STRUCT* ann_object, double* input, double* output)
  • SaveTheWeightToFile(ANN_STRUCT* ann_object, char* file_name)

You can see that these functions are similar to class’s method/function members in OOP concept. Using functions and structure, now you can build a modular artificial neural network by cascading the networks, feeding one network’s output to other network’s input. Let’s stop talking about neural network because this article is not intended to show you how to code a neural network, only just to show that the old structured programming style practice, when facing a complicated task, should have been common to implement something close to OOP concept.

Conclusion
Studying the case of a complex software design, we can see that the concept of object oriented programming can be found on traditional style practice. I hope everyone can now understand and take the benefit of object oriented programming style. Use the OOP technology, and now you’ll be more productive and your life would be easier. (Hamuro)