Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 16th, 2007, 3:40 PM   #1
verb3k
Newbie
 
Join Date: Dec 2007
Posts: 5
Rep Power: 0 verb3k is on a distinguished road
Need your comments on a PyGTK PlayStation CD backup tool

Hi all,

This is my first post and I hope I get something useful out of it.
I am new to programming and currently learning python, working on a GUI app to backup PSX games using "cdrdao" as a backend.

The program in its current state works just fine, but I can see lots of drawbacks:

1-The program is bloated and the code looks ugly.
2-No object-oriented programming was used. ( I know it's not necessary)
3-Many noobish habits and techniques were used to solve some problems.
4-The use of some shell commands instead of doing things in a pythonic way.

I want you to help me polish it and teach me how to do it the right way (and help me toss those bad techniques away)

I would also appreciate it if someone could tell me why I would want to do it in OOB, what's the benefits? what's object-oriented programming?(still struggling with this question)

Here's the code:
http://dpaste.com/hold/28221/

Note the use of the global variable avail, I am sure there is a better way, but can't come up with it.

Thanks in advance,
verb3k
verb3k is offline   Reply With Quote
Old Dec 16th, 2007, 7:20 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Need your comments on a PyGTK PlayStation CD backup tool

OOP is only beneficial from a coding perspective. You can group together alike functions, and manage variables that become global to those specific functions. So for instance, that would solve your global avail problem.

But your code doesn't really look bad. Nothing in dire need of change stands out to me... at least.

I'd only recommend OOP if you want to get away from those global references.
Sane is offline   Reply With Quote
Old Dec 16th, 2007, 9:09 PM   #3
verb3k
Newbie
 
Join Date: Dec 2007
Posts: 5
Rep Power: 0 verb3k is on a distinguished road
Re: Need your comments on a PyGTK PlayStation CD backup tool

That's a testimonial that I am really proud of indeed
But do you think it is ready for large scale use?
As I am learning python, I always ask experienced programmers to tell me things that they think will make my program better, I know my program runs fine but I also know that a wizard like you can add some magic to it

So if you have some free time and want to play with python, take my script and show me things you like to do with your scripts. I am not asking you to add new functionality or anything , just show me better ways of doing things.

Thanks for your time,

verb3k
verb3k is offline   Reply With Quote
Old Dec 16th, 2007, 10:14 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Need your comments on a PyGTK PlayStation CD backup tool

At this point, it all depends on how the code performs. Can you break the code with messing around in the GUI? Can you give the program bad input? Try to handle all of these cases.

Also, it looks like your code's specific to Linux because of some of the system commands you're using. Is cdrdao Linux only?
Sane is offline   Reply With Quote
Old Dec 16th, 2007, 10:22 PM   #5
verb3k
Newbie
 
Join Date: Dec 2007
Posts: 5
Rep Power: 0 verb3k is on a distinguished road
Re: Need your comments on a PyGTK PlayStation CD backup tool

No, it is available for win32:
http://cdrdao.sourceforge.net/
Making code portable is really interesting, but knowing that windows has many similar tools, I plan to do it only if I want to learn about portable code.

Edit: cdrdao comes with most distros by default , shouldn't be a problem for linux users.
verb3k is offline   Reply With Quote
Old Dec 16th, 2007, 11:01 PM   #6
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Need your comments on a PyGTK PlayStation CD backup tool

I don't believe any of the Linux system commands you're using are in the os module, which would handle the cross-compatilibty for you, so you'll have to do it yourself. It'll be compilable on either Windows or Linux if you set a flag that represents the OS, and reference it for each system command that's Linux only, and supply the Windows equivilent of that system command if the OS is Windows.
Sane is offline   Reply With Quote
Old Dec 17th, 2007, 9:01 AM   #7
verb3k
Newbie
 
Join Date: Dec 2007
Posts: 5
Rep Power: 0 verb3k is on a distinguished road
Re: Need your comments on a PyGTK PlayStation CD backup tool

I see...

You said:
Quote:
Originally Posted by Sane
You can group together alike functions, and manage variables that become global to those specific functions. So for instance, that would solve your global avail problem.
Can you please provide sample code demonstrating this? (I don't know how to do that)
I would really appreciate it
verb3k is offline   Reply With Quote
Old Dec 17th, 2007, 11:31 AM   #8
somehollis
Programmer
 
somehollis's Avatar
 
Join Date: May 2006
Location: Memphis, TN
Posts: 31
Rep Power: 0 somehollis is on a distinguished road
Send a message via AIM to somehollis
Re: Need your comments on a PyGTK PlayStation CD backup tool

Quote:
Originally Posted by verb3k View Post
I see...

You said:

Can you please provide sample code demonstrating this? (I don't know how to do that)
I would really appreciate it
This page has a python-focused intro into some of the ideas of OOP. I had to read it all several times before it finally "clicked", and while I understand the idea I'm still trying to learn how it helps me solve problems (i.e. write programs).

As I see it, the idea is to "hide" your code in these boxes (i.e. classes). You can give similar classes methods (functions) with the same name to simplify obtaining information. I think the example from the link above is probably best.

If we take two classes called Square and Circle, we can give them both a method called area(). Then, it doesn't matter to me if x is a square, circle, or something else. As long as it has an area method, I can just run x.area() to get that bit of info.

I feel like I'm doing a poor job explaining this, as I'm just starting to understand a lot of it myself, so maybe the link can help you more.
somehollis is offline   Reply With Quote
Old Dec 17th, 2007, 11:47 AM   #9
verb3k
Newbie
 
Join Date: Dec 2007
Posts: 5
Rep Power: 0 verb3k is on a distinguished road
Re: Need your comments on a PyGTK PlayStation CD backup tool

Thanks somehollis for the link... seems interesting!
I also am like you, I can understand the idea but can't make use of it(can't see why I would use it in my program to solve problems)

Anyway, thanks for the interesting read, much appreciated
verb3k is offline   Reply With Quote
Old Dec 17th, 2007, 11:58 AM   #10
somehollis
Programmer
 
somehollis's Avatar
 
Join Date: May 2006
Location: Memphis, TN
Posts: 31
Rep Power: 0 somehollis is on a distinguished road
Send a message via AIM to somehollis
Re: Need your comments on a PyGTK PlayStation CD backup tool

I suspect that as we grow to writing larger applications (as opposed to the little 1-trick tools that I have written and suspect that you have as well), we will find more use for OOP as an organizational tool. Of course, I could be wrong...

I wanted to play with some GUI programming, so I'm using python and Tkinter to write a little metric conversion tool. I ended up having one class for the gui and one for the actual math involved in the conversion, so I could definitely see the benefit there.
somehollis is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Backup Search grimpirate C 3 Jul 3rd, 2006 7:49 PM
Comments on comments stripper nnxion C 6 Apr 27th, 2006 9:53 AM
Backup Script :-) Pizentios Perl 18 Jan 12th, 2006 10:50 AM
interesting tool -- for webmasters? is it? H_two_O Coder's Corner Lounge 0 Oct 25th, 2005 7:26 PM
hey there.. need some comments! H_two_O Coder's Corner Lounge 1 Aug 27th, 2005 6:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:40 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC