Problem
Solving as Programming Principle: Begin with the end in mind.
Problems can
be solved by different algorithms:
First, a
solution is reached by the obvious way. Then, secondly, it is getting to the solution
by the methodological or structural way. Then, you have the “smart” way,
meaning, using clever insight into the different aspects of the algorithm,
thereby devising the best approach to the problem. I would say that this is the
best problem solving algorithm. Lastly, but not the least, is the serendipitous
way. But this last method relies almost on a hunch. Hunches are not bad at all. But the problem
with that is the inability to write the solution so as to get the right results
given different values.
Once, a young
lady came up with a question which had to do with an item that she bought at a
discounted price. She knew how much she finally paid, but did not know the
actual discount percentage. Then her older sister said that the percentage was
such and such. She just "knew" the answer but could not explain how
she got it. I, in the meantime, wrote out the equation on paper and did the
calculations by testing the algorithms I came up with. Well, I did get the same
answer as the older sister. We were both right, the difference being that I
could repeat the calculations with different variables. She, on the other hand, could not verify
her answer.
This is what
we are after, devising the best algorithm so as to be able to come up with
the ideal solution regardless of the variables, meaning, reproducible results.
We cannot rely on hunches or even educated guesses. As in evidence-based
medicine, we rely on logical, verifiable methods, taking into consideration all
the possible variations as well as mitigating circumstances. Even if one had a
eureka moment, we still have to verify the methods involved. That is the
hallmark of science- reproducible results. It is a discipline.
To code
or not to code…
Given the
conditions above, there is then the question: do I need to develop programs?
The path to this activity has six points to follow along the way. We will go
over those six points briefly.
1.) Do I need a
program for myself, for my own needs? Or for others’ needs? Question: What are
my goals? If you were to write a program for yourself, or for the department
you were working in, then you have a stronger motivation, whether or not you
were compensated materially for it.
2.) What do I hope
to achieve, or to make progress in? Think more, and think better. Considering
the path that lies along the programming road, you will do well to concentrate
on the different activities that are necessary for this task. (e.g. seminars,
classes, online training). Become a project manager at heart.
3.) Can I do it on
my own? Or, do I invite others to collaborate in the project? Feel competent!
If you must work alone, do so, remembering that your battles will be yours
alone. There are circumstances when working alone is of utmost importance.
Like, for example writing a program as part of school tests. Otherwise, there
is strength in numbers, and it would be best for the project to form some team
for collaboration. Which brings us to the next point…
4.) Equip yourself,
equip others. Study well what you’ll need. Prepare, prepare, prepare. As
mentioned before, get a good look at what you need to do to continue working strong.
And if you’re part of a team, your good insights will strengthen everybody as
well. No man is an island in this scenario.
5.) Follow set
guidelines, follow through with development milestones. Be disciplined, not
stressed out. Stick to the roadmap, and in so doing you will be avoiding
latency. In the aspect of agile development, cooperation throughout the course
will give a more holistic view, as well as strength.
6.) Give credit to
whom it is due, to others and yourself as well. This may be the most important
factor for the success of the project and the group itself. Let everybody own
the project. That way the outcome is far better than a lackadaisical product.
Reward hard work along the way.
Now that we
have laid out the rules, let’s take a look at some code which will be useful,
not just for today’s purpose, but will serve as a template if you will.
The code is
in C++, and is a snippet for converting temperature from the Centigrade format
to the Fahrenheit one, and vice versa. Use the tools we talked about in the
previous post, and which are repeated for you below.
Convert Temperatures
from Celsius to Fahrenheit and vice versa.
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int
choice;
float ctemp,ftemp;
cout
<< "1.Celsius to Fahrenheit" << endl;
cout
<< "2.Fahrenheit to Celsius" << endl;
cout
<< "Choose between 1 & 2 : " << endl;
cin>>choice;
if
(choice==1)
{
cout << "Enter the temperature in
Celsius : " << endl;
cin>>ctemp;
ftemp=(1.8*ctemp)+32;
cout
<< "Temperature in Fahrenheit = " << ftemp << endl;
}
else
{
cout << "Enter the temperature in
Fahrenheit : " << endl;
cin>>ftemp;
ctemp=(ftemp-32)/1.8;
cout << "Temperature in Celsius =
" << ctemp << endl;
}
getch();
}
---------------------------------------------------------------------------------------
Tools for
C, C++
C++ Standards
Foundation website http://isocpp.org/,
C++ FAQ from
its founder’s website http://www.stroustrup.com/
C++ Tutorials http://www.cplusplus.com/doc/tutorial/
C and C++
Programming tutorials http://www.cprogramming.com/tutorial.html
MinGW-Minimalist
GNU for Windows http://www.mingw.org/
MinGW –W64 for
32 and 64 bit Windows http://mingw-w64.sourceforge.net/
Dev-C++
(Windows, Linux) http://sourceforge.net/projects/dev-cpp/?source=directory
ARM Linux
GCC – OS X Mountain Lion (Mac, of course) http://www.benmont.com/tech/crosscompiler.html
For
Commercial Options:
Microsoft
Visual Studio (2012) http://www.microsoft.com/visualstudio/eng/team-foundation-service
Embarcadero
C++ Builder XE3 for Windows 8 and Mac http://www.embarcadero.com/products/cbuilder
-----------------------------------------------------------
Other application tools you can use:
For structural biology, check out:
COMPLEAT – Protein Complex Enrichment Analysis Tool
COMPLEAT – Protein Complex Enrichment Analysis Tool
For
statistical operations,
the R language is a really good tool.
the R language is a really good tool.
The Comprehensive
R Archive Network
R bioinformatics Packages (for
genetics)-Bioconductor
R Graph Gallery
A collection
of graphics entirely generated with R.
R Projects of interest
Good Read:
Science
Magazine online http://www.sciencemag.org/
Stay Curious. Stay Busy.
Fernando Yaakov Lalana, M.D.
Fernando Yaakov Lalana, M.D.
No comments:
Post a Comment