Click here to Skip to main content
15,888,521 members
Home / Discussions / C#
   

C#

 
AnswerRe: Time Difference Calculation In C# Pin
Abhinav S12-Sep-10 18:25
Abhinav S12-Sep-10 18:25 
GeneralRe: Time Difference Calculation In C# Pin
Sanket.Patil12-Sep-10 19:33
Sanket.Patil12-Sep-10 19:33 
AnswerRe: Time Difference Calculation In C# Pin
Mycroft Holmes12-Sep-10 19:52
professionalMycroft Holmes12-Sep-10 19:52 
AnswerRe: Time Difference Calculation In C# Pin
J4amieC12-Sep-10 23:25
J4amieC12-Sep-10 23:25 
AnswerRe: Time Difference Calculation In C# Pin
Luc Pattyn13-Sep-10 2:36
sitebuilderLuc Pattyn13-Sep-10 2:36 
QuestionHow to represent this type of data in a c# app? Pin
stephen.darling12-Sep-10 11:37
stephen.darling12-Sep-10 11:37 
AnswerRe: How to represent this type of data in a c# app? Pin
Luc Pattyn12-Sep-10 11:57
sitebuilderLuc Pattyn12-Sep-10 11:57 
AnswerRe: How to represent this type of data in a c# app? Pin
Keith Barrow12-Sep-10 12:04
professionalKeith Barrow12-Sep-10 12:04 
stephen.darling wrote:
1)How should I represent the available options?


IMO, enums are an indicator that there is an underlying problem with you class structure (others will disagree with me on this point [edit - see Luc Pattyn's response above]).
For example:

  • Expired - can it be determined from an expiry date? If so set an expiry date property and have a read-only IsExpired property
  • Trial - create a boolean IsTrial property
  • Invalid - Why would you issue an invalid license? If you really do need this, you could have an IsValid property instead, preferably this would be read-only and determined from the object state (e.g. is expired and is trial, or some other combination of "rules".

Doing this would allow you to have an expired trial license and expired normal license. Another way to factor out the enum is to create a subclass per state, but I don't think this suits your problem well.

stephen.darling wrote:
2)What functions should go in the license class, what in the main form


Anything relating to the function of the license should go in the License class, e.g. if the license can be extended (i.e. it's expiry date moved later), this should handled in the License class. The form should only deal with showing the information to the user and calling the License class's methods. In the example I gave, you might have a button to extend the license by a year. In this case, the button event handler is in the form, but it would call the code on the License class to do the actual update (remember that anything long-lived, such as database or service calls should be done on another thread). The separates the concerns of what the application does out from how it interacts with the user. To start with this will seem like a pain, but as the application grows your life will be made easier.


stephen.darling wrote:
If I have a form to get the serial number, should this be called from my main form, then the serial number passed into my license class, or should I invoke the license class from my main form and then call the serial dialog from the license class?


Ideally, the License class should get the serial number, called by the form. You need to clarify what the form to get the serial number actually adds before I can help with this more fully.[Edit] Although I might look like I contradict Luc on this matter, I agree that the GUI should not do license stuff, and the license model should not do GUI stuff! I think it is probably the responsibility of the License class to get its serial, but this is dependant upon the work the UI needs to do to get the serial number.

Like Luc said, it is confusing, but with experience you'll get the hang of it, at least you spotted this problem beforehand, unlike far too many others Smile | :) ...

ragnaroknrol The Internet is For Porn[^]

Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

AnswerRe: How to represent this type of data in a c# app? Pin
PIEBALDconsult12-Sep-10 12:36
mvePIEBALDconsult12-Sep-10 12:36 
GeneralRe: How to represent this type of data in a c# app? Pin
stephen.darling12-Sep-10 16:10
stephen.darling12-Sep-10 16:10 
GeneralRe: How to represent this type of data in a c# app? Pin
PIEBALDconsult12-Sep-10 16:22
mvePIEBALDconsult12-Sep-10 16:22 
QuestionTaking screenshots of PCs on LAN Pin
teknolog12312-Sep-10 8:50
teknolog12312-Sep-10 8:50 
AnswerRe: Taking screenshots of PCs on LAN Pin
OriginalGriff12-Sep-10 9:23
mveOriginalGriff12-Sep-10 9:23 
GeneralRe: Taking screenshots of PCs on LAN Pin
teknolog12312-Sep-10 9:29
teknolog12312-Sep-10 9:29 
GeneralRe: Taking screenshots of PCs on LAN Pin
OriginalGriff12-Sep-10 9:43
mveOriginalGriff12-Sep-10 9:43 
GeneralRe: Taking screenshots of PCs on LAN Pin
Eddy Vluggen12-Sep-10 9:53
professionalEddy Vluggen12-Sep-10 9:53 
AnswerRe: Taking screenshots of PCs on LAN Pin
Luc Pattyn12-Sep-10 9:53
sitebuilderLuc Pattyn12-Sep-10 9:53 
GeneralRe: Taking screenshots of PCs on LAN Pin
teknolog12312-Sep-10 10:04
teknolog12312-Sep-10 10:04 
GeneralRe: Taking screenshots of PCs on LAN Pin
Luc Pattyn12-Sep-10 10:12
sitebuilderLuc Pattyn12-Sep-10 10:12 
GeneralRe: Taking screenshots of PCs on LAN Pin
teknolog12312-Sep-10 10:15
teknolog12312-Sep-10 10:15 
GeneralRe: Taking screenshots of PCs on LAN Pin
Luc Pattyn12-Sep-10 10:18
sitebuilderLuc Pattyn12-Sep-10 10:18 
QuestionPainting on transparent background multiple times Pin
fdsfsa76f7sa612-Sep-10 1:47
fdsfsa76f7sa612-Sep-10 1:47 
AnswerRe: Painting on transparent background multiple times Pin
Abhishek Sur12-Sep-10 2:39
professionalAbhishek Sur12-Sep-10 2:39 
GeneralRe: Painting on transparent background multiple times Pin
fdsfsa76f7sa612-Sep-10 3:06
fdsfsa76f7sa612-Sep-10 3:06 
GeneralRe: Painting on transparent background multiple times Pin
Dave Kreskowiak12-Sep-10 5:13
mveDave Kreskowiak12-Sep-10 5:13 

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.