Questions tagged [code-structure]

Code Structure regards the way that code is written to allow it to be best read, maintained and organized for efficiency. Decisions such as when classes should be used, and which patterns would be most efficient for a task.

This is a cross-language discipline that allows code to be read and maintained easier. In some areas, such as simple web design, this may relate simply to best practices, such as creating your CSS using a separate file, and then organising this in a way that makes the most sense (starting with a browser reset, then the structure, and then into areas such as fonts).

In more complex languages, however, this also involves the use of patterns to be most efficient, and removing duplicated code and overall making your application appear much simpler.

204 questions
3
votes
1 answer

Symfony2: Code structure for website, mobile website and API?

I'd like to build a mid-sized website which also includes a mobile website and an API. As I already have some experience with Symfony I'd like to build the project on top of it. However, I have no idea how to structure my project. Maybe there are…
XM2
  • 31
  • 1
3
votes
2 answers

perl code structure for post-processing

The question I have is a bit abstract, but I'll attempt to be clear in my statement. (This is something of a "rubber duck effect" post, so I'll be thankful if just typing it out gets me somewhere. Replies, however, would be brilliant!) I have old…
user1357713
2
votes
1 answer

Should layers be visualized in the code structure?

After have read Clean Architecture by Uncle Bob i have been thinking about the concept of screaming architecture and the last chapter around organizing code. I have generally liked working with layers being present in the structure to easily place…
CEH
  • 29
  • 5
2
votes
1 answer

Pytest can't find files/modules

I have had a look at several different topics on this matter but can't work out how to apply it to my situation. I don't have an init.py in my test folder and I have tried to use conftest. I have a directory structure like this: --app --app.py …
Lucy
  • 179
  • 1
  • 4
  • 14
2
votes
1 answer

How to split out and rename code files in git while preserving history?

I am new to git and now facing a git repo 'housekeeping' challenge after deciding to clean up the code structure. There are two dimensions to my challenge: Need to rename suboptimally titled REPO, and some SUBFOLDERS and FILES to a clean python…
PeterO
  • 43
  • 6
2
votes
3 answers

How to import other source code files in dm script

Is there a way to use multiple code files in dm-script to structure the code? Something like: import "path/to/utility_functions.s"; utility_functions.do_something_general(); Note that I do not want to have the code as a menu item if possible. The…
miile7
  • 2,547
  • 3
  • 23
  • 38
2
votes
1 answer

What techniques exist for splitting large angularjs services?

Currently I am rebuilding a large angularjs controller (1000+ lines), and this controller is using a large angularjs service (1000+ lines). I want to push much of the business logic from the controller to the service, but the service is getting hard…
2
votes
1 answer

How validate data from post in restful api

I need to validate some data before insert into the database, for that i create a little service that return invalid fields from an entity. It works ok when validating single entities. class EntityValidator { protected $validator; public…
2
votes
1 answer

Ruby: require works in gem, fails when running from source

Try creating a gem based on bundler's official guide on developing a Ruby gem. Running bundle gem foodie will create a structure and generate files in the lib directory: foodie version.rb foodie.rb foodie.rb reads require…
thisismydesign
  • 21,553
  • 9
  • 123
  • 126
2
votes
1 answer

Best way to use returns to break from a loop

First of all, I'm not a native speaker, so please excuse me if there are grammatical errors. :) I'm a real greenhorn and just started to learn programming - i choose Python 3 as my first language. So please be lenient :) I already tried to find an…
2
votes
2 answers

In what order do you put methods in class code?

Class could have static, private, protected, public methods. Each method is made for modifying, adding, removing etc. How do you group functions in class's code to make it clean to read? What is the best practices? Thank you.
Kirzilla
  • 16,368
  • 26
  • 84
  • 129
2
votes
0 answers

Angular code structuring with JS closures/skillets - inject app as "this" - Should I do this or not?

Is this a good or a bad practise structuring the code this way and injecting the dependencies like below? I like to separate all my code in closures so that I structure them the way below - As far as I remember it is a good practise because using…
haxpanel
  • 4,402
  • 4
  • 43
  • 71
2
votes
2 answers

How to write graphical programs

I have learned C++ and Qt4. I wrote one graphical program with 3000 rows and I found out that there is really complicated to keep code simple, transparent and well-structured. I like design patterns etc. because they are really effective and helps…
Gaim
  • 6,734
  • 4
  • 38
  • 58
2
votes
3 answers

Is there a name for the this code structure?

Here's a simple case: private final MouseAdapter mouse = new MouseAdapter() { public void mouseClicked(MouseEvent e) { calculate(); } }; It's a class level field, so calling it an Anonymous Class doesn't seem…
Eben
  • 422
  • 2
  • 11
2
votes
1 answer

Structure of large assembly code (difference for including .asm/.inc files)

I just started a larger project completely coded in Assembly. Having multiple subroutines, macros, memory tables etc. I am wondering how I can best split the code up in multiple files. The goal is obvious a better structure and a better…
lorenzli
  • 620
  • 1
  • 10
  • 31