LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-16-2008, 01:16 PM   #1
autophil
Member
 
Registered: Jun 2006
Location: Macclesfield Canal, East Cheshire
Distribution: Salix-14.1
Posts: 129
Blog Entries: 1

Rep: Reputation: 15
Clock app


Im not a programmer and I have a kind of basic knowledge of Linux systems. I would like to know how to build a small application that will allow me to open up a window with say 3 clocks in it - digital or other wise - each showing a diffewrent time. Like for example GMT, GMT +2 and GMT +7.
Maybe there are downloadable programs out there that can do this. But for my own ambitious self, How could I go about doing this. Sort of a learning project? I mean is it possible or do you really have to become a pc boffin?
Any pointers in the right direction would be very much appreciated!
Phil
 
Old 09-16-2008, 01:54 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
Quote:
Originally Posted by autophil View Post

But for my own ambitious self, How could I go about doing this. Sort of a learning project? I mean is it possible or do you really have to become a pc boffin?
Any pointers in the right direction would be very much appreciated!
Programming is a fairly complex skill. I have never heard of anyone who wrote a reasonably complex program while learning how to program. I suggest that you learn how to program first and then write your time zone program after you have mastered programming basics.

--------------------
Steve Stites
 
Old 09-16-2008, 03:44 PM   #3
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
Actually, this sounds like quite a good learning example to me.

Writing a clock is fairly complex; you have to update the display continuously and re-calculate the position of the hands and so on. And writing three at once could be worse than three-times as difficult if you're not careful. But it is also a well-defined problem, and it's not so big as to be totally unrealistic.


But one principle that it's good to learn early on in software is that of code re-use.

* It is usually better to modify an existing program to perform a task than to create a whole new program from scratch.

* Provided you can find suitable libraries, you can build your program using the libraries and get a working result much faster; in doing so, you are also likely to find problems in the library that, when fixed, may will fix problems with other programs the library is used in too.

* More generally, when you write your code in a modular fashion, you will find that there are many fewer side-effects to changing any one bit of code, resulting in fewer bugs, faster program development, and easier testing and profiling. You may also find that parts of your program naturally lend themselves to being used repeatedly. Keep things in small units (typically objects), each with a well-defined purpose and as simple an interface as you can get away with.


I would start by choosing a language: C++ is very good for teaching you about object-orientation, memory management, and accuracy in programming (just make sure you find a good modern book to learn from!). Java is good as a graphical language, with support for threads and powerful error-detection, but can be difficult to learn at first since there is no obvious place to start. Scripting languages like Python can also be useful since they tend to have a simpler syntax and so a less steep learning curve. You should probably research these in more detail.

Next, set yourself some milestones. I would suggest getting a simple, functional-but-ugly digital clock done first, just showing the current time, not even updating. Take it step by step: give it an offset that you can pass into its constructor. The next milestone might be making it update. Then make there be three instances with different times. Then go back and work on the user interface; make it a pretty graphical clock or whatever you want it to look like. Or change the order of these milestones around, but try to build it up in well-defined stages. You can always change these stages as you work through your project.

Now find yourself some teaching materials. I tend to talk about books, but it's the quality of the explanations that matters; blogs and tutorials can be just as good. Read reviews before you read the text. Don't get a book just because it comes with an integrated IDE or a Visual Development Tool that makes things easy; tools just as good as these are freely available online or with your favourite Linux distribution. Go for a book that talks about what you're doing on your first milestone – any good book will tell you how to find out what your programming language can do, and the first stages are slowest since you are learning a lot, so you should use all the help you can get.

Finally, if you get stuck, ask questions: even if your problem seems embarrassingly simple. You will be surprised at what you can learn from getting a second viewpoint on the subject. And that doesn't just apply to programming.

Hope that helps, and do let us know how you get on!

—Robert J Lee
 
Old 09-16-2008, 04:55 PM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
From no programming experience writing graphical applications is a big step. That is why most beginner programming tutorials focus on getting output to a terminal.

I don't want to recommend this as an introduction to programming but the Qt examples have a clock, which is pretty close to what you are after. However if you are determined to achieve the program that you outlined then you may want to look at the Qt tutorials but they do assume a certain level of comfort with C++. This would be a rocky and frustrating journey but there are a number of people here who will help you.
 
Old 09-16-2008, 06:59 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
There's some examples with src code here: http://tnemeth.free.fr/projets/xapps.html
 
Old 09-16-2008, 11:48 PM   #6
autophil
Member
 
Registered: Jun 2006
Location: Macclesfield Canal, East Cheshire
Distribution: Salix-14.1
Posts: 129

Original Poster
Blog Entries: 1

Rep: Reputation: 15
OK I get the point. But Im going to follow up on this.
My thinking is: Its very easy to bring up an xclock, digital or analogue with different colours just using bash commands. So could it not be possible to bring up three of these in one window with one command. Displaying different times of course.
Phil
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
System clock correct, hardware clock wrong karlovac Linux - General 5 01-16-2009 07:19 PM
Failed to set system clock to hardware clock jrtayloriv Linux - Newbie 2 09-25-2008 07:06 AM
Slow system clock and stray hardware clock, pleas help! Epox Linux - General 6 01-02-2007 02:43 PM
determining clock cycles for running app true_atlantis Linux - Software 0 06-14-2006 03:56 PM
Linux OS Clock/Timezone shows the clock off by 6 hours between OS's JBailey742 Linux - Software 9 04-06-2006 11:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration