GSoC/GCI Archive
Google Code-in 2014 KDE

Find the maximum in a set of numeric strings

completed by: Techwolf

mentors: Christian Dávid

Overview

In a C++ program we use a SQL database. In some of the tables we have an id which is a strings like "CHAR0000001". Your task is to add a method which can find the maximum and returns it as an integer.

You will need some time to compile KMyMoney. The code you have to program is rather easy.

Your solution will be used by many users all over the world!

Prerequisite

You should have basic knowledge of C++ and classes. You must be willing to read a bit of the Qt documentation.

Instructions

  1. Download KMyMoney from git
  2. Compile it
  3. Add a method in MyMoneyStorageSql
  4. Upload your changes as review request on KDE's reviewboard

Your task is completed if I mark your review request "Ship it". For testing purposes I can give you a SQLite database which contains some data.

Compiling KMyMoney

You find some help in KDE's userbase (no need to perform the install step). This step is significantly easier if you are using a Linux operating system or Mac OS X with MacPorts installed. It is not recommended to solve this task on a Windows system.

The method to implement

Find a useful name for the method.

The return value must be long unsigned.

Your method must take two argument: the table name and the field of the table where the id is stored. If you want you can have a third argument which indicates the length of the prefix or contains the prefix as QString.

In the field is a string which begins with some letters (e.g. "T", "A", "OJ") followed by an integer with leading zeros (e.g. 00000001). So it is always something like "OJ000001". Within a table the prefix string is always the same.

You need to execute an SQL query (you find a lot of examples how to do that in mymoneystoragesql.cpp) to get the information you need from the defined table.

If an error occurs you can throw an exception of type MyMoneyException.

Your solution must work with SQLite. If you can, code in way that it works with other SQL databases as well.

Pro-Tip

In theory you can get your result with a single SQL query without downloading any id from the database and minimal use of C++. But you do not need to solve the problem in this way.

Publish your work

Everything is working? Well done! You can go to KDE's review board and create a new review request. The repository is "kmymoney". The developers (including me) will be notified when you published the request and we will review you work. This is the standard method of helping open source projects.

Please note in your review request that you are doing this as part of Google Code In.

Benefits for you

You will learn something about string manipulation and SQL — these techniques are used very often. Also you work in a real project used by many people around the world.

Why this is interesting for us

This task is the first step to fix several bugs including bug 339103.

Where to find help

These pages could be interesting for you (using them is not necessary to solve this task):

The projects website is kmymoney.org — you find the IRC Channel and developer mailing list there to contact me. For problems with review board you can ask any KDE developer, e.g. in the #kde-devel IRC channel. If you have questions try KMyMoney's irc channel first. If you want to contact only me, my mail is christian-david@web.de.

Have a lot of fun!