473,666 Members | 2,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best practice for large source code projects

I'm developing a web system and based on some patterns I've seen
elsewhere, I made a single file (model.py) to hold all of the
functions and classes that define the model porition of the
application. Hence the code in the controller looks like:

import model

def Display(req,id) :
# ....
It works and things make sense to me. Yet, I feel uneasy that my
model.py file is starting to approach 500 lines. What's the best
practice or community opinion on this? Do I keep everything in a single
file or do I start dividing things into separate files?

TIA

Sep 22 '06 #1
2 1658
several of my programs are thousands of lines long, and i don't think
they're extravagantly large.
i'd say you should use modules the same way you use classes and
functions: to separate code logically.
if it makes sense to think of a group of statements as a function, you
make it a function. if it makes sense to think of a group of functions
as data as a single object, you make a class. if it makes sense to
think of a collection of classes and functions and data as a collective
unit, make a module. and so on for packages.
if it makes sense for a single function to be hundreds or thousands of
lines long, so be it.
follow the modern poet's rule: ignore restrictions that don't make
sense, and follow closely the restrictions you choose.
dh****@gmail.co m wrote:
I'm developing a web system and based on some patterns I've seen
elsewhere, I made a single file (model.py) to hold all of the
functions and classes that define the model porition of the
application. Hence the code in the controller looks like:

import model

def Display(req,id) :
# ....
It works and things make sense to me. Yet, I feel uneasy that my
model.py file is starting to approach 500 lines. What's the best
practice or community opinion on this? Do I keep everything in a single
file or do I start dividing things into separate files?

TIA
Sep 23 '06 #2
"dh****@gmail.c om" <dh****@gmail.c omwrites:
It works and things make sense to me. Yet, I feel uneasy that my
model.py file is starting to approach 500 lines. What's the best
practice or community opinion on this? Do I keep everything in a single
file or do I start dividing things into separate files?
It varies by project and preference. Working with very large files
can get cumbersome, but having a lot of small files means higher
amounts of editing hassle and more junk to keep track of.

As a personal opinion, I'd say just try to keep your functions small
and understandable, and don't worry about file size until the files
start getting inconvenient to edit. I find 1000-2000 lines is a
reasonable file size.
Sep 23 '06 #3

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

Similar topics

36
6368
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but something I'll need in this case is some experience-based set of rules about how to use python in this context. For example... is defining readonly attributes in classes worth the hassle ? Does duck-typing scale well in complex
11
9243
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
136
9307
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
6
4402
by: Droopy | last post by:
Hi, I want to add unit tests in my application using NUnit. At first, I thought to add unit tests in the class that is tested, enclosed in a conditional attribute to remove these unit tests from release code. Though, there is (at least) 2 problems working like that : 1) the class can becoming very large if there is a lot of tests 2) when releasing, the NUnit dll should not be needed => it should not be referenced.
8
5137
by: Axter | last post by:
I normally use a program call Doxygen to document my source code.(http://www.stack.nl/~dimitri/doxygen) This method works great for small and medium size projects, and you can get good documentation like the following: http://axter.com/smartptr Now I'm on a client site, and I'm trying to create the same type of documentation on a very large project. I ran the Doxygen program, and it ran for over 16 hours, before I had
5
2525
by: BK | last post by:
We've got a fairly large scale development process under way in .NET 2003. We are about a month away from go-live for phase 1, second phase is rather short and all work should be completed in the next 2 months. Looking back on problems encountered, we want to learn from this project. FWIW, we are nearly on time with the original time line (only off by about a month), and we actually added more functionality than the original specs...
16
2794
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and efficient navigating within Visual Studio 2005. Let's say your project (or solution) has dozens of forms and hundreds or even thousands of routines. Two Questions: 1) BUILT-IN to Visual Studio 2005. What ideas do you have to quickly
13
2563
by: G | last post by:
Hello, Looking for opinions on a fairly simple task, new to ASP.net (C#) and want to make sure I do this as efficiently as possible. I have a web based form, and I need to run some SQL before submit, which determines exactly where to send the form contents. The table of "receipients" could contain in the region of 3,500 recipients but is more likely to contain up to 1,000. Table structure:
6
5244
by: Daniel Kraft | last post by:
Hi all, in my C++ projects, I usually make "heavy use" of namespaces to "encapsulate" my code. When I have for instance something like this: namespace project { namespace part1 { ... } namespace part2 { ... } }
0
8443
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...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8639
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
7385
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...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
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...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
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

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.