Y'all are a bunch of wankers!

Design question

So I'm going to read from a file data of a windows process in the form of path of an exe and it's parameters.

I am also getting for each process the count of running instances.

string path
string params

int nRun


Do you think that it should be split in 2 classes/interfaces?

i.e process  and  run info?
Permalink Ron 
April 15th, 2017 4:00pm
Permalink Woo Woo 
April 15th, 2017 6:02pm
Permalink Bored Bystander 
April 15th, 2017 7:15pm
Permalink brone 
April 15th, 2017 8:25pm
Who cares?
Permalink Georgeous George 
April 15th, 2017 8:42pm
Don't know
Permalink Terrorist Watch 
April 15th, 2017 8:43pm
Won't Say
Permalink AntiAntiFa 
April 15th, 2017 9:04pm
Can't talk

Won't talk

Not the one
Permalink Zathras 
April 15th, 2017 9:41pm
Seriously, WTF are you building or really trying to do? Your leading sentence isn't phrased clearly at all.
Permalink Bored Bystander 
April 15th, 2017 9:43pm
He's building a high frequency trading system, obviously. Yes, you should minimize the memory footprint so that the lockless programming techniques allow for efficient cooperation of the CPU caches into achieving the low latency, high throughput you strive for.
Permalink Io 
April 16th, 2017 12:56am
I think he's saying he wants to read a file like so:

Program file path                Commandline args
C:\Windows\System32\notepad.exe  C:\names.txt
C:\FullNamePrintingProgram.exe    "First name", "Last name"

And spin off new instances of each of these processes.

And he wants to be able to get a count of instances of each executable at a given point in time.

And he wants to be able to terminate them.

If that's what you're saying, Ron, then you're slightly off the mark. Remember, a process itself is an instance of an executable image laid out in memory. So what you're calling "run info" *is* in fact the process.

There are no *shoulds* but your design should closely resemble something like so:

// or interface too
// or you may call it by any number of names
// such as PortableExecutable or PEImage or
// BinaryImage or PortableExecutableImage
class ExecutableImage : IEquatable<ExecutableImage> {
  public string Location; // path to the binary image file
  public ICollection<Instance> Instances;

  public ExecutableImage(string location) { }

  // yada
  public bool IsComServer;
  public bool IsRemotable;
  public bool IsNative;
  public bool IsManaged;

class Instance {
  // to backtrack to the PE image
  public ExecutableImage ExecutableImage;
  public int PID; // process ID
  public string[] CommandLineArgs;
  // create a new process
  public Instance(ExecutableImage image) { ... }

  public static void Terminate(int pid) { ... }
  public void Terminate();

  public static void Kill(int pid) { ... }
  public void Kill() { ... }

  // yada

Some such.

Again, it all depends on the larger goal you are trying to accomplish.

That, and don't take OOPs too seriously. Inheritence is just a code re-use trick and all of OOP, the truth be told, is a lame attempt to re-use code.

But if you do use OOP, make sure you think deeply about the boundaries between concepts. You literally have to pick a nit when defining classes and interfaces, like a control freak.
Permalink Woo Woo 
April 16th, 2017 12:57am
I don't take OPs that seriously. :)
Permalink Bored Bystander 
April 16th, 2017 12:59am
Woo Woo, thanks man, for your elaborate answer....
Permalink Ron 
April 16th, 2017 4:14am
You're welcome. But here's how you can make help more available to you: work on your English. Try to write your question clearly so anyone can understand. Take the time and put in some effort into it.

If you don't so that, people don't want to take the pain answering your question because they feel cheated that they did most of the work and you got away with doing nothing.
Permalink Woo Woo 
April 16th, 2017 7:29am
Hey Woo Woo, You are right.... English is not my native tongue...

But will try to do better...
Permalink Ron 
April 16th, 2017 9:51am
More homework?
Permalink Terrorist Watch 
April 16th, 2017 1:08pm
Wow, can't remember the last time I saw a "pls send teh codez" on CoT.
Permalink Just Me 
April 16th, 2017 11:41pm

This topic is archived. No further replies will be accepted.

Other topics: April, 2017 Other topics: April, 2017 Recent topics Recent topics