Recently I was working on a project on Genetic Algorithms that required a lot of calculation and data manipulation. Therefore my language of choice was C#.

However due to my meager OOP experience my code looked very much like standard C code and (although I wrote few classes) when I needed to change some bits in the code it almost became unmanageable and gave erroneous results thus teaching me why OOP is so important. And now I want to start from scratch using bits of my code to build a easily modifiable program. And I need your help ! Please guide me how I should

**break my code in manageable classes, blocks etc**.

**I don't want code just the idea of how to break it into small parts.**

Here what my code does:

- Already defined/hard coded : A mathematical equation whose minima is to be found.
- Takes 4 inputs from user : Bit Size, Population Size, Cross Over Length, Generations.
- Generates pseudo-random bits (number of bits generated is equal to population size) of given size (bit size) and stores them in separate lists (number of list depends on the number of variables in equation provided).
- Converts the bits to decimal value mathematically manipulates the decimal to make it fit for putting in the equation and finally stores the value of the solution of the equation in another list.
- Finds the minimum solution and copies the corresponding binary value of the next generation to a new list.
- Average of all solutions is calculated.
- Below average value gets passed to the next generation (that is copied to a new list), above average values are complemented and then copied.
- The corresponding to bit strings are crossed and stored in the same list, i.e. assume bit length is 5 and crossover length is 3 and I have 2 bits as 11000 and 01111 after crossover the will look like 11111 and 01000 i.e. the last 3 digits are interchanged.
- With this new population the same steps are repeated starting from conversion to decimal and so on and so forth for the number of times the user wants.
- Finally when the iteration ends all intermediate steps etc are put in a text file as output.

Also, will using a database be better than using list?

Thanks.

This post has been edited by **Jeet.in**: 18 January 2013 - 03:15 PM