Questions tagged [code-separation]

75 questions
260
votes
17 answers

Is it a good practice to place C++ definitions in header files?

My personal style with C++ has always been to put class declarations in an include file and definitions in a .cpp file, very much like stipulated in Loki's answer to C++ Header Files, Code Separation. Admittedly, part of the reason I like this style…
T.E.D.
  • 44,016
  • 10
  • 73
  • 134
50
votes
4 answers

Implementation of achievement systems in modern, complex games

Many games that are created these days come with their own achievement system that rewards players/users for accomplishing certain tasks. The badges system here on stackoverflow is exactly the same. There are some problems though for which I…
lamas
  • 4,528
  • 7
  • 38
  • 43
30
votes
4 answers

How and when to split C++ code into headers and source files

I have a small application, all in one file. I want to convert this into separate smaller files. How do I know how to separate things? What is the invisible margin that code should be separated at? Also, what's the point of header files? Is it to…
Parkman
26
votes
2 answers

Project segregation in Sonar Qube

I have a projects structure like as shown below. Cloud projects folder are having four type projects (eco-projects, evn-projects, met-projects, svn-projects) Each type of projects contains again four different projects, like for example in…
Alex Man
  • 4,746
  • 17
  • 93
  • 178
18
votes
8 answers

Separating UI and logic in C#

Does anyone have any advice on keeping logic out of my GUI classes? I try to use good class design and keep as much separated as possible, but my Form classes usually ends up with more non-UI stuff mixed in than I'd like, and it tends to make…
Andy
  • 2,764
  • 6
  • 24
  • 33
13
votes
3 answers

Keeping code in a client-server game organized

Background: I help develop a multiplayer game, written mostly in C++, that uses a standard client-server architecture. The server can be compiled by itself, and the client is compiled with the server so you can host games. Problem The game…
faffy
  • 351
  • 3
  • 14
5
votes
4 answers

how to separate sql from php code

I have a class that helps me to handle users. For example: $user = new User("login","passw"); $name = $user->getName(); $surname = $user->getSurname(); $table = $user->showStats(); All these methods have SQL queries inside. Some actions require…
Larry Foobar
  • 11,092
  • 15
  • 56
  • 89
5
votes
3 answers

3 values (numbers) in 1 input separation. Python 3

I'm working on a code right now that a part of it requires to ask the user for 3 different numbers in one line ( could be any number of digits in each number). Say I ask the user for the input and he enters : "31 722 9191". A space is required…
dkentre
  • 289
  • 3
  • 5
  • 10
4
votes
0 answers

CUDA Separate compilation issues using cmake

I have a CUDA project which I compile with cmake. It worked fine until I wanted to add a new class containing a device function described in new files (.cu and .cuh). This is the CMakeList file : project(SINS) cmake_minimum_required(VERSION 2.8) #…
Mortuis
  • 51
  • 5
4
votes
4 answers

All code in one js file vs separating code into multiple js files

By now I've had only one javascript file in my project that contains tons of functions only few of which are used by more than one web page..As the amount of code involved rises I can see the the file gets messy and way too long. I'm thinking of…
Mikayil Abdullayev
  • 12,117
  • 26
  • 122
  • 206
3
votes
3 answers

Multiple Singleton Instances

I am writing a library of utility classes, many of which are singletons. I have implemented them as such using inheritance: template class Singleton { public: T& getInstance() { if(m_instance == 0) { …
ohnnyj
  • 53
  • 2
  • 6
3
votes
3 answers

How to combine separated Koa-Routers with Typescript

I decided to split my routers by their purpose, so they look like this: routers/homeRouter.ts import * as Router from 'koa-router'; const router: Router = new Router(); router .get('/', async (ctx, next) => { ctx.body = 'hello world'; …
Fuchur Kool
  • 53
  • 2
  • 7
3
votes
4 answers

Prompt user for confirmation in the middle of a process

I'm looking for a good approach to sometimes pause an action (function/method call) until the user confirms that he wants to do a specific part of that action. I need to do this in an environment that doesn't allow code execution to stop…
Alin Purcaru
  • 43,655
  • 12
  • 77
  • 90
3
votes
2 answers

Separate user interface from domain in java Swing

As a Java Swing newbie, I have some trouble separating the user interface logic from the domain logic. I have a small (trivial?) Swing app with a JFrame that contains a JLabel, JTextField and a JButton. When pressing the JButton a JFileChooser…
user504342
  • 945
  • 2
  • 16
  • 36
2
votes
2 answers

In JQuery how can I keep HTML OUT of my javascript?

I think JQuery is great but I also like the idea of keeping the HTML in the HTML document and virtually none of it in the javascript. What do I mean? You know like, say you are creating a dynamic table that had many many rows or a variable number…
Strat-O
  • 163
  • 1
  • 9
1
2 3 4 5