473,324 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Structuring larger applications - ideas

iv
Hello,

I'm busy with a large application and feel it would eas my work if I
can specify dependencies on the granularity of packages, rather than
modules and classes. Eg:

- By convention I do the one class per file thing. SO in python this
means one class per module - naming classes after their modules. (this
helps with version control, and several other little irritations, for
example)
- I'd like to specify once for a _package_ that it depends upon another
_package_.
- The following should then also be true for a module A in package X
(which depends upon package Y):
1) X should be available in the namespaces of module A (in fact for
all modules in X)
2) X.B should refer to X.B.B (I name classes after their modules).

(2) Can be done easily by, eg putting the following in X.__init__.py:
from B import B

What's the feeling in this group about the idea & plans to get closer
to accimplishing it?

-i

Jul 19 '05 #1
4 1491
iv@lantic.net wrote:
I'm busy with a large application and feel it would eas my work if I
can specify dependencies on the granularity of packages, rather than
modules and classes. Eg:

- By convention I do the one class per file thing. SO in python this
means one class per module - naming classes after their modules. (this
helps with version control, and several other little irritations, for
example)
- I'd like to specify once for a _package_ that it depends upon another
_package_.
- The following should then also be true for a module A in package X
(which depends upon package Y):
1) X should be available in the namespaces of module A (in fact for
all modules in X)
2) X.B should refer to X.B.B (I name classes after their modules).

(2) Can be done easily by, eg putting the following in X.__init__.py:
from B import B

What's the feeling in this group about the idea & plans to get closer
to accimplishing it?


My two cents: one of the advantages of a language like Python is that the
project reaches an unmanageable size more slowly than in many other languages.
As such, be wary of "importing" conventions you have used in other languages.
Many will apply, some will not.

IMO, the one-class-per-module is a convention that in and of itself doesn't add
much value (it drove me crazy in Java), and only accelerates your project
towards being tough to manage - you don't want to artificially introduce
complexity. If two classes are inherently tied together and closely related, is
there an advantage to forcing them to live in separate files? The costs of doing
so include manually tracking a relationship that would normally be implied and
obvious, keeping file versions in synch (seems like this makes version control
harder), and some extra code to bring them into each others' namespaces.

Much like a class encapsulates many details and pieces of functionality into a
larger, more powerful building block, a module often does the same thing on a
larger scale (and a package on an even larger one). So if it makes sense in a
few cases to restrict yourself to a single class per module, go for it, but I
don't see the value in adopting it as a convention (maybe I'm missing something?).

As for inter-package dependencies, what problem are you trying to solve? If you
are trying to track dependencies for documentation purposes, you could just
write a script to walk the source tree and detect the dependencies - it is
information contained in the code itself, so rather than tracking it manually,
you could just "ask" it. If you are trying to organize the overall structure of
the project, then the consumer of that info is likely to be a person, so a piece
of paper, a whiteboard, or a big fat docstring might be a better suited home
for it.

-Dave
Jul 19 '05 #2

I know my foreign (to python) one class per module idea is what makes
life more difficult for me here. And there is an argument to be made
out that it is a stupid remnant I stick to from having used it in other
programming languages (do I have to admit C++ in my background?) Two
small examples of where it it useful for me: my development
environment is run by make to a large extent. Many standard UNIX tools
have the intelligence to deal with filenames, and if you know a file
corresponds to a class, you have a lot more info available in your
makefile. Also, if I use my version control software (currently gnu
arch) to see what's changed, for example, I get a list of changes files
which again gives me more info because I know a file corresponds to a
class.
So, I can do a number of such small things using that convention that
works well with standard old UNIX tools. And I find that valuable.

As for the dependencies- I'm trying to keep the specification of them
simple. From a design point of view, it makes sense to me to only
specify ONCE that largeish-collection-of-classes-A depends on
largeish-collection-of-classes-B. As another simple small example: say
I change the name of large-collection-of-classes-B - this way I only
need to do it once, else I need to grep and sed all over in order to do
it.

It just feels cleaner and easier.

I know essentially, if you stick to having many classes in a python
module, you have what I referred to in the previous paragraph, because
you can stick to importing other modules at the beginning of a module
and so have them and their contens available in the entire file.

Still, I'm investigating whether I can bend the ever-so-flexible python
to work well with my admittedly somewhat strange requirement. And, off
course, I'd like to hear what others think.

-i

Jul 19 '05 #3

