General Question about Main() and forms etc

  • Thread starter Thread starter Charlie Tame
  • Start date Start date
C

Charlie Tame

Definitely a newcomer to C# (in fact to any programming after some years
away) and I'm finding lots of examples but they are sometimes confusing.

My concept of (say) QuickBasic was that you write a main program that calls
subroutines, thus breaking the thing up into manageable parts.

I started off assuming that in C# main() would be the program flow with
(say) several forms called in a similar way, each form doing it's part then
returning to the main() flow. Let me give an example.



Initialize stuff

Get a filename (call file input dialogue and validate)

Create Playlist (call creator or add to existing and validate)

Get more or play
(go back for filename or play)

Play (call media player)

Media ended
(go back or stop)

I hope this makes clear what I am asking. I visualized a form called from
main() for input and another for playing with the create playlist either in
the main flow or as a separate method. Playing would be a form of course and
I guess the decision to play more or stop could be in there as well.

Examples I've seen seem to put the majority of the code in the "Player"
form, even calling the "Get a filename" form from it, which leaves main()
doing virtually nothing except kicking off the player form.

The simple question is whether there's a right way and a wrong way to do
this or is it "Who cares as long as it works"? :)

also which is preferred.

Declare a public string fileName and then just have the form that gets
filename set it or is it better to do something like

string fileName getfilename ()

and have the getfilename method return it?

Sorry if these seem like stupid questions but there seem to be some
differences between what the book says and what people usually do if you see
what I mean, I take that to mean I am missing some reasoning here :)

Thanks for any suggestions, I have looked around but not found definitive
answers yet.

Charlie
 
in my opinion, main function is just a kick-off of the player form,
it's the normal way.

the rule is : put the code where it's handy. it's just like put you
usually used things in your room and things used by your parents in
their room.

in your example, get a filename and create a playlist it's the function
of the player, so we put it with the player code. if you want to open
another playlist, it's handy.

as for the getfilename, Property will be good
 
Thanks for the comment, I guess I'll get used to it :)

The trouble is I've been out of programming for so long that I have not
really kept up with trends and I think it's one of those things that "Stick"
if you are actually using it but gets lost if you don't. That's how it seems
to work for me anyways :)

Charlie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top