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 .

620 questions
2386
votes
15 answers

Should 'using' directives be inside or outside the namespace in C#?

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
  • 37,735
  • 14
  • 62
  • 96
563
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
  • 343,444
  • 107
  • 203
  • 205
168
votes
10 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
  • 24,229
  • 18
  • 37
  • 41
148
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?
108
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
  • 22,566
  • 11
  • 59
  • 78
79
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
  • 25,113
  • 20
  • 133
  • 211
77
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…
52
votes
6 answers

NetBeans shortcut key for collapsing/expanding a method

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 method and click on…
Stefanos Kargas
  • 10,547
  • 22
  • 76
  • 101
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
  • 35,731
  • 24
  • 60
  • 70
48
votes
11 answers

Why is each public class in a separate file?

I recently started learning Java and found it very strange that every Java public 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…
Sandbox
  • 7,910
  • 11
  • 53
  • 67
45
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…
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,800
  • 2
  • 24
  • 32
38
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,398
  • 13
  • 30
36
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…
35
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
  • 39,751
  • 32
  • 78
  • 114
1
2 3
41 42