Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
First off, my company is into power grid, not IT, so software is kinda a secondary role here.
I work on a power system simulation software, very old code base in C++ with MFC, like 15 years old. What we do is take large amounts of data, ~100,000 floating point values then format and write to a text file (most of the code actually uses the C FILE structure to do this). Then, it's read by a separate engine exe which computes the electrical algorithm (Electrical algorithms are mostly numeric solutions of system of diffn equations) and then writes back huge amount of data to another text file, which we read and update the UI.
My question is, is this how it should be done? It there a way to skip writing into the text file and directly pass the data to the exes?
exes are called using CreateProcess() MFC function.
EDIT::
Sorry, site won't let me comment.
#Vlad Feinstein Well, yes, it's like a Ladder. A thing called load flow solves power flow through the lines, which in turn will be used to find stability of the systems, which in turn for overvoltage ect. It's huge, the UI is million+ lines of code, engine exes another million maybe.
Doesn't MFC already implement IPC using Dynamic Data Exchange? I can pass strings to another process's PreTranslateMessage() func. A scaled up version of that?
There is no such a thing as "should be done as ..." there are multiple methods to do IPC and while the method you describe might not be the fastest, it is a viable solution nevertheless. If the performance doesn't bother you in this particular case you should not bother with modifying it. It is exactly the case where the phrase "if it ain't broke, don't fix it" applies.
Probably, you would not want to make any new IPC in the application that way, though.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm planning the network communications system for a program. The program is divided a client and a server class, but I might split them into separate programs if they get too big, and nothing else prevents it.
At the moment, all of the network communication is to call set and get functions on the server (of which their are about 500, and I expect to generate about 500-1,600 requests per second across eight clients in typical operations).
My current plan is to use a basic network API to send machine code inspired Opcodes to the server as a string, along with a few bytes of parameters, and have the server select the function and interpret the parameters using a massive switch statement.
However, with hundreds of possible function to call, this will get A) hard to read, and B)slow to implement. I'm also a bit concerned about the performance of large switch statements.
In light of that, could anyone confirm if this is the best way to implement function calls over a network, or tell me if there's a better way. I'd love a magic API that allows be to do something like x = callServerFunc(server, function, parameter1...) but my searches have not yet found such a library.
You can write your code from scratch. Feel free on how to do it.
Or you can use one of many ready mature technologies. Just google for CORBA, DCOM, XPCOM and so on. You can look at Remote call in common. Or consider existing web-based technologies with different data formats. This is just a starting point. This tehnologies are mature but heavyweight. You'll need some knowledge and practice to start with them.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm currently writing a developper documentation of a program I just wrote and which has to be continued by somebody else.
I'm documenting my code using Doxygen, but I'd like to show a more global view, using for instance flow charts filled with the name of the functions and the parameters they send to each other. But I also have to represent events, and it seems to me that flow charts are not the best for that, or a least I don't really see how to do it right and clear.
So Am I right? What would you need to catch on with a development of an already started application? Is there a better alternative than flow charts and UML?
From a general familiarisation perspective, I like seeing clear and detailed requirements specifications. This is lacking in the majority of cases in my experience.
From a design perspective, I like seeing state diagrams for state transitions, UML diagrams for general code structure and relationships and communication diagrams for information about data flows.
The more documentation you can give, the better it'll be for the next guy. But bear in mind that documentation can go out-of-date very quickly, so your (good) code comments and doxygen output are likely (but not necessarily so) to be more up-to-date than anything else you write.
As someone who picked up a 35,000 line Java project with 3 comments 2 of which were "this is gross" and "yeesh" I can say that I want to know what the abstract base classes are, what the flow of the program is, and any namespaces or global variables defined.
What's really helpful to me is a paragraph or two that says something along the lines of "main creates a driver of some base class which then reads in the xml file using some file reader and sets up an output object of type DefaultOutput before it executes the driver.run() function which ostreams the std:out to a file called output.txt and std::err to log.txt.
That paragraph would save me hours of picking through your code to figure out what gets used all the time.
It's also really helpful to have a "this depends on this so don't change it or you'll ruin literally everything" for any finicky code that might be present.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have code to solve 2D truss structures implemented in C++ (as a console application).
I would like to add some simple graphics to it in order to visualize the initial structure and the deformed form. Example: http://people.rit.edu/pnveme/VenkatCOMSOL42/COMSOLTruss2D/ExtractingInfoinMATLAB_01.png
But I have no idea of how to add graphics in any way. How can I implement this kind of graphics?
Cross platform (preferred) or windows.
I doubt this is the answer you want, but to be honest, implementing plotting functionality isn't trivial, even if you're not doing it from scratch: you'll have to review a number of libraries, choose one, and get to grips with it.
Unless it's essential that the plotting functionality be integrated with the solver (e.g. for a product), I think you ought to consider simply exporting your results to, say, a simple ASCII matrix format that can be easily imported into a variety of environments with extensive and flexible plotting capabilities, one or more of which you probably already know (e.g. Matlab, R, Octave, etc.)
One option would be to generate a file which can be shown by another program. For example, generating SVG and using the browser to display it sounds like it would be good for your case, you can even easily include it in a report.
Check out SDL: http://www.libsdl.org/ It's cross-platform and has a ton of features. It maybe a bit overwhelming for your task, but I thought it was very easy to grasp when I was a newcomer.
There is a derivative of SDL that lets you draw basic shapes such as lines and points and is incredibly easy to use:
http://sdl-draw.sourceforge.net/
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am writing a particle tracker in C++ which releases a particle in a numerical flow field and then integrates in time to calculate the new position of the particle.
This is done for as many particles as time allows (hopefully millions) for approximately 10k timesteps per particle. During the simulation I generate a double array1[10k][10] and int array2[10k][4] which represent the 14 characteristics of each particle at each timestep.
My question is how to write such a 'matrix' to a notepad++ readable .txt file (for the purpose of post-processing). Both arrays are to be merged in the file such that a [10k][14] matrix is formed.
Personally I have only had experience with fprintf but Visual Studio appears to have some security issues with that function. Other functions I have seen are streams (more secure I suppose) and fwrite.
Could someone enlighten what the advantages and disadvantages are of the similar functions? And possibly what the better choice is for my problem (if there is one).
Kind regards,
EJG
Newer Microsoft compilers give you various "security" warnings if you do not define _CRT_SECURE_NO_WARNINGS. See here and here
The _s versions it will suggest using instead are microsoft specific, so if you ever wanted to compile your code for another platform you would need to re-write.
There are other ways to write to files in C++. You could consider using a C++ std::ofstream instead.
Or, you can just write to std::cout and stream the program output to a file
myprogram.exe > output.txt
If you want to use fprintf, just add #pragma warning(disable:4996) at the top of your source file and it won't complain about you using it.
Otherwise you can always use fprintf_s() or whatever the alternative is that VS provides.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I was fascinated by the "press Tab to search site" feature in chromium, so naturally I wanted to see how exactly it was implemented in code.
A little background for anybody who aren't familiar with this. After navigating to some site, say wikipedia, and doing a search, chromium remembers the name of the query variable and will let you press tab and search the site directly from the address bar. Neat!
Problem is the codebase for chromium is huge and I've had no luck in finding the method/function that handles this.
How do you approach a large codebase when you are looking for the implementation of a particular piece of functionality? Any tricks for narrowing it down? Preferably it should not require building the software with debug symbols and following the flow through the program.
There is no one size fits all approach to this sort of problem. But for this one I would try these:
If there are any unique messages associated with the operation, grep all the source files for that string. A common pitfall of this technique is that messages might be assembled from pieces within the application, so it is often helpful to grep for a unique short phrase—or even a single word—to identify the source of the message. Once the text is found, then finding what references it often requires more text searches.
Trace execution from an easy-to-find point, like the command processing and dispatch loop. I'd look for a Tab key case and follow where it leads.
Look at source code directory and filenames for hints. Software is often constructed rationally, with good engineers dividing and conquering in a sensible way.
A test coverage tool is a good way to do this. They tell you what part of an application
is exercised by a test.
Instrument the application to collect test coverage. Execute the functionality you care about. Record what is executed. Execute something similar, but not the same as the functionality you want. Record this. Take the set difference over the coverage. The diff selects code involved in the functionality of interest, excluding code which is common to similar functionality.
Ask the Chromium team. They don't give points or bronze pixels but they're definitely the authority and right people to ask this sort of questions.