Questions tagged [code-organization]

Code organization is the way how code is placed in a project.

Questions regarding code organization can deal with the topic on various levels:

  • How to split parts of a larger project in subprojects (e.g. in maven modules)

  • How to distribute classes in packages

  • Where to put tests relative to the code that gets tested

  • Where to put methods or fields inside of classes or other code units

One aspect of code organization is .

616 questions
2193
votes
12 answers

Should 'using' directives be inside or outside the namespace?

I have been running StyleCop over some C# code, and it keeps reporting that my using directives should be inside the namespace. Is there a technical reason for putting the using directives inside instead of outside the namespace?
benPearce
  • 34,921
  • 14
  • 60
  • 93
520
votes
18 answers

Where do the Python unit tests go?

If you're writing a library, or an app, where do the unit test files go? It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it…
readonly
  • 306,152
  • 101
  • 198
  • 201
164
votes
11 answers

How to organize large R programs?

When I undertake an R project of any complexity, my scripts quickly get long and confusing. What are some practices I can adopt so that my code will always be a pleasure to work with? I'm thinking about things like Placement of functions in source…
Dan Goldstein
  • 21,713
  • 17
  • 34
  • 41
125
votes
11 answers

Including one C source file in another?

Is it OK (or even recommended/good practice) to #include a .c file in another .c file?
102
votes
2 answers

How should I organize Python source code?

I'm getting started with Python (it's high time I give it a shot), and I'm looking for some best practices. My first project is a queue which runs command-line experiments in multiple threads. I'm starting to get a very long main.py file, and I'd…
Andres Jaan Tack
  • 21,282
  • 10
  • 57
  • 75
72
votes
1 answer

Spark code organization and best practices

So, having spend many years in an object oriented world with code reuse, design patterns and best practices always taken into account, I find myself struggling somewhat with code organization and code reuse in world of Spark. If I try to write code…
68
votes
6 answers

Can maven projects have multiple parents?

We have Java and Flex projects. We currently have 1 base pom that contains the configurations we want to use for both projects. Problem with this is: Flex projects inherit configuration, for example, for javadoc and pmd plugins, which is not…
Wim Deblauwe
  • 19,439
  • 13
  • 111
  • 173
51
votes
6 answers

NetBeans shortcut key for collapsing/expanding a method

JAVA - NETBEANS This is an IDE question I am always working with collapsed methods, because I want to be able to see my methods all together. This is a little time consuming because I have to use the mouse to scroll up to the declaration of the…
Stefanos Kargas
  • 8,783
  • 21
  • 69
  • 90
51
votes
8 answers

jQuery and "Organized Code"

I've been struggling lately with understanding the best way to organize jQuery code. I asked another question earlier and I don't think I was specific enough (found in this question here). My problem is that the richer you make an application, the…
hugoware
  • 33,265
  • 24
  • 58
  • 70
47
votes
12 answers

Why is each public class in a separate file?

I recently started learning Java and found it very strange that every Java class must be declared in a separate file. I am a C# programmer and C# doesn't enforce any such restriction. Why does Java do this? Were there any design consideration? Edit…
Sandbox
  • 7,088
  • 10
  • 49
  • 64
43
votes
5 answers

Splitting a JavaScript namespace into multiple files

Let's say I have a namespace like that: var myNamespace = { foo: function() { }, bar: function() { } }; What is the best way to split this code into files defining foo and bar separately? I'm not worried about loading time - I'll…
Piotr Zurek
  • 2,583
  • 1
  • 23
  • 32
40
votes
1 answer

Domain Driven Design - how the layers should be organized?

I'm very much new to software development. I think layered architecture is a great way to reduce the complexities that arise in the process of object oriented software development and, not to mention, to keep your code organized. I'm interested to…
36
votes
2 answers

Xcode Workspace vs Nested Projects

I don't understand the use of an Xcode workspace to organize projects with dependencies on one another. For instance I see a lot of developers create workspace structures that look like this: Workspace |-- App |-- A Common Library |-- Another…
mark
  • 1,328
  • 11
  • 27
35
votes
2 answers

Haskell module naming conventions

How should I name my Haskell modules for a program, not a library, and organize them in a hierarchy? I'm making a ray tracer called Luminosity. First I had these modules: Vector Colour Intersect Trace Render Parse Export Each module was fine on…
34
votes
10 answers

C++ Header order

What order should headers be declared in a header / cpp file? Obviously those that are required by subsequent headers should be earlier and class specific headers should be in cpp scope not header scope, but is there a set order convention / best…
Konrad
  • 35,953
  • 29
  • 74
  • 111
1
2 3
41 42