Questions tagged [code-organization]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
159 views

How might encapsulated source be broken into into multiple files?

I have a project where there is a primary, high-level, opaque struct with many functions that operate on it. Maybe I am simulating a CPU. How might the corresponding source code be organized? One way ...
Ana Nimbus's user avatar
2 votes
2 answers
187 views

Where to put interface files for mocking aka what are best practices for organizing interfaces in a C#/.NET Core project with NSubstitute, Moq etc.?

Question I'm working on a C#/.NET Core project, and I'm looking for guidance on organizing interfaces, especially when it comes to using NSubstitute, Moq or other libraries for mocking, because there ...
rklec's user avatar
  • 31
2 votes
3 answers
929 views

C++ Is it okay to use nested classes as a way to namespace derived classes?

I have many abstract classes that describe many abstract ideas and objects. These classes have many complex relationships with each other, and I realize that while writing code with some of the ...
nreh's user avatar
  • 151
0 votes
2 answers
149 views

Where to put the code that searches objects in a complex hierarchy?

Given the following hierarchy of objects: a keyed collection of ClassA objects, where each ClassA object contains a keyed collection of ClassB objects and each ClassB object contains a keyed ...
PieterV's user avatar
  • 215
-3 votes
1 answer
78 views

What are some best practices for team structure around Mobile and Desktop apps? [closed]

We're currently developing a product which will have a Web version and a Mobile version. At the moment, the plan is to have identical features on both of these. From a tech perspective, there is an ...
pvukovic's user avatar
  • 145
0 votes
2 answers
106 views

Where are all the small functions supposed to go in XP? [closed]

I like the concept of Extreme Programming (as I understand it), that there should be many smaller functions with descriptive names, instead of fewer, longer ones, even if those functions are only ...
Minix's user avatar
  • 149
1 vote
3 answers
4k views

"Hard coded" vs. configuration files for values in libraries? (code organization question)

I'm trying to get a good understanding as to whether there is a best practice or standard regarding keeping values within your code libraries or referencing them from another config file. I don't ...
Kyle's user avatar
  • 13
3 votes
1 answer
380 views

Which is a good way of separating and organizing layers and subdomains code, one that highlights and facilitates a clean architecture?

As I understand, when following the Low Coupling High Cohesion Principle, I should keep together the code that is related to same theme, splitting the code into modules/submodules by its "domain&...
whyer's user avatar
  • 139
2 votes
3 answers
335 views

What are some methods of storing personal notes alongside code?

When exploring a new codebase, what would be some methods of storing personal notes or annotations alongside the code? If I were the only maintainer, I might consider added an actual code comment into ...
dotancohen's user avatar
  • 1,041
-1 votes
1 answer
391 views

How to organize top level scripts in Python projects, especially for interactively developing

I have a Python project that looks something like this. project/ tests/ __init__.py tests.py main_module/ __init__.py sub_modules/ ... task1.py ...
RJTK's user avatar
  • 107
1 vote
2 answers
801 views

In C#, is it reasonable to use a #region when I need several members to implement a common interface?

I know that lots of people hate #regions in C#. IMO there is at least one legitimate use of them: Sometimes I have a class which, in addition to its core functionality, needs to implement a commonly ...
Claus Appel's user avatar
0 votes
0 answers
56 views

What best practices/principles could help me improve my routine call placement?

I'm trying to change my module's outline since I feel I'm blocking some reuse possibilities, but I don't know how to justify it under the lens of good practices/design principles. Keep in mind this is ...
Fernando Silva's user avatar
-4 votes
1 answer
1k views

Best practice for organizing build products of dependencies and project code in your repo source tree?

I've checked quite a few related questions on source tree organization, but couldn't find the answer for my exact need: How should I organize my source tree? What's the best structure for a ...
kakyo's user avatar
  • 95
-3 votes
2 answers
264 views

How do I organize my REST API codes along with the codes for generating the website?

Using github as an example, www.github.com is the website people visit and api.github.com is the REST api server programs will visit. But they probably share some codebase and in my case they share a ...
Qiulang 邱朗's user avatar
0 votes
2 answers
196 views

DRY Violation for Logical Code Organization and Readability

I have a block of code that branches into 2 pathways, let's call them the "simple" and "complex" branch, based on user input. Either the simple or complex logic has 4 steps, let's call them A, B, C ...
Dragonsheep's user avatar
-3 votes
1 answer
153 views

Proper way to organize Small Functions in PHP

I have a bunch of small utility PHP functions that I made to solve different scripting problems. Functions like UUID() and trackUserActivity() etc. There are tons of these functions and increasing ...
Abdul Jabbar's user avatar
0 votes
0 answers
486 views

