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

OOP and Console Apps

I'm learning C# via console apps (to avoid getting bogged down in Windows
stuff). I'm wondering how the OO paradigm would work.

Say I'm developing 'classic' menu-driven apps where a menu gives a number of
options, you choose an option and then do something. Traditionally I would
set up a loop - waiting for the Exit option - and, say, create database
records, update them or delete them.

This would make my Main() look a bit 'procedural', I think. Are there any
examples for console apps which implement 'good' OO design?

Thanks
Aug 19 '08 #1
5 2987
On Mon, 18 Aug 2008 19:10:08 -0700, Paolo
<Pa***@discussions.microsoft.comwrote:
I'm learning C# via console apps (to avoid getting bogged down in Windows
stuff). I'm wondering how the OO paradigm would work.

Say I'm developing 'classic' menu-driven apps where a menu gives a
number of
options, you choose an option and then do something. Traditionally I
would
set up a loop - waiting for the Exit option - and, say, create database
records, update them or delete them.

This would make my Main() look a bit 'procedural', I think. Are there any
examples for console apps which implement 'good' OO design?
I don't know about examples. But I would say that the question of OOP is
basically orthogonal to the question of user-input paradigm, as well as to
the question of "procedural" or "imperative" versus other ways of
describing the code.

OOP has to do with how the code is structured and related to the data.
You can easily have OOP with or without an event-driven input model.
Conversely, you can implement an event-driven input model with or without
OOP. In fact, event-driven user input -- as part of GUI operating systems
-- has been around a lot longer than OOP has been popular for OS and
application development.

In your "'classic' menu-driven" application, just because you have a loop
waiting for user input and you're dispatching operations based that in an
imperative way, that doesn't mean that the code and data can't be
organized in an object-oriented way. So, if you want to code your program
in an OOP way, I'd say just do that. :) Heck, writing your code in C# I
think you're going to have some significant effort avoiding OOP (but I
can't speak for whether you'll do _good_ OOP or not :) ).

Pete
Aug 19 '08 #2
I concur with Peter's comments. Being procedural does not mean it is less
OOP. OOP is about organizing your code into objects. Most applications are
not procedural simply because they are written to respond to Windows events,
which you are currently avoiding.

Beyond that, I would recomend that you start using the Windows interface.
It's not easy and you need to learn that as well for most application types.
..NET also provides many UI-related objects to help further provide examples
of OOP.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Paolo" <Pa***@discussions.microsoft.comwrote in message
news:86**********************************@microsof t.com...
I'm learning C# via console apps (to avoid getting bogged down in Windows
stuff). I'm wondering how the OO paradigm would work.

Say I'm developing 'classic' menu-driven apps where a menu gives a number
of
options, you choose an option and then do something. Traditionally I would
set up a loop - waiting for the Exit option - and, say, create database
records, update them or delete them.

This would make my Main() look a bit 'procedural', I think. Are there any
examples for console apps which implement 'good' OO design?

Thanks
Aug 19 '08 #3
Peter: as you say, with C# I am led down the OOP path. As it happens I have
already started, having developed a ScreenManager class and a Menu class. I
need to spend a bit more time researching/thinking about class(es) to
encapsulate database operations.

"Peter Duniho" wrote:
On Mon, 18 Aug 2008 19:10:08 -0700, Paolo
<Pa***@discussions.microsoft.comwrote:
I'm learning C# via console apps (to avoid getting bogged down in Windows
stuff). I'm wondering how the OO paradigm would work.

Say I'm developing 'classic' menu-driven apps where a menu gives a
number of
options, you choose an option and then do something. Traditionally I
would
set up a loop - waiting for the Exit option - and, say, create database
records, update them or delete them.

This would make my Main() look a bit 'procedural', I think. Are there any
examples for console apps which implement 'good' OO design?

I don't know about examples. But I would say that the question of OOP is
basically orthogonal to the question of user-input paradigm, as well as to
the question of "procedural" or "imperative" versus other ways of
describing the code.

OOP has to do with how the code is structured and related to the data.
You can easily have OOP with or without an event-driven input model.
Conversely, you can implement an event-driven input model with or without
OOP. In fact, event-driven user input -- as part of GUI operating systems
-- has been around a lot longer than OOP has been popular for OS and
application development.

In your "'classic' menu-driven" application, just because you have a loop
waiting for user input and you're dispatching operations based that in an
imperative way, that doesn't mean that the code and data can't be
organized in an object-oriented way. So, if you want to code your program
in an OOP way, I'd say just do that. :) Heck, writing your code in C# I
think you're going to have some significant effort avoiding OOP (but I
can't speak for whether you'll do _good_ OOP or not :) ).

