pyatcron-devel-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pyatcron-devel-list] New stuff in CVS and some answers to several quest


From: NICOLOVICI Xavier
Subject: [Pyatcron-devel-list] New stuff in CVS and some answers to several questions
Date: Tue, 13 Apr 2004 18:09:41 +0200

Hi there,

I've commited some lines of code (Julien and mine) today. Please read the CVS 
comments to now what have been changed.

And here some of the comments I have about programming in this project. 
WARNING, this is comments, not orders, if you think that I'm wrong or 
misleading everything, feel free to respond ;-)

So, here we are:

My comments about PyAtCron programming.

* Identation.
Personnaly, I use Emacs to edit source files. The version provided with FC2 
uses an identation of 4 characters (by default). Now, I do not mind using 
spaces or tabs, but as our objective is to be integrated into Fedora system 
config tools, let's use the 4 spaces identation, as it is actually in others 
system config tools.

* Algorythm in Python and coding styles.
I've found the following code in PyAtCron classes:
def getName(self):
        tmpName = self.name
        if (len (tmpName) == 0):
          tmpName = self.task.command
        return(tmpName)

Python allows us to write "smart" code, and I would prefer to see:
def getName(self):
        if self.name:
                return self.name
        else:
                return self.task.command
Smarter, huh? ;-)

Another thing, instead of having two methods to set the value of an object 
field, use a generic method. It's easier to maintain. Example:
"def activate(self)" and "def deactivate(self)" should be replaced by "def 
setActive(self,boolean)"

* Python programming
Python has some special method names for objects, which makes objects more 
Python oriented. For example, implementing the __str__(self) method for an 
object allows to directly pass it to the "print" method. This avoids doing a 
"print object.getStr()" call. I let you read the Python reference manual, 
section 3.3 "Special method names".

* Object oriented programming
What I like a lot in OO programming is the way how we can modularized a 
software. That way, having classes interface, it's easy to make changes to the 
code without impacting the rest of the software.
For that reason, when a function requires a lot of lines, it might be 
interesting to think about creating a class to embed this function code. 
Example, in the mainwin.py module. There is a *huge* bunch of code to simply 
build the "Next Run" string. What I've done is extract this code from 
mainwin.py and created a new class, "SyntacticEngine". This class expect a 
Scheduler object as parameter to its constructor and export a method that 
returns the NextRun string. Think how it could be easy then to make changes to 
this code ;-)
Note: I've found a small bug in this SyntacticEngine code. The getNextRunString 
method returns never for the following cron command: "*/23 3-8,10-12 */8 */8 
sun /bin/false"

Good evening for all of you that are in Europe ;-)

X.

This e-mail contains proprietary information some or all of which may be 
legally privileged. It is intended for the recipient only. If an addressing or 
a transmission error has misdirected this e-mail, please notify the author by 
replying to the e-mail. If you are not the intended recipient you must not use, 
disclose, distribute, copy, print, or rely on this e-mail.
We take reasonable precautions to ensure our e-mails are virus free. However, 
we cannot accept responsibility for any virus transmitted by us and recommend 
that you subject any incoming e-mail to your own virus checking procedures.







<<winmail.dat>>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]