Structuring a "Large" Windows Forms Project and Solution To something with Multiple Sub-Projects

I've willingly inherited a VB.Net forms project based on .Net 3.5 last edited with VS2012. I was able to open it up and up-convert it to VS2017. I can compile and run it and make some little tweaks. ...
GisMofx's user avatar
  • 379
2 votes
1 answer
119 views

Separating Plotting and Computation Logic in Scientific Computing MVC App

I’m developing a Matlab GUI for a scientific computing application and need to plot fairly heavy intermediate results. Currently, the computation is represented as a function. The GUI accepts user ...
Dragonsheep's user avatar
4 votes
2 answers
1k views

How can I cleanly handle deeply nested namespaces in C++?

The first language that I truly learned was Java. In it, it is very syntactically easy to nest classes in an essentially arbitrarily complex package hierarchy, which keeps the code organized. It is ...
john01dav's user avatar
  • 879
4 votes
1 answer
1k views

Managing error code and error message mapping

As part of a game engine I am writing in cython, one of the challenges I am facing is creating a consistent interface for error handling that works at the C and python levels of my code. I am ...
CodeSurgeon's user avatar
5 votes
1 answer
23k views

Folder structure for a C project [closed]

I am wondering what is the recommended folder structure for a C project. I read several posts about using src, include, test, build folders. But what if I want to structure the project in modules? ...
Mat.R's user avatar
  • 67
1 vote
1 answer
2k views

Organizing Python functions into a module or class

I'm working on a module for clustering algorithms, clustering.py. I noticed several functions in the module only pertain to the mean shift algorithm, so I thought it might make sense to group them ...
Vermillion's user avatar
0 votes
3 answers
721 views

When it isn't right to add types to a well known namespace?

For the purpose of writing a library, I found to be nice to add types to some well known namespace. Example: I've written a couple of extension methods for BinaryWriter and naturally put them in ...
Eric Cartman's user avatar
0 votes
1 answer
589 views

Relative merits of monolithic repository over multiple smaller ones

I was tasked with implementing a networking stack. The software is self-contained with no external dependencies - it only needs the C++14 standard library, and a POSIX platform. In my opinion there's ...
Mael's user avatar
  • 2,345
0 votes
1 answer
105 views

Thinking about a setup to work with react and front end development

On my team I'm working as a frontend developer in a React codebase. We're building an application and do everything in React. Before this I was actually always a backend developer. Now I have the ...
Vince V.'s user avatar
  • 153
37 votes
4 answers
57k views

How to best to organize class and interface files?

OK .. after all the discussion I'm changing my question slightly to better reflect a concrete example that I am dealing with. I have two classes ModelOne and ModelTwo, These classes perform ...
Peter M's user avatar
  • 2,029
-3 votes
3 answers
490 views

Writing quality code [closed]

I know there are many books on writing clean, modular, readable and whatever else you can say but frankly speaking I find it very hard to remember every advice given on those books. Frankly speaking ...
CodeYogi's user avatar
  • 2,166
-2 votes
1 answer
113 views

Using git on a project with different areas

I'm starting a new project and I'd like to plan it's use with git (using SourceTree) before starting. I work as a self developer and I'm starting a project that will have 3 different areas. This is ...
celsomtrindade's user avatar
3 votes
2 answers
784 views

Mixing JavaScript and server-side scripting

I see code like this sometimes (mixed PHP and JS in this case, but could be any server-side language): <script> var data = <?php echo $bigDataStructure ?>; // then lots more pure js ...
jinglesthula's user avatar
5 votes
3 answers
1k views

Should parameters of a method be in the same namespace as the class?

