Cogitas Blog:
Google Android,
Common Lisp,
programming
and web design.

Fibonacci sequence in Common Lisp – the power of Lisp recursion

Filed under: programming — Tags: , — April 15, 2011

As I’m currently studying for a BSc in Mathematics with the Open University and I am trying to teach myself Common Lisp, I decided to try and create a function that outputs the Fibonacci nth element. Here it is, I think is a nice example to illustrate how recursion works in Lisp.
(defun fibonacci (n)
    (cond
        ((> n 1) (+ (fibonacci (- n 1)) (fibonacci (- n 2))))
        ((= n 1) 1)
        ((= n 0) 0)
        (T (print "invalid number"))))

Create an Application class in Google Android

Filed under: programming — Tags: — January 3, 2011

Up until a few months ago, I never created an Application class in Android because I didn’t see the need, after all Android manages all that, right? Then I realised I had a lot of duplicated code in my onCreate() methods for my Activities.
(more…)

Test tool for your regular expressions

Filed under: programming — Tags: , — December 15, 2010

While trying to understand why \b@ wasn’t matching all words starting with @, I came across this Regular Expression Tester and it helped me work it out. So if you’re stuck, get in there, and make sure to use the “replace with” field so you can actually see matches.

In my case, I needed to match \B@ instead of \b@ (non-word boundary instead of word boundary).

Apps World Conference, Day 1, London

Filed under: programming — Tags: , , , , , , , , — December 1, 2010

Yesterday, I attended the first day of Apps World in London and it was very interesting. I did spend a lot of time in the Developers’ Corner and was inspired in particular by two talks.
(more…)

Reflections on literate programming

Filed under: programming — Tags: , , — November 16, 2010

For those unfamiliar with Literate Programming (LP), this is a style of writing programs, invented by Donald Knuth, with the purpose of writing better documentation. The way to do this, according to Donald Knuth, is to consider programs to be works of literature.
(more…)

For complete novice Linux users – create a python script to start your browser with your favourite sites loaded in

Filed under: programming — Tags: , , , — November 5, 2010

If you’re like me and check the same sites every day, it gets frustrating to go to them each time. Sure, Google Chrome makes it easy by showing you the top 8 sites you have visited the most recently but still, you have to open a tab and click on the site, for each site you want to view. So I thought – can I create a script to do this for me so I only have one thing to click on whenever I want to check my emails, my facebook, my blog, my google reader and a couple of other sites I regularly check?

(more…)

Exactly, what does a programmer do?

Filed under: programming — Tags: — August 28, 2010

Recently, I got asked “exactly, what does a programmer do?”. This question came about when I explained that I had just registered for a BSc in Mathematics from the Open University (this confused that person, who thought I spent all day coding apps for Google Android).
(more…)

The joy of agile development and small iterations

Filed under: programming — Tags: , , — July 17, 2010

Ah, the joy of agile development and small iterations :-) The joy to complete a step (iteration), thus providing the satisfaction of a job well done, thus motivating the developer(s) for the next step (iteration).

At the start of the week, I embarked on a new programming project, a desktop app that will help you plan projects to reach your goals, coupled with a calendar (the app is written in Java, and once finished, the code will be released as open source and the app will be available for free, using the donationware approach).
(more…)

Donationware desktop Planning Tool coming soon

Filed under: programming — Tags: , , , — July 12, 2010

I’m working on a planning desktop app loosely based on Steve Pavlina’s The Meaning Of Life: From Purpose To Action associated with a calendar.

The app is developed in Java so it will be cross-platform and I plan to release it as donationware (eg it will be free but I will ask you to consider making a donation).

I will be using an agile development process, with many small iterations (one month long). I started yesterday on development and the first iteration should be done in exactly one month.

Not only the app will be donationware – which means fully free to use even though users are asked to consider making a donation to ensure I can put resources into further enhancements to the app – but also open source. This is an experiment with the donationware model as a possible long term solution for open source developers (we need to eat too ;-) )

Top 5 object programming commandments

Filed under: programming — Tags: , , , — May 16, 2010

This is my list of coding & design principles I remind myself of whenever I feel coding my app is getting too complicated. Essentially, this list helps me apply the principle of orthogonality.

1. Stop repeating yourself – reorganise your object(s) so that you don’t find yourself copying/pasting chunks of code.

2. What does your method do? If it does 2 things, it should be 2 methods.

3. Private is good – you wouldn’t show your underwear to anybody in the street, don’t show your variables and methods unless you have to.

4. Isolate your constraints – keep them all in a method called “initialise()”, which you can call from your constructor (or from onCreate() if you’re programming from Android).

5. Isolate your input & output methods – do not add any logical app code to them, only input/output processing code specific to the input/output media you have chosen. This way, you can easily add that “save to file” functionality later on.

Older Posts »