473,408 Members | 1,870 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,408 software developers and data experts.

advice on dotnet architecture please

I'm pertty new to designing software, so I have what's probably a very
simple question. I'm designing a Windows Forms application in C#. I have a
class LogMessage that will hold a single log message. I am creating a
Logger class where the constructor will take in a LogMessage and log it to a
file and update a Windows Form.

My question is, should Logger be a static class? And in what file/function
should I create the Logger instance so that it's accessible from all forms
and other classes? Thanks for the help!
Oct 18 '06 #1
2 1144
First, you will want to create a separate Class Library project for your
LogMessage class, so that it can be used in any Solution of another project,
and when you're finished, add that project to your application's Solution.

Create the LogMessage class in such a way that it does not need to know
anything about the client using it. This can be done by exposing properties
and methods that a client class can work with.

In order for your Form to be updated from the LogMessage class, you will
want to add Events to the LogMessage class that the client class can
subscribe to.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"SoxFan44" <so****@44.netwrote in message
news:u2**************@TK2MSFTNGP04.phx.gbl...
I'm pertty new to designing software, so I have what's probably a very
simple question. I'm designing a Windows Forms application in C#. I have
a class LogMessage that will hold a single log message. I am creating a
Logger class where the constructor will take in a LogMessage and log it to
a file and update a Windows Form.

My question is, should Logger be a static class? And in what
file/function should I create the Logger instance so that it's accessible
from all forms and other classes? Thanks for the help!

Oct 18 '06 #2

SoxFan44 wrote:
I'm pertty new to designing software, so I have what's probably a very
simple question. I'm designing a Windows Forms application in C#. I have a
class LogMessage that will hold a single log message. I am creating a
Logger class where the constructor will take in a LogMessage and log it to a
file and update a Windows Form.

My question is, should Logger be a static class? And in what file/function
should I create the Logger instance so that it's accessible from all forms
and other classes? Thanks for the help!
No need to re-invent the wheel anyways - get Log4Net, a
de-facto-standard logging solution. But yes, your logs should
generally be a static/singleton/global/whateveryouwant to call it. The
log is a single, physical logfile, and every class must write to that
log, so just having it accessible by all (in it's own project) is
probably ideal.

Oct 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tamir Khason | last post by:
Hi, all This time I need advice - no help ;) I have following architecture: 30 server with 100 devices connected each one Each "device" implement some (between 1 and 10) different interfaces All...
4
by: Heath Kelly | last post by:
I need advice on correct usage of ADO.NET in an ASP.Net environment. I have an ASP.Net application that accesses data through a referenced class library. Things start to break down when multiple...
6
by: V. Jenks | last post by:
I apologize if this is the wrong forum for this, I could not locate one that was exactly appropriate for this topic. Over the last couple of years I've been doing a lot of reading on design...
0
by: CodeMonkey | last post by:
Hi, I was wondering if anybody could give me some advice on how to structure an application that I am about to start work on. The vague requirements will be: 1) Always-On monitoring of data...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
0
by: =?Utf-8?B?VGlt?= | last post by:
I have written both a client (SoapClient) and server (SoapServer) application using WSE 3.0 with the TCP transport. These are completely standalone applications (the Server runs as a Windows...
3
by: Jim Horvath | last post by:
I know how to create exe applications in dotnet that use functions supplied by pre-existing dlls. How do you turn that around? I want to create an exe program that will be the pre-existing piece....
13
by: terry.holland | last post by:
I have a three tiered CRM application (ASP.Net UI, VB.Net Business Layer & VB.Net Data Access Layer) that consists of number of classes. The application will be deployed to a number of clients. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.