From: Chris M. <Chr...@te...> - 2003-07-09 14:19:19
|
Hello, I make a good number of changes to the some of the base packages (esp. user) but I'm wondering whether just mucking around in the base packages is the best way to go about it. It does make upgrading a bit painful. My problem is that I'm not sure what the "right way" would be, and my other problem is that I have never (intentionally, anyway) subclassed or overridden anything. So, if anyone has some ideas about how to implement modifications in the base packages in some intelligent way (as opposed to my way) or pointers to some docs I should read, I'd appreciate it. Thanks, Chris McDaniel |
From: Mark S. <ma...@su...> - 2003-07-09 14:29:00
|
On Wed, Jul 09, 2003 at 07:58:30AM -0600, Chris McDaniel wrote: > > Hello, > > I make a good number of changes to the some of the base packages (esp. user) > but I'm wondering whether just mucking around in the base packages is the > best way to go about it. It does make upgrading a bit painful. My problem > is that I'm not sure what the "right way" would be, and my other problem is > that I have never (intentionally, anyway) subclassed or overridden anything. > So, if anyone has some ideas about how to implement modifications in the > base packages in some intelligent way (as opposed to my way) or pointers to > some docs I should read, I'd appreciate it. Chris, I think subclassing/overriding is a good way to go. This is a common technique among users of the CGI::Application package. I have never needed to do anything special when upgrading CGI::App while using this technique. The syntax should be be: package My::SubClass; use base 'CGI::Application'; ... and then just add your override methods and new methods. Scripts using the functionality may now need to refer to My::SubClass instead. I don't how painful that naming chage would be. Mark -- . . . . . . . . . . . . . . . . . . . . . . . . . . . Mark Stosberg Principal Developer ma...@su... Summersault, LLC 765-939-9301 ext 202 database driven websites . . . . . http://www.summersault.com/ . . . . . . . . |
From: Chris W. <ch...@cw...> - 2003-07-09 14:38:26
|
Chris McDaniel wrote: > I make a good number of changes to the some of the base packages (esp. user) > but I'm wondering whether just mucking around in the base packages is the > best way to go about it. It does make upgrading a bit painful. My problem > is that I'm not sure what the "right way" would be, and my other problem is > that I have never (intentionally, anyway) subclassed or overridden anything. > So, if anyone has some ideas about how to implement modifications in the > base packages in some intelligent way (as opposed to my way) or pointers to > some docs I should read, I'd appreciate it. This is a interesting point. Off the top of my head I can think of: - create a *new* package with my modifications (e.g., 'telus_user' instead of 'base_user'). This should include ALL the functionality of the original package and then any additions you have - uninstall the original package - whenever I upgrade to a new version either skip my custom counterparts in the upgrade or let them get installed and then immediately uninstall. You could also keep the old package and subclass what you need. (I'd create a new package for this as well so you're insulated from upgrades.) However you'll run into a mapping problem. That is, the 'user' action is mapped to OpenInteract::Handler::User and not OpenInteract::Handler::MyUserSubclass. So you may have to do some editing of configuration files either directly or through the global overrides. Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |
From: Andreas N. <an...@kl...> - 2003-07-09 18:56:04
|
On Wed, 2003-07-09 at 15:58, Chris McDaniel wrote: > I make a good number of changes to the some of the base packages (esp. user) > but I'm wondering whether just mucking around in the base packages is the > best way to go about it. It does make upgrading a bit painful. My problem > is that I'm not sure what the "right way" would be, and my other problem is > that I have never (intentionally, anyway) subclassed or overridden anything. > So, if anyone has some ideas about how to implement modifications in the > base packages in some intelligent way (as opposed to my way) or pointers to > some docs I should read, I'd appreciate it. Hi Chris, I saw Chris Winters already sketched a solution for a subclassing solution implementing an ISA relationship. Maybe you should consider also using a HAS A relationship. You would define a new SPOPS class with ISA Telus::User, maybe has some extra stored attributes but then HAS A base_user. There are multiple ways in SPOPS to do this with the has_a, links_to and object_link things. I like object_link the most because I think it` s the most flexible. Using this approach, you do not need to worry much about the base packages and upgrading is a snap. later, Andreas |
From: Chris W. <ch...@cw...> - 2003-07-09 20:41:17
|
Andreas Nolte wrote: > I saw Chris Winters already sketched a solution for a subclassing > solution implementing an ISA relationship. > Maybe you should consider also using a HAS A relationship. You would > define a new SPOPS class with ISA Telus::User, maybe has some extra > stored attributes but then HAS A base_user. There are multiple ways in > SPOPS to do this with the has_a, links_to and object_link things. I like > object_link the most because I think it` s the most flexible. > > Using this approach, you do not need to worry much about the base > packages and upgrading is a snap. This is an excellent suggestion for SPOPS objects. As the GoF says: "Favor object composition over class inheritance." :-) Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |