Questions tagged [program-structure]

26 questions
76
votes
29 answers

How do you find a needle in a haystack?

When implementing a needle search of a haystack in an object-oriented way, you essentially have three alternatives: 1. needle.find(haystack) 2. haystack.find(needle) 3. searcher.find(needle, haystack) Which do you prefer, and why? I know some…
Anders Sandvig
  • 20,720
  • 16
  • 59
  • 73
47
votes
4 answers

Is it possible to generate a diagram of an entire Django webapp?

Is it possible to generate a diagram of an entire Django site? For example, to understand the model/database structure I use graphViz which is extremely useful for keeping track of the model structure, and very useful for discussions. I was curious…
djq
  • 14,810
  • 45
  • 122
  • 157
9
votes
6 answers

C - program structure (avoiding global variables, includes, etc.)

I'm using C (not C++) and I'm unsure how to avoid using global variables. I have a pretty decent grasp on C, its syntax, and how to write a basic application, but I'm not sure of the proper way to structure the program. How do really big…
guitar-
  • 1,051
  • 5
  • 15
  • 21
9
votes
6 answers

How does a program look in memory?

How is a program (e.g. C or C++) arranged in computer memory? I kind of know a little about segments, variables etc, but basically I have no solid understanding of the entire structure. Since the in-memory structure may differ, let's assume a C++…
sharkin
  • 12,162
  • 24
  • 86
  • 122
5
votes
3 answers

How do you define functions in header files?

The setup If I have a program like this A header file that declares my main library function, primary() and defines a short simple helper function, helper(). /* primary_header.h */ #ifndef _PRIMARY_HEADER_H #define _PRIMARY_HEADER_H #include…
RBF06
  • 2,013
  • 2
  • 21
  • 20
5
votes
4 answers

Origins of the name 'main' for program entry point?

Out of curiosity, what are the origins of the name 'main' for a program entry point?
user113476
5
votes
2 answers

What are some best practices for structuring cherrypy apps?

I'm writing a cherrypy app and I was wondering what the best way is for structuring my handlers and code for larger applications? I realize assignment is simple trough cherrypy.root, but what are some practices for writing the handlers and assigning…
Alexander Trauzzi
  • 7,277
  • 13
  • 68
  • 112
4
votes
1 answer

What is the advantage of a parallel pipeline compared with Task Parallelism?

I often read about the pipeline pattern as a common and helpful pattern in terms of exploiting concurrency. But I wonder if there is any advantage of the parallel pipeline pattern compared with the Task Parallel Pattern. Suppose we have three stages…
3
votes
4 answers

Maintaining modularity in Main()?

I'm writing the simple card game "War" for homework and now that the game works, I'm trying to make it more modular and organized. Below is a section of Main() containing the bulk of the program. I should mention, the course is being taught in C#,…
nvillec
  • 61
  • 1
  • 8
2
votes
3 answers

How to find and execute a method on another java application currently running on computer using java?

For example, lets say I have hello.java (arbitrarily), if it was running and user changed some accessible (not private) variable in that application by providing input while running, this application would have the variable different compared to one…
User7829300192
  • 128
  • 1
  • 8
2
votes
1 answer

Clarification on variables

Recently, while reading the book "Eloguent Javascript" by Marijn Haverbeke, in chapter 2: Program Structure, section 2: Variables, I came across this statement: They (variables) do not contain values; they grasp them He then goes on to use the…
NaijaProgrammer
  • 2,892
  • 2
  • 24
  • 33
1
vote
1 answer

Should I not be subclassing the Cocos2d CCDirector class?

I'm trying to make cocos2d work as an RPG engine. I'm thinking of making a class that will coordinate the movements of the characters, the map loading/unloading etc. Should I make a CCNode for this, or just extend the CCDirector? Is there a reason…
Moshe
  • 57,511
  • 78
  • 272
  • 425
1
vote
3 answers

How can I simplify repeating function logic

Question I'm wondering if there is a way to improve the current structure of some functions in my program since I feel there is a fair amount of unwanted repetition happening. Background I'm writing a tiny logger so CLI applications can have…
alex Hexan
  • 115
  • 2
  • 6
1
vote
2 answers

MVC: One model, multiple applications

I am starting a project based on multiple webapplications (Website, ControlPanel, RestAPI) each based on the same Data[bases] and an MVC framework. To avoid parallel code maintenance I thought of having the same model-files for each app. But when…
user11031378
1
vote
1 answer

For-Else loop in another For loop

I have some question regarding the for-else loop in another for loop. So here is an example: primelist = [] for p in range (2, x+1): print 'in first for' raw_input() for i in range(2, p): print 'in second for' if p%i ==…
BlackTM
  • 13
  • 2
1
2