[Freeipa-devel] Why do we have so much duplicated code?

John Dennis jdennis at redhat.com
Wed Jan 27 18:32:30 UTC 2010


On 01/27/2010 06:00 AM, Jason Gerard DeRose wrote:
> On Tue, 2010-01-26 at 18:55 -0500, John Dennis wrote:
>> I constantly find identical code spread across multiple files. Is there
>> a reason for this code duplication? (Perhaps trying to keep import name
>> spaces isolated?)
>>
>> It seems to me code duplication is bad software practice for obvious
>> reasons.
>>
>> If there isn't a compelling design justification for the duplication can
>> we start moving some of this stuff to common libraries?
>
> John, where's the duplication you're talking about?  We know there's a
> lot of lingering duplication between the legacy code from v1 (ipapython,
> the installer) and the new plugable v2 code (ipalib, ipaserver).  We've
> slowly been migrating away from this legacy code, but the process
> obviously isn't yet complete.
>
> AFAIK, there isn't really any duplication within the v2 code itself, but
> if you've spotted some, I'd like to know about it.

Well, you've helped answer one question, ipapython is deprecated, I 
didn't know that, what else is deprecated?

Is the contents of the source tree documented somewhere so one can tell 
what's supposed to be imported by what, what's the target goal, etc?

This isn't a complete list, just off the top of my head:

Duplicate functions:

client_auth_data_callback()
     ipapython/nsslib.py
     ipaserver/install/cainstance.py
     ipaserver/install/certs.py
get_fqdn()
     ipalib/util.py
     ipaserver/install/installutils.py
get_gsserror()
     ipapython/ipautil.py
     ipaserver/ipautil.py
get_serial()
     ipalib/plugins/cert.py
     ipalib/plugins/service.py
needs_base64()
     ipapython/ipautil.py
     ipaserver/ipautil.py
openLocked()
     contrib/RHEL4/ipachangeconf.py
     ipa-client/ipaclient/ipachangeconf.py
realm_to_suffix()
     ipalib/util.py
     ipapython/ipautil.py
     ipaserver/ipautil.py
unwrap_binary_data()
     ipapython/ipautil.py
     ipaserver/ipautil.py
utf8_encode_value()
     ipapython/entity.py
     ipaserver/ipautil.py
utf8_encode_values()
     ipapython/entity.py
     ipaserver/ipautil.py
validate_host()
     ipalib/plugins/host.py
     ipaserver/plugins/join.py
wrap_binary_data()
     ipapython/ipautil.py
     ipaserver/ipautil.py

Duplicate Classes:

class CIDict
     ipapython/ipautil.py
     ipaserver/ipautil.py
class IPAChangeConf
     contrib/RHEL4/ipachangeconf.py
     ipa-client/ipaclient/ipachangeconf.py
class SSLFile
     ipalib/rpc.py
     ipapython/ipasslfile.py
     ipapython/nsslib.py

Logic for HTTP requests duplicated in:

nsslib.py
rpc.py
cainstance.py
ipapython/dogtag.py
plugins/dogtag.py
certs.py

-- 
John Dennis <jdennis at redhat.com>

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/




More information about the Freeipa-devel mailing list