[ARCH] split large files into modules -> feasible?

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
doia
Posts: 251
Joined: Sat May 29, 2021 5:47 am
Location: Düsseldorf

[ARCH] split large files into modules -> feasible?

Post by doia »

Hey,
I try to do a deep dive into the ARCH WB in preparation for some bug fixing and feature adding to the Arch Axis system.

Reading the outlined Code conventions in Mod/Draft/coding_conventions.md (Mod/Arch/coding_conventions.md references these) I want to ask how well it is received, if I split the ArchAxis.py package into a folder with multiple files. ArchAxis.py exceeded past 1600 LOC and is hard to read.

I would split it into the following package structure, similar to the package structure within Mod/Draft:

Code: Select all

archaxis (folder)
- __init__.py
- axis.py
- axis_system.py
- grid.py
I just wanted to ask upfront to not waste time on things which will not be well received.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: [ARCH] split large files into modules -> feasible?

Post by bernd »

Yorik would be needed here.

AFAIR we had a disscussion about changing Arch code structure the same way like Draft but it was decided to not do it for Arch.
User avatar
doia
Posts: 251
Joined: Sat May 29, 2021 5:47 am
Location: Düsseldorf

Re: [ARCH] split large files into modules -> feasible?

Post by doia »

bernd wrote: Sun Oct 03, 2021 12:38 pm AFAIR we had a disscussion about changing Arch code structure the same way like Draft but it was decided to not do it for Arch.
I found the corresponding discussion under [Discussion] Splitting Draft tools into their own modules.

I agree with Yorik's reservation against splitting Arch in the same way as Draft. This would spread e.g. the ArchAxis code over multiple folders.

But on the other side the current ArchAxis.py file contains code of three semantically different objects (yet belonging to the same encapsulation concept) and is with 1600 LOC just too long. It needs to be split up to make it more maintainable. The same holds for other Arch objects.

Instead I would propose a more Domain Driven approach in keeping code which belongs to a specific domain together in a specific module. So the archaxis/arch.py file would include the the Axis class, the Command class, the ViewProvider and the TaskPanel code. On a later stage specific IFC code related to ArchAxis could be located here too. Code related to AxisSystem would go into archaxis/axis_system.py and so on.

I ping Yorik here to ask for his opinion.
Yorik wrote:
User avatar
doia
Posts: 251
Joined: Sat May 29, 2021 5:47 am
Location: Düsseldorf

Re: [ARCH] split large files into modules -> feasible?

Post by doia »

Or maybe just split the current ArchAxis.py into ArchAxis, ArchAxisSystem and ArchGrid. And get rid of underscore classes.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: [ARCH] split large files into modules -> feasible?

Post by bernd »

I would even move the whole disscussion into Arch development section to get more attraction. Do you agree?

I fully agree 1600 code lines are way to long. You may have a look at FEM too. Despite I do fix here and there some Arch code (mainly IFC) I have not spent much time in the splitting of Arch code.

We splited the code years before Draft did it and we have very good experience with the splitted code.
User avatar
doia
Posts: 251
Joined: Sat May 29, 2021 5:47 am
Location: Düsseldorf

Re: [ARCH] split large files into modules -> feasible?

Post by doia »

Yes please, if you could move this thread to the Arch sub-forum.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: [ARCH] split large files into modules -> feasible?

Post by bernd »

done, see if we get more input here ...
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: [ARCH] split large files into modules -> feasible?

Post by carlopav »

I confirm that FEM code was one of the most important source of ispiration for @vocx project to split Draft code (I just did the dumb boring work).

On the opposite of how Draft looked at the time, Arch seems really more tidy: in the old Draft module we had files with more than 7000 lines of code, with objects and viewproviders inside, etc.

Even so I think we can benefit of some splitting and what you proposed of "just splitting the current ArchAxis.py into ArchAxis, ArchAxisSystem and ArchGrid" seems good to me, cause it doesn't change the workbench structure too much, and has more chance to be approved by yorik.

One thing that I didn't like much in the restructure of Draft is that we changed many functions name from CamelCase to snake_case, so now - beacuse of backward compatibility - we have both. Except of that i really feel more comfortable with the splitted code.

(there is still something that remained to be tackled when @vocx leaved the forum after a discussion with @Zolko: some modules like DraftGui were not treated by the splitting... so there is still work to do in that field I guess)

Edit: PS Sorry for not having replied before even If I saw the topic, but at the time we splitted Draft there has been some hard opposition by several users and I didn't want to light the fire another time.
follow my experiments on BIM modelling for architecture design
User avatar
doia
Posts: 251
Joined: Sat May 29, 2021 5:47 am
Location: Düsseldorf

Re: [ARCH] split large files into modules -> feasible?

Post by doia »

Yeah, I've read the discussion thread and found the end rather "disturbing". That escalated quickly.

I analysed the Draft and Arch module structure and personally, I wouldn't split Arch in the way Draft was done. Draft seemed to be split from a programmers point of view using a Model-View-Controller (MVC) approach, where code of a semantically functionality is split between different folders just to separate basic code from GUI related code.

As written above, I'd rather use a more Domain Driven approach, where semantically encapsulated code is near by each other. Is anyone of you familiar with the term/concept of DDD?
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: [ARCH] split large files into modules -> feasible?

Post by carlopav »

doia wrote: Mon Oct 04, 2021 1:32 pm As written above, I'd rather use a more Domain Driven approach, where semantically encapsulated code is near by each other. Is anyone of you familiar with the term/concept of DDD?
I'm not, but I looks like you got perfectly the sense of Draft splitting.

Independently on how this will go further (and I admit I do not have the skills to asses if a code architecture is better than another), I guess that from a newbie point of view it is important to try to be as much consistent as possible, at least among the core modules... And that's why I still think that having Draft similar to FEM is a positive result.
follow my experiments on BIM modelling for architecture design
Post Reply