vines
vines

Reputation: 5225

refactoring modular structures in D

Here's how I usually develop an application:

This workflow implies the need to move source files between modules sometimes. And here comes the problem:

When I move a module to another location, it changes the module's name, so I have to walk through all the other files renaming imports by hand.

Is there some organisational technique to avoid that annoying procedure? Or is that the way it goes and I just have to look into some automation utilities instead?

Upvotes: 2

Views: 147

Answers (3)

ratchet freak
ratchet freak

Reputation: 48196

you can create a *.all module that public imports all modules in the package

then you only need to add/remove the module names from that module

Upvotes: 4

Mihails Strasuns
Mihails Strasuns

Reputation: 3803

You can override module name via module packagename.modulename; directive in the beginning of the module. It will need a help from the build system though as rdmd uses module names from import statements to form file system path to search for their sources. But if you will supply all source files project consists from by hand, it should resolve module names just fine.

Upvotes: 3

faissal
faissal

Reputation: 261

It's better to define your entities before you start coding. You can use some modelling language to identify and write your entities. For example if you are using java to code your application then you can use UML to model this application.

Also, you have to separate buisness logic from data.

If you continue to do it like today you will lose a lot of time just dealing with filenames.

Upvotes: 1

Related Questions