472,378 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 1617
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.com 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.com" <dh****@gmail.comwrites:
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
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...
11
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...
136
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...
6
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...
8
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...
5
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...
16
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...
13
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...
6
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 { ... }...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...
0
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

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.