code-structure

Creating an API for my software - Basic code structure

Hi! I'm currently writing a web software which is also going to be used by Client desktops via an API. The problem I'm facing right now is: Should I implement every action of adding/updating/deleting objects in the application twice? Once as it sits in the normal code and once isolated for the API? Or should I much rather use a system o...

Why use short-circuit code?

Related Questions: Benefits of using short-circuit evaluation, Why would a language NOT use Short-circuit evaluation?, Can someone explain this line of code please? (Logic & Assignment operators) There are questions about the benefits of a language using short-circuit code, but I'm wondering what are the benefits for a programmer? Is it...

Combining XmlWriter objects?

The way my application is structured, each component generates output as XML and returns an XmlWriter object. Before rendering the final output to the page, I combine all XML and perform an XSL transformation on that object. Below, is a simplified code sample of the application structure. Does it make sense to combine XmlWriter objects...

Using a Goto to enhance the DRY principle and code clarity: a good idea?

I have some code that is structured like the following: if (someStatement) { //... if (SomeOtherStatement) { //..., possibly more cases like this } else { //goto warning; //would otherwise repeat //the MessageBox.Show here } } else { //goto warning; } //... warning: Message...

What is a good code structure for api-independant vertex processing?

Currently working on a 3D media engine using C# and I have come across a little conundrum. I have my rending loop figured out, I got a great plug-in architecture and content management system and even a material pipeline all planned out. Then engine is planned to use DirectX and OpenGL (via 'renderer' plug-ins), along with both APIs' pro...

Any tips for structuring C++ code using win32?

I am trying to improve my coding skills by making my code more structured and readable. I code the GUI (thanks edit). I have been reading through Firefox's open source code to improve but it uses GTK+ and not much Win32. Where can I find an open source (professional) program that is coded in Win32? One more thing: When should one write...

In what package should a "Settings" class be placed?

I'm in the middle of building an application but found myself too easily creating new packages without keeping the project's structure in mind. Now, I'm trying to redo the whole project structure on paper first. I am using a Settings class with public properties, accessed as settings for several other classes around the project. Now, s...

Building out a well-structured service layer

First, I want to say that it has been awhile since I've gotten into the kind of detail I am at currently. Lately, I've been very much in the SharePoint world and my entire thought process was focused there for quite some time. I'm very glad to be creating databases again, writing "lower level" code to deal with data access, and so fort...

C++: Avoid .cpp files with only an empty (de)constructor

Hi, When I have a header file like this: #ifndef GAMEVIEW_H_ #define GAMEVIEW_H_ #include <SDL/SDL.h> class GameView { public: GameView(); virtual ~GameView(); virtual void Update() = 0; virtual void Render(SDL_Surface* buffer) = 0; }; #endif /* GAMEVIEW_H_ */ I need to create a .cpp file like this: #include "GameView.h" Ga...

javascript / jquery code organisation

I would like to get some advice on structuring my javascript code and jquery functions. I like to use JQuery for dom event handling and ajax etc. I have written what seems like poor code in the past where my entire js file consists of a bunch of anonymous Jquery functions. I am wondering - what does a "well structured" javascript file...

How to write graphical programs

Hi, 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 to keep code simpler and more transparent. Now I am going to write another "bigger" ap...

In what order do you put methods in class code?

Hello, 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. ...

How to parse actual code like stackoverflow/intellisense/etc?

I was wondering how stackoverflow parses all sorts of different code and identifies keywords, special characters, whitespace formatting, etc. It does this for most code I believe, and I've noticed it's even sophisticated enough to understand the relationships between everything it parses, like so: String mystring1 = "inquotes"; //incomm...

Good way to define a method

What is the best / good way to implement method calls. For eg: From the below which is generally considered as best practice. If both are bad, then what is considered as best practice. Option 1 : private void BtnPostUpdate_Click(object sender, EventArgs e) { getValue(); } private void getValue() { ...

What tools should I use to visualize structure of my code?

I have an application written in Java. In is stored in several files. It uses different classes with different methods. The code is big and complicated. I think it would be easier to understand the code if I have a graphical model of the code (some kind of directed graph). Are there some standard methods for visualization of code. I am t...

Cleaning up a large, legacy Java project

I've been assigned to do some work on a huge Java project, and the influence of several iterations of developers is obvious. There is no standard coding style, formatting, naming conventions or class structure. It's a good day when I come across a class with Javadoc, and unit testing is a happy daydream. So far those of us on the proj...