Pete
Aug 19 '08 #4
Jonathan: thank you. I have quite a bit of experience of event-driven Windows
programming through using Delphi/Object Pascal and that should stand me in
good stead when I tackle .NET WIndows forms etc.

I decided to concentrate initially on console apps so that I could focus on
learning 'pure' C#, its features and OOP before digging into the class
libraries.

"Jonathan Wood" wrote:
I concur with Peter's comments. Being procedural does not mean it is less
OOP. OOP is about organizing your code into objects. Most applications are
not procedural simply because they are written to respond to Windows events,
which you are currently avoiding.

Beyond that, I would recomend that you start using the Windows interface.
It's not easy and you need to learn that as well for most application types.
..NET also provides many UI-related objects to help further provide examples
of OOP.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Paolo" <Pa***@discussions.microsoft.comwrote in message
news:86**********************************@microsof t.com...
I'm learning C# via console apps (to avoid getting bogged down in Windows
stuff). I'm wondering how the OO paradigm would work.

Say I'm developing 'classic' menu-driven apps where a menu gives a number
of
options, you choose an option and then do something. Traditionally I would
set up a loop - waiting for the Exit option - and, say, create database
records, update them or delete them.

This would make my Main() look a bit 'procedural', I think. Are there any
examples for console apps which implement 'good' OO design?

Thanks

Aug 19 '08 #5
>I'm learning C# via console apps (to avoid getting bogged down in
Windows
stuff). I'm wondering how the OO paradigm would work.<

Paolo... IMHO, if you are trying to learn OOP there is no reason to
avoid using
Windows Forms under .NET. You are on the right track in writing a
console
app first. Specifically, you can write a class that encapsulates the
logic and
algorithms of your application and test it as a console application.
This
separates the MODEL from the event handling and GUI code, the VIEW-
CONTROLLER. Once you have written and tested the model class, you can
write a Windows Form application that uses the logic in the model class.

As an example. Many GUI Unix Chess programs differ only in the GUI code.
The actual logic to mimic the chess game is in a separate class that can
be
called and queried from a console. So in Unix terminology the chess game
logic and algorithm is the ENGINE. Different programmers can then write
their
own "chess games," actually different GUIs, that call the same engine.
In Unix
the GUI is considered the user_INTERFACE.
>>Say I'm developing 'classic' menu-driven apps where a menu gives a
number of options, you choose an option and then do something.
Traditionally I would set up a loop - waiting for the Exit option - and,
say,
create database records, update them or delete them. <<

The framework takes care of all this event looping code. It has been a
very
long time since I wrote my own event looping code and I don't miss it at
all.
NET has the concept of delegates and events that _could_ be thought of
as
"sending messages to interested objects" that implement the delegate.

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Aug 19 '08 #6

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

Similar topics

4
by: Ken VdB | last post by:
Hi everyone, One of the things that really interested me about VS.net was that I can now create a console based app using VB. I have a number of QuickBASIC 4.5 apps which we are still using and...
5
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough...
17
by: MumboJumbo | last post by:
Hi I have a really basic question hopefully some can help me with: Can you write a (i.e. one) C# project that works from the cmd line and gui? I seems if i write a GUI app it can't write to...
6
by: MeowCow | last post by:
I will try and make my question with out being too long winded. I have been doing a lot of reading on how to do multithreading and I have implemented the code from the following example on...
7
by: Robert | last post by:
Hello, I'm using Pythonwin and py2.3 (py2.4). I did not come clear with this: I want to use win32-fuctions like win32ui.MessageBox, listctrl.InsertItem ..... to get unicode strings on the...
5
by: Jon Davis | last post by:
Is there such a thing as a Windows standard for killing a console app that is monitored by a System.Diagnostics.Process object? I'm hosting several C# console apps in a C# Windows service and...
0
by: serpius | last post by:
Hello Everyone, I am a beginner in VB.Net 2003 and am taking classes in beginning VB.net. To make a long story short, I am looking for real samples of coding in Console Apps. I am the type of...
4
by: Paul Hemans | last post by:
Hi newbie here. I am learning c++/cli I by writing console apps. When my apps finished they used to display a message at the bottom of the screen, something like "press any key to continue" so that...
3
by: Alex | last post by:
Hello, I'm wroting a console utility in VB 2005, and I need the ability to pass parameters to the application when the program runs. For example, if my program is called testing.exe, I need to...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.