LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-25-2012, 08:25 AM   #1
Garda
Member
 
Registered: May 2005
Distribution: Debian
Posts: 83
Blog Entries: 2

Rep: Reputation: 15
designing large projects


Before I begin let me say that what I'm asking probably has a whole science to it that is not easily learned in a few hours or even days, but nonetheless, here I go asking anyway.

What tips, ideas, suggestions, ideas for things I shouls read/learn do you have for someone who has not done bery much programming and is beginning a reasonably large project.

My main problem really is getting my head around all the different parts that I want to put together (many of which I am not sire yet even of what they're going to look like or work).

Should I have a big diagramme in UML that I have planned already, should I just "make it up as Io go along" and wing it.

Any pearl of wisdom for anyone to share.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 03-25-2012, 04:44 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,623

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
Just one...

The classic approach is start from teh high-level overview, then break the project down into its critical parts, divide those parts down into functions or procedures that can be coded, then code those elements that are easy first. By the time you get to the more difficult ones you will more experience, more ideas for dividing them down into smaller and easier to code functions, and a better feel for how the whole thing will work when you have it finished.

Top down design, bottom up coding.

Rarely does the actual execution of the project continue to fit that model, but it gets you started and gives you a methodology for dealing with the occasional coding block. (Like writers block for engineers.) Actually getting started and making progress without wasting your energies or stressing yourself to death is key.

Luck!
 
1 members found this post helpful.
Old 03-25-2012, 05:21 PM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
I admit that this is only tangentially related, but related it is:

The Architecture of Open Source Applications (free ebook)
 
1 members found this post helpful.
Old 03-25-2012, 05:46 PM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Quote:
Originally Posted by wpeckham
Rarely does the actual execution of the project continue to fit that model, but it gets you started
Could not agree more.

With that in mind:
Quote:
Originally Posted by Garda
should I just "make it up as Io go along" and wing it
Absolutely not. For a quick, small project: fly by the seat of your pants all you like. For anything else, put some thought into it beforehand.

There's a bit of a catch-22 involved though that wpeckham touched on in his quote above. The catch-22 is, if this is a first-time approach to a programming task, you cannot properly design a system--because you have no experience/knowledge of the difficulties or problems you are likely to encounter. You end up programming-as-you-go because unanticipated problems pop up as often as not.

For those instances, my suggestion would be to write some basic, minimally-effective, skeleton version of the final program (or pieces of the final program). Then discard it--seriously. The purpose is to gain that initial experience about the problem. With that experience, develop a plan/specification/whatever and start over. Resist the temptation to "improve" your first-attempt-learning code. Start fresh.

So, in a nutshell, you should plan and document when starting a large project. If you're not familiar with the task to be confident in a plan you create, cut your teeth on a simplified version so you can go back and have a more competent plan.

It's ok to deviate from your plan. It's not set in stone, but make sure you have a good reason.

If you don't plan, you will end up rewriting your code. Not once, not twice, but probably many times as you refine your approach. There's no bigger motivation killer than realizing you need to make a fundamental change that trickles throughout the project.

Last edited by Dark_Helmet; 03-25-2012 at 05:48 PM.
 
Old 03-31-2012, 05:23 PM   #5
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by Garda View Post
Should I have a big diagramme in UML that I have planned already, should I just "make it up as Io go along" and wing it.
UML will hinder your progress unless you already have a plan. This is because there are rules to UML and you'll spend more time fitting into those rules than you'll spend being creative. It's a specification tool, not a creativeness tool. As far as "make it up as you go", keep in mind that every worthwhile project will change substantially over time. Your best bet regarding planning is to anticipate future requirements and figure out what sort of design will allow incorporation of those requirements without having to restructure the project. You don't have to plan out all of the requirements, and you won't know them all up front, but you can anticipate the weaknesses that will need to be improved or extended. For example, if your project involves IPC you'd want to make it easy to replace the IPC part of the system with something more robust in the future. Or if it processes flat files, you'd want to make it so you can add functionality to process more complex formats later on.

If there is only one philosophy you approach your project with, it should be to make it easy for "someone else" with more knowledge or skill to improve the weak parts of your project. For example, if your project performs computations, make it easy for someone who is better at computing things to pull out your code and put in something better. The cleverness in this philosophy is that this "more skilled person" will in most cases be you in the future.
Quote:
Originally Posted by Dark_Helmet View Post
For those instances, my suggestion would be to write some basic, minimally-effective, skeleton version of the final program (or pieces of the final program). Then discard it--seriously. The purpose is to gain that initial experience about the problem.
That's great advice. I usually have a "clean" source tree and a "working" source tree. In the "working" tree I mess around and get each piece of functionality to work in isolation, and once it's working well I integrate it into the "clean" tree using the "working" code only as a model.
Quote:
Originally Posted by Dark_Helmet View Post
If you don't plan, you will end up rewriting your code. Not once, not twice, but probably many times as you refine your approach. There's no bigger motivation killer than realizing you need to make a fundamental change that trickles throughout the project.
I find that rewriting is inevitable if your skill and knowledge of the problem you're solving both progress during the life of the project. Not anticipating at least component-level rewrites can seriously stagnate your project if at some future point you realize you can't overcome a barrier that you never knew could be a problem. If you sufficiently modularize your project, even structural-level rewrites don't need to be that painful.
Kevin Barry
 
Old 03-31-2012, 06:56 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Quote:
My main problem really is getting my head around all the different parts that I want to put together (many of which I am not sire yet even of what they're going to look like or work).
A long walk in the park helps sometimes.

Get out a legal pad and a number-two pencil and start sketching ideas. Do not remove a single sheet of paper from that pad. Consider how the user will approach the application, and the task that the application is purposed to help him or her solve. Consider what the application has to do with regards to its files, databases, other computers, whatever.
 
Old 04-01-2012, 12:00 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Set up automated testing that will allow you to easily re-run all the test cases set up so far. This will include data sets designed to expose edge-cases such as null data, one of a kind, many of a kind and erroneous data.

Specify the interfaces as well as the functional requirements -- user interface, OS interface and inter-module interfaces.

Write the developers' documentation as you develop.
 
Old 04-01-2012, 05:11 PM   #8
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
My (on-going) experience with large projects is that is important to have a well-thought out overall structure for your program. Drawing diagrams might be going a bit overboard, but it will help to create a "main" file with top level function calls, and then prototype those functions into some sensible arrangement of header files, with the accompanying stub implementations. Once this is in place, code tends to "fall in place" as you write it, which is a lot less stressful that constantly wondering how every line of code will fit into your overall plan.

As you create this structure, you mainly you want to be thinking about two things:

1) How will my program function on a fundamental level and how can I fit program structure to sensibly match that? Questions like: Is my program event based, or does it do batch processing? How is input related to program state? What approach will I take to handle various kinds of events?

2) How can I keep program components reasonably well isolated (while simple and efficient)? Generally, you want to be able to adjust function definitions and internal data structures without worrying that this will screw up 12 other files in ways you didn't expect. Each language typically has its own various features and nuances that can help. (In C, for example, which doesn't strictly speaking have an "object oriented" syntax, will allow you to hide a lot of internal structures and functions inside a source file, using internal linkage, while making a few interface functions available through a header.) Whatever structure or interface configuration you apply, you want to make sure it effectively isolates distinct program components, while being reasonably easy to use and allowing efficient handling of the data. The object-oriented approach can be helpful, though if you overuse it or abuse it, you might find yourself constantly moving around complex bundles of program objects, which might be difficult to understand or make optimization difficult.

Hope that helps.
 
Old 04-03-2012, 08:50 PM   #9
jarubyh
Member
 
Registered: Aug 2011
Location: $HOME
Distribution: Slackware, FreeBSD, Debian
Posts: 50

Rep: Reputation: 1
I'll chip in some advice: always over-document. Especially if your project is going to grow, it's better to write more documentation than needed and waste a little time than have an under-documented project and waste a lot of time explaining to people how to use it (or maintain it).
 
Old 04-05-2012, 04:18 PM   #10
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
In the real world, large projects are begun by gathering requirements. Designing how the program will interact with other systems and with its users (its interfaces) and how it will be organized (its architecture) is a separate step from defining what it needs to do.

If you're serious about learning this, you might want to check out some books on software engineering.

Last edited by dugan; 04-05-2012 at 05:07 PM.
 
2 members found this post helpful.
Old 04-05-2012, 08:16 PM   #11
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by dugan View Post
If you're serious about learning this, you might want to check out some books on software engineering.
I recently realized that there's a major difference between CS and software engineering. I'm not in either field, but not long ago what I thought was CS was actually software engineering.
Kevin Barry
 
Old 04-06-2012, 11:45 PM   #12
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by ta0kira View Post
I usually have a "clean" source tree and a "working" source tree. In the "working" tree I mess around and get each piece of functionality to work in isolation, and once it's working well I integrate it into the "clean" tree using the "working" code only as a model.
That's almost how GitHub is developed. The only difference is that they use a version control system (git) to automate this workflow, and that version control system can merge branches ("integrate it into the clean tree") automatically.

Details here. Very interesting read:

http://scottchacon.com/2011/08/31/github-flow.html

Last edited by dugan; 04-06-2012 at 11:51 PM.
 
Old 04-26-2012, 10:19 PM   #13
Garda
Member
 
Registered: May 2005
Distribution: Debian
Posts: 83

Original Poster
Blog Entries: 2

Rep: Reputation: 15
Smile

Thanks guys.

I hadn't replied after the first posts because I didn't think I had anything to add, but I have read all the posts.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make portable code for large projects shamjs Programming 2 09-21-2011 01:11 PM
designing large scale websites run on Linux dazdaz Linux - General 4 04-05-2011 12:32 AM
ext3 performance -- very large number of files, large filesystems, etc. td3201 Linux - Server 5 11-25-2008 09:28 AM
Knoppix on CD, Upon starting I get large menu with large text & blank submenus samdaria Linux - Newbie 1 06-06-2008 09:59 PM
LXer: This week at LWN: Large pages, large blocks, and large problems LXer Syndicated Linux News 0 09-27-2007 11:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration