How to use good oo-structure?

Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: May 2006
Posts: 1
Reputation: matt87 is an unknown quantity at this point 
Solved Threads: 0
matt87 matt87 is offline Offline
Newbie Poster

How to use good oo-structure?

 
0
  #1
May 4th, 2006
Hi.
I am stuck when it comes to plan my application.
The purpose is to importdata from a database and export it to a cvs file. During the transfer should some data be validated (email adress). How shuld one build such a thing in good OO-structure.
I have writen a main class wich have communciate with a dbConn class, importClass, exportClass. The data is sent all over by Hashtable and strings, this does't feel like good OO.
Plase give me a hint in the right direction.
Br
Matt
Sweden
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: How to use good oo-structure?

 
0
  #2
May 5th, 2006
Usually, it helps me to draw out my code, using something like UML, or just a pen and paper.

In most circumstances, I use a wrapper class to do all of the talking to my database. That way, all of the calling classes/methods don't have to know anything about what type of database I'm connecting to.

Encapsulation is the word of the day in this matter-- the thing to focus on is this question:

"If I change something in class A, will I have to change anything in Class B to keep using Class A with it?"

If your answer is yes, then you probably need to change something in your design. The whole idea with object orientation is to have the object you've created be almost entirely responsible for doing stuff to itself. At least, that's how I understand it.

Can you post some code snippets of some parts that make you uneasy about your design? I'll admit I'm somewhat of a noob still at this game, but after reading the book Object Oriented Thought Process (disclaimer:informational link, no referrals, or anything), I really feel stronger in what exactly you're supposed to accomplish with OO design. I'm not through with the book yet, but they really reinforce the idea of encapsulation in EVERYTHING they do.

Basically, make a method that describes what you want to do. Then, the class that instantiated your object can call it, without knowing anything about what the method actually does. If done right, you can completely change the way your method works, but if you return the same types of values, and accept the same parameters as before, then the instantiating class will be none the wiser that you've changed anything
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC