Hi,

still finding my way through the code, I really wonder about most of the
stuff in utils.py:

    * prefixing functions with 'get_' is unpythonic and should be
      removed. This "get_" is useless data, since obvious in most cases.
    * same for prefix "to_"
    * get_sequence is not used at all and should be removed -- and I
      doubt it is useful
    * "print_date" has wrong name, since it does not print.
    * For these "Pythnication" functions I really wonder if this is the
      best way.

Which leads me to properties. I still did not exactly get, what they are
since I did not find the place where they are used.

These properties seam to be very, very redundant. I Propose introducing
property classes which hold a lot of the knowledge of the object types.

        'execute_host_checks': BoolProperty(
            default=1, class_inherit= [(Host, 'execute_checks')]),
        'status_update_interval': UnusedProperty(
            'usage_text'= '...no longer used ...'),

I did a test converting the properties in config.py to this syntax.
Currently these are approx. 680 lines, the converted version is down to
approx. 260 lines. This saves 60% of code for these area!

This change would save a lot of code elsewhere, since many test could be
removed and test could be simplified. E.G. item.Item.pythonize() could
be as short as:

    def pythonize(self):
        for name, prop in self.__class__.properties.items():
            try:
                old_val = getattr(self, name)
                new_val = old_val.pythonize()
                #print "Changing", old_val, "to", new_val
                setattr(self, name, new_val)
            except AttributeError , exp:
                #print self.get_name(), ' : ', exp
                pass # Will be catched at the is_correct momen

Another benefit would be, that semantics are much clearer then. E.g.
required=True plus default-value is useless and unused properties do not
need any other value but usage_text.

What do you think about this?

If you want to go this way, I happily hand over the small utility I
wrote for converting the properties in config.py. And yes: I would do
this for 0.4, since this vastly enhances readability, understanding and
maintainability.

-- 
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult 
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/
Goebel Consult mit Mitglied bei http://www.7-it.de

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
Shinken-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/shinken-devel

Reply via email to