Suppose you have this: namespace Project.Services { public class ClientService { public IEnumerable<Clients> Query(Project.Models.Builders.ClientQueryBuilder builder) { ...
Einer Santana's user avatar
4 votes
2 answers
7k views

How I can organise a project in more programming languages in Git repos? [closed]

At work I'm using Java, but I'm planning to study some other programming languages as Python or Clojure. I'm thinking of coding one project in Java in my Git repository and, during my study, coding ...
alepuzio's user avatar
  • 341
14 votes
5 answers
713 views

Small functions vs. keeping dependent functionality in same function

I have a class that sets up an array of nodes and connects them to each other in a graph-like structure. Is it best to: Keep the functionality to initialize and connect the nodes in one function ...
mcfroob's user avatar
  • 249
2 votes
1 answer
99 views

Encapsulate multiple retrieval methods for a class

I'm doing a little bit of cleanup and I'm trying to gather all the spread SQL queries done to an object into a single place. I have a class whose responsibility is to present a CRUD interface to the ...
Sergi Juanola's user avatar
1 vote
0 answers
33 views

How to handle the set of objects that represents a context?

How can I handle the situation when exists the context that represents a collection of arbitrary objects? This context can be created by code like this: $context = new Context(); $context->add(...
Eugene's user avatar
  • 11
11 votes
4 answers
10k views

How can I effectively use one file per class in C++?

Even though I have a decent bit of professional experience with object oriented programming in Java and a basic familiarity with C, I've run into a bit of a mental block with C++ that I was hoping ...
SaxSalute's user avatar
  • 119
0 votes
2 answers
77 views

Is an approach to store classes that belong to a single feature in a single folder, superior to classifying them in several "community" folders?

in my project I am finding that I mix and match the following two patterns, when it comes to organizing classes in folders/namespaces: Modularized MVC Blocks module/Album/Feature/Controller/...
Dennis's user avatar
  • 8,217
0 votes
1 answer
394 views

Is it a bad practice to use external files for storing SQL templates?

I am working on a report system which aggregate a lot of data from multiple sources (databases and internal APIs). Among other things I communicated with another departaments and told them I need some ...
Nikita U.'s user avatar
  • 173
1 vote
1 answer
523 views

Ruby: Abusing mixin

I'm currently working with some code that IMO has abused ruby's mixin features. Given that I'm new to ruby, I wonder if MO in IMO is correct or not. My primary question is what makes more sense (and ...
Kashyap's user avatar
  • 159
2 votes
2 answers
1k views

How to structure classes in a large codebase

One of the most touted rules of OOP is to keep classes small. This means that in a significantly sized project there are bound to be thousands of classes. Logically it seems to make sense to combine ...
Andy's user avatar
  • 687
5 votes
1 answer
193 views

How to organize my module

This is currently the way I'm organizing it. myProject/ README subproject1/ __init__.py classA.py classB.py driver.py basicTest.py Driver imports from ...
emschorsch's user avatar
4 votes
0 answers
1k views

Should the order of definitions correspond to the order of declarations in header/source files? [closed]

If my header looks like this: class foo { public: foo(); ~foo(); QString b(); QString c(); QString a(); void setB(QString s); void setC(QString s); void setA(...
Anon's user avatar
  • 3,593
16 votes
1 answer
22k views

Directory organization of a CMake (C++) repository containing several projects

I would like some advises on the organization of a set of related but independent C++ projects stored in a single (git) repository. The projects use CMake. For a simplified example we imagine 2 ...
Barth's user avatar
  • 471
3 votes
1 answer
104 views

Split program to smaller programs

I have for planned to build my own drone from scratch for learning purpose and will program all controls for the drone. My question is if it's a good idea to split the code that doesn't interact with ...
Olof's user avatar
  • 133
0 votes
2 answers
741 views

Way to organize repetitive text in Java

Some times I have texts that appears in different places, like comments, messages... For example if I have a custom Exception, probably class doc, messages that passes as parameter to its constructor ...
hasanghaforian's user avatar
3 votes
1 answer
4k views

What is the purpose of separating routes into individual modules with Node.js and Express?

My app uses Node.js and Express 4 and has the following code in the app.js file located in the root directory: var express = require('express'); var index = require('./routes/index'); var users = ...
Jackmc1047's user avatar
2 votes
1 answer
136 views

Pick dynamically the right Factory Class with Inversion of Control

I have a TreeView and I want to enable the context menu when clicking with the right mouse button. It is composed by items from different classes, but they all share the same base class. So, I was ...
simoneL's user avatar
  • 232
3 votes
1 answer
245 views

Structure project based on platform or design?

I have a medium sized project (~10,000 lines) that runs on Windows and Linux. However it is only specific components of the program that are platform dependent and are located in a folder called ...
Pithikos's user avatar
  • 232
1 vote
1 answer
1k views

How to organize large polyglot projects?

One of my projects started as PHP but recently some of the new functionality has been written in JavaScript on Node.js platform. How do big polyglot projects that use multiple languages to write ...
Denis Pshenov's user avatar
4 votes
0 answers
1k views

Structuring a multi-language project?

I'm working on a project which involves writing code for multiple devices, each in its own language (in particular, Arduino and Python). I want to contain the entire project in a single directory, but ...
Vasu's user avatar
  • 141
0 votes
1 answer
84 views

Know any good resources/information on architecting an iOS app? [closed]

I spent a few months working on an iOS app of mine (in Swift) before realizing it was really a bunch of MVCs (Massive View Controllers). I want to start fresh and build something modular, scalable, ...
dcgoss's user avatar
  • 181