473,806 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1518
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.ne t> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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
1774
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 the best approach?
2
3605
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 same machine. PRODUCTION is currently accessed by 50 clients running many applications and by some REXX scripts running on the same server machine on a timely basis. I do not want to modify in any way clients configuration, applications,
3
1305
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 Table includes one record for each possible area of work in the church. I need a way to input multiple areas of service per person - basically, to link one pID with multiple InvID, but not in an exclusive manner.
1
1226
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 button1.
8
4926
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 development, which are using much more memory than their Delphi and Python equivalents, I am a bit worried. Is there more than meets the eye or is it simply deemed acceptable for the platform?
1
1067
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 sickness/holiday reporting/authrisation, handling the new starter/leaver processes, etc...the list goes on. Up to recently, we have been developing in 'classic' ASP, storing all apps in subdirectories of there own.
1
1186
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. Thereafter, various different services may be available to the user, dependant on how they are set up - there are currently two services available:
3
1200
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. I want to display this in a datagrid - which is not too hard. I've done this by mapping the object data to a datatable, and then
3
2021
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 loop (easy) waiting for the mouse to be clicked (I dont need help with this) and depending on user input a variable might define what function I want (be it line, circle....(again these are my issues)
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10371
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.