I know my foreign (to python) one class per module idea is what makes
life more difficult for me here. And there is an argument to be made
out that it is a stupid remnant I stick to from having used it in other
programming languages (do I have to admit C++ in my background?) Two
small examples of where it it useful for me: my development
environment is run by make to a large extent. Many standard UNIX tools
have the intelligence to deal with filenames, and if you know a file
corresponds to a class, you have a lot more info available in your
makefile. Also, if I use my version control software (currently gnu
arch) to see what's changed, for example, I get a list of changes files
which again gives me more info because I know a file corresponds to a
class.
So, I can do a number of such small things using that convention that
works well with standard old UNIX tools. And I find that valuable.

As for the dependencies- I'm trying to keep the specification of them
simple. From a design point of view, it makes sense to me to only
specify ONCE that largeish-collection-of-classes-A depends on
largeish-collection-of-classes-B. As another simple small example: say
I change the name of large-collection-of-classes-B - this way I only
need to do it once, else I need to grep and sed all over in order to do
it.

It just feels cleaner and easier.

I know essentially, if you stick to having many classes in a python
module, you have what I referred to in the previous paragraph, because
you can stick to importing other modules at the beginning of a module
and so have them and their contens available in the entire file.

Still, I'm investigating whether I can bend the ever-so-flexible python
to work well with my admittedly somewhat strange requirement. And, off
course, I'd like to hear what others think.

-i

Jul 19 '05 #4
"Iwan Vosloo" <iv@lantic.net> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...

I know my foreign (to python) one class per module idea is what makes
life more difficult for me here. And there is an argument to be made
out that it is a stupid remnant I stick to from having used it in other
programming languages (do I have to admit C++ in my background?) Two
small examples of where it it useful for me: my development
environment is run by make to a large extent. Many standard UNIX tools
have the intelligence to deal with filenames, and if you know a file
corresponds to a class, you have a lot more info available in your
makefile.
Have you looked at using scons (http://www.scons.org/) instead
of make?
Also, if I use my version control software (currently gnu
arch) to see what's changed, for example, I get a list of changes files
which again gives me more info because I know a file corresponds to a
class. So, I can do a number of such small things using that convention that
works well with standard old UNIX tools. And I find that valuable.
Sometimes little conveniences lead to great big tar pits.
As for the dependencies- I'm trying to keep the specification of them
simple. From a design point of view, it makes sense to me to only
specify ONCE that largeish-collection-of-classes-A depends on
largeish-collection-of-classes-B. As another simple small example: say
I change the name of large-collection-of-classes-B - this way I only
need to do it once, else I need to grep and sed all over in order to do
it.

It just feels cleaner and easier.
This is what packages are for. As far as refactoring package alignments,
a little bit of scripting goes a long way. Sometimes trying to make an
existing tool do something that it's not really right for distorts the
entire
process, rather than simplifies it.

John Roth

-i


Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: jmgro | last post by:
I need help in structuring a 200 question survey. Each question has three responses, and I want all 200 questions displayed at the same time with the user using the scrollbar to go down. What is...
2
by: Massimiliano Campagnoli | last post by:
Good morning, Database PRODUCTION was created on a system mamanged tablespace on drive c:\ Now drive c:\ is running out of space and I need to move PRODUCTION to the larger drive d:\ on the...
3
by: Josh Kingcade | last post by:
I have 2 tables built in my database already: A People contact table - tblPeople (with Primary Key pID); and an Involvement table - tblInvolvement (with Primary Key InvID). The Involvement...
1
by: Patrick De Ridder | last post by:
I have the following A solution called SOL001 SOL001 contains a library LIB001 LIB001 contains Form1.cs SOL001 also contains a windows application APP001 APP001 contains Form2.cs with...
8
by: Afanasiy | last post by:
Should I be concerned with the amount of memory my C# applications use? I have 2 gigs of ram, and I use most of that without running any C# applications. So, when I see C# applications in...
1
by: Simon Harris | last post by:
Hi All, I work in a team of three developers. 99% of our work is developing 'applications' for our organisations Intranet - mainly whats become known to us as e-employee apps, such as...
1
by: Damien | last post by:
Hey guys, I'm currently developing a reasonably sized application, which is expected to grow in the future. At the centre is the User login facility - everyone using the site must log in....
3
by: arun.hallan | last post by:
Hi, I need some structuring help. I have a set of data, in the form of an arraylist of objects. Each object is the same, and can be treated as a generic object which gets and sets properties....
3
by: googlinggoogler | last post by:
Hi This should all be pretty standard C stuff, but I'm going to use terms like mouse callback to communicate what Im tyring to do. Basically I have my program whirling around in an infinite...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.