473,795 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opinion question on the best method to structure a solution

2 New Member
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 1224
weaknessforcats
9,208 Recognized Expert Moderator Expert
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
3008
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 points. I usually use the Python bindings to GDAL http://www.remotesensing.org/gdal/ to manipulate geospatial data but there are no Python bindings for GDALCreateGCPTransformer()....
131
21692
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 get some good real world examples. Fire away! :) Regards, Peter Foti
11
2571
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 opaque data types to transfer information in between them. At some stage I was stuck and needed to make a variable global, and I also needed to make the struct declaration public to some other parts. Looking through the code I found out that lots...
3
2038
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 DataNode is changed, it raises "Changed" event. The class has a reference to the DataNode it is being contained in: - DataTree - tree like data structure that contains DataNodes; When
5
5879
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 the original byte () value to the xml and viceversa? I've tried a lof of way, as encoding.utf8, encoding.unicode, bitconverter, etc, but the only working solution I found is Convert.XXbase64String: writer.WriteElementString("ContentSignature",
20
1609
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 with useraccounts (username, password etc), the user should be notifed to login. Now, in my opinion their are 3 ways to cope with situation: 1. Exit the method nicely with an errorcode (eg access denied, specify accountinformation and try...
4
1527
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 for it. If I click the checkbox, the new subdirectory gets the same name as the higher subdirectory (which is the application name). For example if the project is called Test, then the subdirectory structure looks like Visual Studio 2005...
7
1977
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 processes inputs from a serial port. The serial port data is processed when DataReceived event occurs from the SerialPort instance. If the DataReceived event handler and the MainForm are in the same thread, and the user is calling a method in...
6
2766
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 intensive, so would prefer to retrieve the info once at the beginning of the session, and have the data persist for the session 3) several forms in the app need to reference the information retrieved in #2 (the information specific to the user) 4)...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10214
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10001
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.