compile and classes

Posted by goo on 23-Jan-2020 16:46

11.7

I have made a compilingprogram does some compile of dirctories and files. Basically it travers a directory, finds *.p *.w *.cls and does a compile to a pregiven area. 

&scope-defined Environment Test

&scope-defined Target001 \\serverA\$D\{&Environment}\myApp

myCompile = new Compile().

myCompile:addDirectory('.\directoryA','{&Target001}\directoryA').

myCompile:addDirectory('.\directoryB','{&Target001}\directoryB').

myCompile:addCommand('.\oo\myClassA.cls','{&Target001}\oo').

myCompile:addCommand('.\oo\DataHelper\myClassB.cls','{&Target001}\').

and so on... I could have done this different, but when I did it I was not very familiar with oo. Anyway, now to my question:

if I have

myClassA.cls that is defined without namespace

class myClassA :

end.

and myClassB that is defined with namespace

class oo.DataHelper.myClassB.cls :

end.

then I have to differentiate between how I do the compile statement.  If I say compile myClass.cls save into .... it will store the class where it points to in save + the namespace.

How can I ensure that it is compiled into the area I tell it store (save into) as it is now, I have to check if the code has a namespace before I do the compile?

PS! I know I should use namespace, but there is a lot of legacy code that do not have that....

//Geir Otto

//Geir Otto

All Replies

Posted by Fernando Souza on 23-Jan-2020 19:12

I am not sure I got what you are trying to do completely, but if you are trying to get the class that has a namespace on the directory you specified with SAVE INTO without the namespace, that will not happen. When there is a namespace, we require it to be compiled with the namespace, and we will need to store the rcode in the directory based on the namespace, since that is how we will need to find it at runtime. You do want the directory structure for a class with a namespace, otherwise we wouldn't be able to find it at runtime. So not sure what the issue you are having is.

Posted by goo on 24-Jan-2020 10:12

Hi Fernando, thanks for your reply.
 
Lets say I have workingarea:
 
d:\workspace\projectA\
 
I have the following directories under projectA:
 
oo/A.cls
oo/X.cls
 
If I travers each directory I will get:
 
A.cls
X.cls
 
If I have not used namespace in the class compile à
 
class A:
 
end.
Versus
 
class oo.X:
 
End.
 
If I do
compile .\oo\A.cls save into .\oo  à This will be ok, the file is saved correct
 
compile .\oo\X.cls save into .\oo àThis will create an extra directory under oo named oo where X.r will be put.
Compile .\oo\x.cls save into .\ à this is ok
 
So I either need to be sure that all classes uses correct namespace or I need to be able to know when namespace is used in the class.
 
Did this clarify my question?
 
I would think that the best way of dealing with this, is to fix all classes that has not been given correct namespace.
 
//Geir Otto
 
 

Posted by Mike Fechner on 24-Jan-2020 10:19

Allowing classes with no package name is IMHO the biggest design flaw (maybe the only one) of OOABL.

Utilizing that is a great way of shooting yourself in the foot.

Geir, I strongly suggest you refactor your legacy:

Every class should have a package name and that must match the relative directory name

Posted by goo on 24-Jan-2020 10:54

Thanks Mike, then I will do so 😊 it is a bit work, but after struggling with this I can see that I should have used namespace a long way ago
 
//Geir Otto
 

Posted by Matt Baker on 24-Jan-2020 14:54

Otto,

Why are you not using PCT (github.com/.../wiki)  It takes care of the directory issues for you, with or without package names.  (of course I second the package name issue...always use them).

Posted by goo on 03-Feb-2020 07:19

Matt, the link is broken...

Posted by Fabio Anijs on 03-Feb-2020 08:30

Try removing the ")?" from the end of the hyperlink.

This thread is closed