Click here to Skip to main content
15,909,835 members
Home / Discussions / C#
   

C#

 
GeneralDTS (Import/Export) Pin
ye win zaw25-Jan-05 17:13
ye win zaw25-Jan-05 17:13 
General.NET framework version questions... Pin
new_phoenix25-Jan-05 14:21
new_phoenix25-Jan-05 14:21 
GeneralRe: .NET framework version questions... Pin
Nick Parker25-Jan-05 17:27
protectorNick Parker25-Jan-05 17:27 
GeneralRe: .NET framework version questions... Pin
new_phoenix27-Jan-05 5:25
new_phoenix27-Jan-05 5:25 
QuestionCan no longer view Help(CHM) through windows application Pin
Mike Balfour25-Jan-05 13:29
Mike Balfour25-Jan-05 13:29 
GeneralProcedure Parameter Pointer Pin
Budi Zhu25-Jan-05 11:24
Budi Zhu25-Jan-05 11:24 
GeneralRe: Procedure Parameter Pointer Pin
Dennis C. Dietrich25-Jan-05 12:13
Dennis C. Dietrich25-Jan-05 12:13 
GeneralA Design question [offtopic?] Pin
moredip25-Jan-05 11:03
moredip25-Jan-05 11:03 
Hi all, I posted this on the General Discussion board, but it seems a little dead in there. Hopefully this isn't too offtopic for this board.....

I was hoping for some advice on 'best practices' regarding the design of an app I'm working on. It's a subscription-based web app in C#. Member data is stored in a DB table cunningly named Members. I've implemented a fairly simple Member class which essentially wraps access to a row in the table, with functions like:

static public Member FetchFromDB( int iMemberID );
public void UpdateInDB();
etc.

and getters/setters to map the contents of the Members row, like:
public DateTime ExpiryDate{ get{ return _expiryDate; } }
public StatusEnum Status{ get{ return _status; } }
etc.

I'm happy with this class as described so far. It does one job, maintains a constant level of abstraction/encapsulation, etc. However, My app also needs functionality like 'Check whether a member's ExpiryDate is in the past, and if so update their Status to Expired', or 'Update LastOnline to now'.
The way I've been doing this so far is to add methods to Member such as UpdateLastOnlineToNow(), CheckExpiryDate(), etc. Obviously this works fine, but I'm finding myself adding more and more 'utility' methods to Member, and I'm starting to think that Member has a 'bad smell' - it's still a wrapper for the DB, but it's also getting more and more higher-level functionality mixed into it.

This class is just an example, I'm also getting similar bad smells with various similar classes in my app (Message, for example, which encapsulates my message sending/receiving system).

So my question is, what do all you wise and esteemed CPians think? Have I been reading my Patterns books a bit too religiously? If I not, what would be the best way to refactor this? One thought I had is to break Member out into 3 classes, a low-level wrapper to the DB, a high-level wrapper that uses the low-level wrapper internally, and a utility class that also uses the low-level wrapper. Is this overkill?

Any other suggestions (or any thoughts at all) gratefully appreciated!

Cheers,

Pete

GeneralRe: A Design question [offtopic?] Pin
Skynyrd25-Jan-05 12:01
Skynyrd25-Jan-05 12:01 
GeneralRe: A Design question [offtopic?] Pin
moredip25-Jan-05 12:19
moredip25-Jan-05 12:19 
GeneralRe: A Design question [offtopic?] Pin
Skynyrd25-Jan-05 12:47
Skynyrd25-Jan-05 12:47 
GeneralRe: A Design question [offtopic?] Pin
moredip25-Jan-05 13:45
moredip25-Jan-05 13:45 
GeneralRe: A Design question [offtopic?] Pin
Anonymous25-Jan-05 21:56
Anonymous25-Jan-05 21:56 
GeneralCOM Port in Visual C# 2005 Pin
Juan Pablo G.C.25-Jan-05 9:08
Juan Pablo G.C.25-Jan-05 9:08 
GeneralRe: COM Port in Visual C# 2005 Pin
Stefan Troschuetz25-Jan-05 21:41
Stefan Troschuetz25-Jan-05 21:41 
GeneralCOM Port in Visual C# 2005 Pin
Juan Pablo G.C.25-Jan-05 9:06
Juan Pablo G.C.25-Jan-05 9:06 
GeneralRe: COM Port in Visual C# 2005 Pin
warnerja26-Jan-05 12:09
warnerja26-Jan-05 12:09 
GeneralHierachy on windows without MDI Pin
jpgarcia25-Jan-05 8:57
jpgarcia25-Jan-05 8:57 
Generalevent handling Pin
rchokler25-Jan-05 7:18
rchokler25-Jan-05 7:18 
GeneralRe: event handling Pin
Stefan Troschuetz25-Jan-05 21:25
Stefan Troschuetz25-Jan-05 21:25 
GeneralSpeed Hack Pin
Budi Zhu25-Jan-05 6:30
Budi Zhu25-Jan-05 6:30 
GeneralRe: Speed Hack Pin
Alex Korchemniy25-Jan-05 6:39
Alex Korchemniy25-Jan-05 6:39 
GeneralRe: Speed Hack Pin
Budi Zhu25-Jan-05 7:22
Budi Zhu25-Jan-05 7:22 
GeneralRe: Speed Hack Pin
Dave Kreskowiak25-Jan-05 8:26
mveDave Kreskowiak25-Jan-05 8:26 
GeneralRe: Speed Hack Pin
Budi Zhu25-Jan-05 11:27
Budi Zhu25-Jan-05 11:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.