Questions tagged [code-organization]
The code-organization tag has no usage guidance.
112
questions
0
votes
2
answers
180
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 ...
2
votes
2
answers
219
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 ...
3
votes
3
answers
2k
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 ...
0
votes
2
answers
154
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 ...
-3
votes
1
answer
92
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 ...
0
votes
2
answers
109
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 ...
1
vote
3
answers
5k
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 ...
3
votes
1
answer
411
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&...
2
votes
3
answers
440
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 ...
0
votes
1
answer
490
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
...
1
vote
2
answers
917
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 ...
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 ...
-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 ...
-3
votes
2
answers
295
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 ...
0
votes
2
answers
201
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 ...
-3
votes
1
answer
176
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 ...
0
votes
0
answers
561
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. ...
2
votes
1
answer
125
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 ...
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 ...
4
votes
1
answer
2k
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 ...
5
votes
1
answer
24k
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?
...
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 ...
0
votes
3
answers
722
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 ...
0
votes
1
answer
629
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 ...
0
votes
1
answer
110
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 ...
38
votes
4
answers
59k
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 ...
-3
votes
3
answers
491
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 ...
-2
votes
1
answer
114
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 ...
3
votes
2
answers
792
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 ...
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)
{
...
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 ...
14
votes
5
answers
715
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
...
2
votes
1
answer
101
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 ...
1
vote
0
answers
35
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(...
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 ...
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/...
0
votes
1
answer
411
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 ...
1
vote
1
answer
540
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 ...
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 ...
5
votes
1
answer
196
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 ...
4
votes
0
answers
2k
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(...
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 ...
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 ...
0
votes
2
answers
746
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 ...
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 = ...
2
votes
1
answer
152
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 ...
3
votes
1
answer
248
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 ...
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 ...
4
votes
0
answers
2k
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 ...
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, ...