473,396 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Opinion question on the best method to structure a solution

I am compiling 4 different programs, each using a lot of the same core functions and files. One of the programs requires access to a large third party library, the others do not.

I have created an "options" structure suitable for all 4 programs. The way the options structure is filled out however can differ depending on the program which is to be used. Most of it is trivial stuff... "do I write to stdout?", etc. However, one of the programs, in the options function, may attempt to access those functions calling the large third party libraries if some information is not available. Moreover, it must do this before the rest of the options can be processed, and its purpose is intricately tied to task of options processing.

How would you set up the source code in files suitable for this? Here are some choices as I see them:

1. Use one options.cpp file, and link everyone against the large library.
2. Use one options.cpp file, and move the offending line of code elsewhere.
3. Tie the options processing, usage statements, etc., into the same file containing the main() for each program.
4. Create different .cpp files for the filling out of options data (p1-options.cpp, p2-options.cpp, ...) where each program links only to the instructions for options filling that it needs.
5. Create one options.cpp file, with #ifdefs for each program. Use makefile trickery to compile different options object files (p1-options.o, p2-options.o, ...) all from the same one source file.

I like option 5 the best, which is to say I don't like it much, but I have yet to come up with a better thought as to how to do it. Hence the request for suggestions/comments. As per my thoughts on each:

1. Unnecessary Bloat
2. Not a reliable solution for the future
3. Creates too much code in the files containing main()
4. Not very elegant, and a larger traversal should an option need to be changed. Basically more clunky than (5).
5. Still clunky

Thanks!
Feb 29 '08 #1
1 1206
weaknessforcats
9,208 Expert Mod 8TB
I like option 6 or 7:

6) each function is in it's own .cpp file. Just add the .cpp files as needed to your project. Remeber, adding a .cpp file to a project does not require that you make a copy. All projects can use the exact single .cpp file.

7) group commonly accessed functions into a library that is built as a separate project. Add the library as necessary to projects that need the functions.


You should not have an "options" file unless you are preparing code for different platforms, like Unix. Linus, Windoes, AIX, etc.

Your "options" file is kinda like an uber-makefile and I don't think you need the complexity.
Mar 1 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Kyler Laird | last post by:
I'm trying to do some georeferencing - using points of known location (ground control points, GCPs) on an image to develop a polynomial that can be used to approximate the locations of other...
131
by: Peter Foti | last post by:
Simple question... which is better to use for defining font sizes and why? px and em seem to be the leading candidates. I know what the general answer is going to be, but I'm hoping to ultimately...
11
by: Capstar | last post by:
Hi, I am working on an application, which will run embedded without an OS. The app is build up out of a couple of well defined parts. At first I wanted to keep those parts seperated and use...
3
by: Sasha | last post by:
Hi everyone, Here is my problem: I have the following classes: - DataNode - this class is designed to hold some data and will be contained in a tree like data structure DataTree. When...
5
by: Trapulo | last post by:
Hello, I need to send to a webservice a parameter that is a string containing an XML doc. In this xml, a node value came from a byte array (it's an RSA signature). What is the best way to convert...
20
by: C# Beginner | last post by:
I'm currently creating a database class, which contains a member called Open(). With this method users can open different databases. When a user tries to open a database which happens to be secured...
4
by: Steve | last post by:
When I create a new project in 2005, and I go to save the project files, vb.net displays a dialog box that repeats the name of the application and has a checkbox if I want to create a new directory...
7
by: Sin Jeong-hun | last post by:
I've using thread a lot in C#, but all of them were just single method with no return value or paramenters. It may sound bizarre but, can't it be a class? I'm writing an Windows application that...
6
by: mirandacascade | last post by:
Assume the following: 1) multi-user environment 2) when user opens app, want to run some code that retrieves some information specific to the user...retrieving this information is somewhat i/o...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.