Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a small application that will reset the entire “environment” consisting of various machines and applications.

Machine names are added via config file - this is read, the appropriate services are stopped and log files deleted. My problem isn’t how to do this (its already working) a bit more elegantly, but due to my lack of experience, I'm curious of the proper architecture.

Right now I feel it’s a mess, large blocks of code, in 5 different classes (delete, processes management, etc) and I would like to make this available for others to enhance.

For example, Ive been thinking about breaking up the DeleteLog class into separate classes by machine, adding and interface and programming each of them to the interface (Strategy Pattern?).

I've also contemplated using delegates (to which I'm very clueless, but it's always a good time to learn).

share|improve this question

closed as not a real question by Jimmy Hoffa, Martijn Pieters, MichaelT, gnat, GlenH7 Apr 18 '13 at 15:00

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Although these are custom internal applications, I do not have access to any code. In order to start and stop applications Im getting the Service name via SystemProcess.ServiceController.GetServices then stopping (or starting) by using ProcessStartInfo and calling sc.exe. – Ryan May 12 '11 at 20:53
It seems you are over-enginnering. What you said (stopping processes and services, deleting logfiles) are more appropriately done through scripting, my suggestion is to use powershell. You can learn it easily enough. – Pratik May 12 '11 at 23:11
up vote 1 down vote accepted

Break it down

Super High level:


C -> P -> A |
  • Configuration File/Data is read in (C)
  • Data is processed & actions taken (P)
  • Results of actions are analysed (A)
  • Feedback to Process section if needed (P <-> A )

Obj represents an "Environment" object (e.g a computer & its related properties), as seen in the diagram it flows forwards through each module.


Parse Module

Process Module

Feedback (Monitor Module)

based upon the above re-write your classes around those major functions. Each modules methods should reflect its main purpose.

share|improve this answer

What you're doing sounds pretty simple, and it works. 5 classes sounds enough, the danger if you start splitting into fancy patterns is that it becomes harder to read. I'd suggest finishing up and moving on to something else.

share|improve this answer

What sort of applications are you working with? It is hard to recommend something without actually looking at the specifics of what you are doing... But, perhaps, you can simplify your application by ensuring the applications you are serving have uniform interface for doing things you need. For example, each app has a script in folder X which can do start, restart and stop. You can also add some meta data into these scripts to help you manage the applications. Something like init.d on unix basically. Then your app just reads files from directory X and just runs them.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.