From: Bob Hutchison Date: 2001-12-07T05:00:04+09:00 Subject: [ruby-talk:27737] Re: Package Naming Hi, You are mostly right, I think, but there are at least two bits you've missed that I can think of right now. One is where a class is named explicitly, e.g. "com.foo.MyClass myClass = new com.foo.MyClass();". The other is that you pretty much have to change all the package's clients at once -- it isn't generally possible to change one client at a time. This is because of the class location rules, and that com.foo.MyClass is different than com.bar.MyClass in java, even if you know they are the same java doesn't, and so compilation, or I suppose loading, fails. Now, having said all this, I've done it many times. You just have to be careful. If you are careful, and lucky, it might be as simple as a short script -- I've certainly had occasions where it was that easy. What I've found even more difficult is splitting a package into two or more packages. This really is a refactoring job. I'm not aware of a good way to do it in java. I also don't think it has a lot to do with the naming convention. Do I understand what this discussion is about? There appears to be a concern with using the java naming convention in Ruby. I don't think this is the problem. Breaking a module into smaller modules is going to happen no matter what the naming convention is -- can Ruby deal with that? Renaming a module, and moving a module are going to happen too -- can Ruby deal with those? What we might want to avoid in Ruby is having the module name, module location, and the type names in the module quite so tightly bound. The ideas behind XML namespaces might help here to some degree. It is painless in Eiffel (where location, module/cluster name, and type names are all independent) -- there might be something useful there. I still think I'm missing the point of this discussion. Cheers, Bob On 01/12/06 1:28 PM, "Bill Kelly" wrote: > > From: "Rich Kilmer" >> >> 3) Name your packages after your company domain and product (like >> sun told us to) > >> 5) Change the name of the company (and domain) (major refactor) > >> 6) The library is finally updated to use the standard convention of >> "com.domain.libraryname.classname" (major refactor) > > Just curious, wouldn't a one-liner such as > > find . -name "*.java" -exec ruby -i -pe 'gsub(/(import\s+com)\.foo/,"\1.bar")' > {} \; > > to change all "import com.foo..." to "import com.bar..." pretty > much handle all of the package renaming? (Or am I missing some > aspect of it?) > > (OK whoops I forgot about the 'package' declarations, but we > should be able to change the gsub to > > gsub(/((?:import|package)\s+com)\.foo/,"\1.bar") > > and still keep our one-liner :-) > > > Regards, > > Bill > >